Suggestion: instead of always using the same big expression
+#if defined(__GNUC__) && (!defined(__STRICT_ANSI__) ||
defined(__cplusplus) || \
+ __STDC_VERSION__ >= 199901L) && (DBL_MANT_DIG == LDBL_MANT_DIG &&
\
+ LDBL_MIN_EXP == DBL_MIN_EXP && LDBL_MAX_EXP == DBL_MAX_EXP)
define a shorter one that gets put into math.h. For example:
#if (!defined(__STRICT_ANSI__) || __STDC_VERSION__ > 199901L || \
defined(__cplusplus)) && defined(LDBL_MANT_DIG) && \
(DBL_MANT_DIG == LDBL_MANT_DIG && \
LDBL_MIN_EXP == DBL_MIN_EXP && LDBL_MAX_EXP == DBL_MAX_EXP)
#define _LDBL_EQ_DBL
#endif
[Notice that I added a check for LDBL_MANT_DIG being defined, as it
is possible for long double to not exist if it's a C89 compiler but
without STRICT_ANSI having been selected. (This is my 2nd suggestion.)
Since we've assumed the presence of float.h, checking any of the LDBL
defines is the same as a configure check for AC_TYPE_LONG_DOUBLE.
No need for configure when float.h can be assumed.]
Then, in all of the libm files (and a few places in math.h, itself):
#include <math.h>
#if defined(_LBDL_EQ_DBL)
...
#endif
This is very similar to using AC_TYPE_LONG_DOUBLE_WIDER from one
place, but is doing it via float.h instead of configure.
In addition to being easier to read in the source files, it permits
an easy modification of the if for all of the source in 1 place
instead of needing to edit it in many, should the need ever arise.
(An interesting future possibility is if a system used, for example,
128 bits for double and long double. The present routines hard code
64 or 32 bits for double. So if at that time there were 128-bit LD
routines, _LDBL_EQ_DBL would not be defined, but _DBL_EQ_LDBL could
be, which would then map the double routines to the long double. And
this will probably happen at about the same time that the US government
actually returns to a balanced budget.)
I've been planning a LDBL_EQ_DBL define for the real long double
routines
that I'm working on, but have it in a math library local include.
"Promoting" it to math.h probably makes sense.
A minor variation of the above is to also define something that says
long double ought to be used, where a potential user-configured choice
to not use long double even if it could be is also demonstrated:
#if (!defined(__STRICT_ANSI__) || __STDC_VERSION__ > 199901L || \
defined(__cplusplus)) && defined(LDBL_MANT_DIG) && \
!defined(SKIP_LDBL)
#define _USE_LDBL
#endif
Then, in all of the libm files (and a few places in math.h, itself):
#include <math.h>
#if defined(_USE_LDBL) && defined(_LBDL_EQ_DBL)
...
#endif
Or, down the road:
#if defined(_USE_LDBL)
#if !defined(_LDBL_EQ_DBL)
real function
# else
wrapper
#endif
#endif
_USE_LDBL probably does not make sense in the source files, as would
make more sense to leave the LDBL source out of the makefiles. But it
could make sense in header files.