This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: log2, log2f


On Mar 18 11:28, Christopher Faylor wrote:
> On Wed, Mar 18, 2009 at 06:07:11AM -0600, Eric Blake wrote:
> >-----BEGIN PGP SIGNED MESSAGE-----
> >Hash: SHA1
> >
> >According to Yaakov (Cygwin/X) on 3/17/2009 7:50 PM:
> >> SUSv3 requires that log2 and log2f be defined as functions (at least)
> >> and may also be defined as macros.  Right now, though, these are only
> >> defined as macros, and besides being noncompliant, it also creates false
> >> negatives with configure AC_CHECK_FUNC[S] tests.
> >> 
> >> Here's my first attempt at a patch to define these as functions instead.
> >
> >Your patch adds the functions (good) but deletes the macros.  SUSv3 (and
> >v4) allow these to be macros in addition to functions.  Since the body is
> >so trivial, maybe it is worth keeping the macro around to avoid the
> >penalty of an extra function call, with minimal impact to code size in the
> >common usage of log2?
> 
> I discussed this with Yaakov on irc but how would you do this exactly?  Where
> would you define the function if log2 is already defined as a macro?

First declare the function, then define the macro in the same header.
In the source, undef the function name.  This is also done for stdio
functions like getchar, getwchar, for instance.


Corinna

-- 
Corinna Vinschen
Cygwin Project Co-Leader
Red Hat


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]