This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


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

Re: Implementation of <tgmath.h>


On Fri, 28 Jul 2000, Joern Rennecke wrote:

> > Geoff Keating <geoffk@cygnus.com> writes:
> > 
> > > There is, or used to be, a '__builtin_classify_type' builtin that
> > > might be helpful here.
> > 
> > No, this does not work.
> 
> Why not?  You could check for real_type_class, and if it is, you use the
> sizeof tests.
> 
> Another approach would be to cast 0.25 to the argument type, and test if
> that's non-zero.  If so, we are dealing with a floating point type.

The type of the final expression needs to be right - i.e., float, double
or long double according to the type of the arguments.  The type of a
statement expression is the type of the last expression in it (the one
returned) - which reduces to needing to produce a typeof expression for
that type; even if you can identify the right function, you still need the
right type of return value (e.g. for passing the return direct into printf
or into another tgmath macro).  I don't see how to get that
right.  (Strictly, if a target doesn't distinguish all of the float,
double, long double types in terms of representation, they are still
distinct types, and the right return value must be chosen, and all the
long double functions must exist (even if just as aliases) - though I
can't right now think of how to tell whether the type is correct in such a
case using only the properties of the standard (typeof makes this
easy).)  (If __builtin_classify_type could be used in integer constant
expressions, then it would be possible to convert integer types to double
within a typeof.)

-- 
Joseph S. Myers
jsm28@cam.ac.uk


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