tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] tcc_relocate() and tcc_relocate_ex()


From: Michael Matz
Subject: Re: [Tinycc-devel] tcc_relocate() and tcc_relocate_ex()
Date: Sun, 2 Sep 2012 22:26:13 +0200 (CEST)
User-agent: Alpine 2.00 (LNX 1167 2008-08-23)

Hi,

On Wed, 29 Aug 2012, grischka wrote:

What about this:  Keep the 0.9.25 declaration of tcc_relocate, which was:

Sure.  Keep tcc_relocate with its current signature.

  /* copy code into memory passed in by the caller and do all relocations
     (needed before using tcc_get_symbol()).
     returns -1 on error and required size if ptr is NULL */
   LIBTCCAPI int tcc_relocate(TCCState *s1, void *ptr);

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.

You earnestly added this interface abomination to avoid exporting a function? I mean, huh? Well, as you asked: yes it's ugly, and yes it's confusing. (and it's also non-C, ((void*)-1) might not be representable; the only integer literal that definitely is convertible into a pointer is 0; but I'll admit that this would just be a nitpick). But why you think this interface would be better than an explicit one with two functions is a complete mystery to me. I mean, really, can you give a reason? I'm seriously interested.


Ciao,
Michael.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]