robo...@celest.fr wrote:
I already did a general function to store a value but I adopted a different approach:

#define put_sym_attr(s,index,field,val) \
    alloc_sym_attr(s, index);           \
    s->sym_attrs[index].field = val

where alloc_sym_attr is the old put_got_offset without the assignment line at the end. See attached file for the full patch (only tested on x86-64 so far, I'll try to compile it on arm later).

To my taste that macro with 4 args (and omitted ';') is a too clever
workaround to avoid letting alloc_sym_attr() return a value.

Compare
     put_sym_attr(s1, sym_index, got_offset, s1->got->data_offset);
with
     alloc_sym_attr(s1, sym_index)->got_offset = s1->got->data_offset;

Clearly the latter is better readable (since '=' is C for 'put') and
without the additional macro your patch will be shorter which is
what counts in the end. ;)

Also, in general, there is always an certain ugliness with 'void'
functions.  Thus if a function can return some useful value, then it
should do so.  Think of 'strcpy'.  (In that sense and opposed to the
related GCC warning it is of course not wrong not to use a return
value.)

> +    typeof(s1->sym_attrs) tab;

Is this C?  Note that not just GCC and TCC might be used to compile
tcc.  (E.g. more recent MS compilers from the VCExpress editions used
to work)

Thanks,

--- grischka


_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to