Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/include Correct C99 / C++11 feature testing. Document remain...



details:   https://anonhg.NetBSD.org/src/rev/6c1a0c14c965
branches:  trunk
changeset: 745105:6c1a0c14c965
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Feb 22 22:47:35 2020 +0000

description:
Correct C99 / C++11 feature testing. Document remaining missing symbols.

diffstat:

 include/math.h |  73 ++++++++++++++++++++++++++++-----------------------------
 1 files changed, 36 insertions(+), 37 deletions(-)

diffs (170 lines):

diff -r 89ddbe4b7b7f -r 6c1a0c14c965 include/math.h
--- a/include/math.h    Sat Feb 22 22:20:47 2020 +0000
+++ b/include/math.h    Sat Feb 22 22:47:35 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: math.h,v 1.65 2018/06/24 23:55:29 christos Exp $       */
+/*     $NetBSD: math.h,v 1.66 2020/02/22 22:47:35 joerg Exp $  */
 
 /*
  * ====================================================
@@ -21,6 +21,16 @@
 #include <sys/cdefs.h>
 #include <sys/featuretest.h>
 
+/*
+ * Missing for C99 support:
+ * - MATH_ERRNO
+ * - MATH_ERREXCEPT
+ * - FP_FAST_FMA
+ * - FP_FAST_FMAF
+ * - FP_FAST_FMAL
+ * - math_errhandling
+ */
+
 union __float_u {
        unsigned char __dummy[sizeof(float)];
        float __val;
@@ -40,7 +50,14 @@
                                           or __long_double_u */
 #include <limits.h>                    /* for INT_{MIN,MAX} */
 
-#if ((_POSIX_C_SOURCE - 0) >= 200809L || defined(_NETBSD_SOURCE))
+#if (!defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
+    !defined(_XOPEN_SOURCE)) || ((_POSIX_C_SOURCE - 0) >= 200809L || \
+     defined(_ISOC99_SOURCE) || (__STDC_VERSION__ - 0) >= 199901L || \
+     (__cplusplus - 0) >= 201103L || defined(_NETBSD_SOURCE))
+#define __MATH_C99_FEATURES
+#endif
+
+#ifdef __MATH_C99_FEATURES
 #  if defined(__FLT_EVAL_METHOD__) && (__FLT_EVAL_METHOD__ - 0) == 0
 typedef double double_t;
 typedef float float_t;
@@ -83,12 +100,8 @@
 /*
  * ISO C99
  */
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
-    !defined(_XOPEN_SOURCE) || \
-    ((__STDC_VERSION__ - 0) >= 199901L) || \
-    ((_POSIX_C_SOURCE - 0) >= 200112L) || \
-    ((_XOPEN_SOURCE  - 0) >= 600) || \
-    defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
+#if defined(__MATH_C99_FEATURES) || \
+    (_POSIX_C_SOURCE - 0) >= 200112L || (_XOPEN_SOURCE  - 0) >= 600
 /* 7.12#3 HUGE_VAL, HUGELF, HUGE_VALL */
 #if __GNUC_PREREQ__(3, 3)
 #define        HUGE_VALF       __builtin_huge_valf()
@@ -133,7 +146,7 @@
 #define        FP_ILOGB0       INT_MIN
 #define        FP_ILOGBNAN     INT_MAX
 
-#endif /* !_ANSI_SOURCE && ... */
+#endif /* C99 || _XOPEN_SOURCE >= 600 */
 
 /*
  * XOPEN/SVID
@@ -238,16 +251,18 @@
 double floor(double);
 double fmod(double, double);
 
-#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+#if defined(__MATH_C99_FEATURES) || defined(_XOPEN_SOURCE)
 double erf(double);
 double erfc(double);
+double hypot(double, double);
+#endif
+
+#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE)
+int    finite(double);
 double gamma(double);
-double hypot(double, double);
-int    finite(double);
 double j0(double);
 double j1(double);
 double jn(int, double);
-double lgamma(double);
 double y0(double);
 double y1(double);
 double yn(int, double);
@@ -260,12 +275,7 @@
 /*
  * ISO C99
  */
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
-    !defined(_XOPEN_SOURCE) || \
-    ((__STDC_VERSION__ - 0) >= 199901L) || \
-    ((_POSIX_C_SOURCE - 0) >= 200809L) || \
-    ((_XOPEN_SOURCE  - 0) >= 500) || \
-    defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
+#if defined(__MATH_C99_FEATURES) || (_XOPEN_SOURCE - 0) >= 500
 double acosh(double);
 double asinh(double);
 double atanh(double);
@@ -279,12 +289,8 @@
 double rint(double);
 #endif
 
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) && \
-    !defined(_XOPEN_SOURCE) || \
-    ((__STDC_VERSION__ - 0) >= 199901L) || \
-    ((_POSIX_C_SOURCE - 0) >= 200112L) || \
-    ((_XOPEN_SOURCE  - 0) >= 600) || \
-    defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
+#if defined(__MATH_C99_FEATURES) || (_XOPEN_SOURCE - 0) >= 600 || \
+    (_POSIX_C_SOURCE - 0) >= 200112L
 /* 7.12.3.1 int fpclassify(real-floating x) */
 #define        fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)
 
@@ -331,6 +337,8 @@
 long double    tanhl(long double);
 
 /* 7.12.6 exp / log */
+double scalbn(double, int);
+double scalbln(double, long);
 
 float  expf(float);
 float  exp2f(float);
@@ -378,6 +386,7 @@
 
 /* 7.12.8 error / gamma */
 
+double lgamma(double);
 double tgamma(double);
 float  erff(float);
 float  erfcf(float);
@@ -436,6 +445,7 @@
 
 /* 7.12.11 manipulation */
 
+double copysign(double, double);
 double nan(const char *);
 double nearbyint(double);
 double nexttoward(double, long double);
@@ -474,11 +484,7 @@
 
 #endif /* !_ANSI_SOURCE && ... */
 
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_C_SOURCE) || \
-    !defined(_XOPEN_SOURCE) || \
-    ((__STDC_VERSION__ - 0) >= 199901L) || \
-    ((_POSIX_C_SOURCE - 0) >= 200112L) || \
-    defined(_ISOC99_SOURCE) || defined(_NETBSD_SOURCE)
+#if defined(__MATH_C99_FEATURES) || (_POSIX_C_SOURCE - 0) >= 200112L
 /* 7.12.3.3 int isinf(real-floating x) */
 #if defined(__isinf) || defined(__HAVE_INLINE___ISINF)
 #define        isinf(__x)      __isinf(__x)
@@ -505,13 +511,6 @@
 double significand(double);
 
 /*
- * Functions callable from C, intended to support IEEE arithmetic.
- */
-double copysign(double, double);
-double scalbn(double, int);
-double scalbln(double, long);
-
-/*
  * BSD math library entry points
  */
 double drem(double, double);



Home | Main Index | Thread Index | Old Index