Macros using __NO_LONG_DOUBLE_MATH
Wilco Dijkstra
wdijkstr@arm.com
Thu Jun 4 12:18:00 GMT 2015
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
More information about the Libc-alpha
mailing list