Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20120309105703.GT5728@port70.net>
Date: Fri, 9 Mar 2012 11:57:03 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: libm

* Rich Felker <dalias@...ifal.cx> [2012-03-09 05:22:39 -0500]:

> On Mon, Mar 05, 2012 at 04:17:11PM +0100, Szabolcs Nagy wrote:
> > * Rich Felker <dalias@...ifal.cx> [2012-03-05 09:04:59 -0500]:
> > > On Mon, Mar 05, 2012 at 09:51:35AM +0100, Szabolcs Nagy wrote:
> > > Hm? If you need a macro to test whether an argument is an integer or
> > > floating point, try this:
> > > 
> > > #define __IS_FP(x) !!((1?1:(x))/2)
> > > 
> > 
> > oh nice
> > (and subtle)
> 
> I checked out your latest tgmath.h; it's surprisingly clean and
> readable! A couple ideas..
> 
> 1. __fun could be just fun (macro arguments are free of namespace
> issues)
> 

hm true

> 2. You could add something like:
> #ifdef __GNUC__
> #define __RETCAST(x) (__typeof__((x))
> #else
> #define __RETCAST(x)
> #endif
> Then add __RETCAST((x)), __RETCAST((x)+(y)), etc. Some trick will be
> needed to make integer types result in a cast to double, though.
> 

ok, that makes sense

actually i'm not sure when the extra () protection
is needed like __typeof__((x))
(the reason for it in (x)+(y) is clear)

is it because single argument macros might get
called with a comma expression?

so
#define A(x) B((x))
is ok

but
#define A(x,y) B((x),(y))
is redundant

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.