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: Sean Conner
Subject: Re: [Tinycc-devel] tcc_relocate() and tcc_relocate_ex()
Date: Wed, 29 Aug 2012 11:44:26 -0400
User-agent: Mutt/1.4.1i

It was thus said that the Great grischka once stated:
> Michael Matz wrote:
> >
> >So, while the complaint about the leak is correct, the conservatism 
> >about exporting one internal function (whose functionality once was 
> >available as an exported function that was removed from the API) is 
> >hypocritic at best.
> >Sorry for that assessment.  IOW: I don't understand your reservations.
> >
> >To make it short: just export the damn thing.  It makes sense.
> >
> 
> Well I hope this damn thing makes sense because I wrote it. ;)
> 
> Anyway, we're not in a hurry, are we?

  Define "hurry".  I'd like to see this happen sooner than later, as I have
code I already depend on and would rather not keep a separate fork of tcc
around any longer than I have to.

> What about this:  Keep the 0.9.25 declaration of tcc_relocate, which was:
> 
>    /* 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?  

  Personally, I don't mind the two functions, although I might rename
tcc_relocate_ex() to tcc_relocate_mem() or tcc_relocate_here() (which I
personally like, as it describes what is being done much better).  That way,
you wouldn't have to change the example codes and they remain as simple as
possible (which is the reason for the change in tcc_relocate() in the first
place).  On the other hand ... 

> 0.9.26 isn't out yet so we can still decide.

  Um, about that ... 

Version 0.9.25 from http://www.tcc.org/ (which is where anyone looking for
"tcc compiler" will find first):
        LIBTCCAPI int tcc_relocate(TCCState *s1, void *ptr);

Version 0.9.25 from http://repo.or.cz/w/tinycc.git (which someone will find
if they look a bit further):
        LIBTCCAPI int tcc_relocate(TCCState *s1);

  You made an incompatible API change and didn't bother to bump the version
number.  So saying that 0.9.26 isn't out yet is a moot point I would think.

  Now, in light of that, you could change tcc_relocate() back to the
www.tcc.org version, and add:

        LIBTCCAPI int tcc_relocate_simple(TCCState *s1);

to remain compatible with the www.tcc.org version (although I'm not happy
with the name, but I have nothing better at this time).

  -spc (Not a fan of TCC_RELOCATE_AUTO ... )




reply via email to

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