Jared Maddox wrote:
but define a special value for 'ptr' to get behavior as of 0.9.24, as in:

    /* Do all relocations. Needed before using tcc_get_symbol().
       Possible values for ptr:
         - TCC_RELOCATE_AUTO : Allocate memory internally
         - NULL              : return required memory size for the step
below
         - memory address    : copy code into memory passed by the caller
       returns -1 on error. */

     LIBTCCAPI int tcc_relocate(TCCState *s1, void *ptr);
     #define TCC_RELOCATE_AUTO (void*)-1

Is this ugly?  Confusing?  0.9.26 isn't out yet so we can still decide.

--- grischka


If you're going to use that method, then I'd suggest this definition
of TCC_RELOCATE_AUTO:
#define TCC_RELOCATE_AUTO (void*)&tcc_relocate

If I recall the C standard correctly, that will result on a value
that's unique from all other valid addresses even on Harvard
architectures (though porting TCC to one of those would be
"difficult"), thus ensuring that the new behavior can only be invoked
by accident if the calling code has a bug.

It also makes it easy to not run into a conflict with anything else,
which could be relevant, since I half recall some architectures having
valid negative addresses for some reason..

Thanks, and so we conclude that even with most careful considerations
unique can still be different to really unique, in practice.

In this case because &tcc_relocate in a libtcc.dll is resolved to
the function itself, but in the client code is resolved to the
function vector (on windows, with any of GCC, CL, TCC).

I dropped the minus and currently plan to go with

   #define TCC_RELOCATE_AUTO (void*)1

Better name or other suggestions still welcome.

--- grischka


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

Reply via email to