This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Macros using __NO_LONG_DOUBLE_MATH
- From: "Wilco Dijkstra" <wdijkstr at arm dot com>
- To: "GNU C Library" <libc-alpha at sourceware dot org>
- Cc: "'Joseph Myers'" <joseph at codesourcery dot com>
- Date: Thu, 4 Jun 2015 12:12:03 +0100
- Subject: Macros using __NO_LONG_DOUBLE_MATH
- Authentication-results: sourceware.org; auth=none
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