This is the mail archive of the libc-alpha@sourceware.org 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]
Other format: [Raw text]

Macros using __NO_LONG_DOUBLE_MATH


Hi,

Looking at math/math.h, a common idiom is:

# ifdef __NO_LONG_DOUBLE_MATH
#  define isnan(x) \
     (sizeof (x) == sizeof (float) ? __isnanf (x) : __isnan (x))
# else
#  define isnan(x) \
     (sizeof (x) == sizeof (float)                                            \
      ? __isnanf (x)                                                          \
      : sizeof (x) == sizeof (double)                                         \
      ? __isnan (x) : __isnanl (x))
# endif

This looks unnecessary - given that it is OK to use the double version when
__NO_LONG_DOUBLE_MATH is defined, sizeof (long double) == sizeof (double)
when long double math is not supported. Also sysdeps/ieee754/ldbl-opt
defines all the long double functions using double, so even we did accidentally
expand into __isnanl, it would be the same as __isnan anyway.

So can we simplify the logic to this?

#define isnan(x) \
     (sizeof (x) == sizeof (float)                                            \
      ? __isnanf (x)                                                          \
      : sizeof (x) == sizeof (double)                                         \
      ? __isnan (x) : __isnanl (x))

This would make adding inlines using GCC built-ins far less messy.

Wilco



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