standards/65939: [patch] namespace issues in <math.h>
Stefan Farfeleder
stefan at fafoe.narf.at
Sat Apr 24 13:50:21 PDT 2004
>Number: 65939
>Category: standards
>Synopsis: [patch] namespace issues in <math.h>
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-standards
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: sw-bug
>Submitter-Id: current-users
>Arrival-Date: Sat Apr 24 13:50:20 PDT 2004
>Closed-Date:
>Last-Modified:
>Originator: Stefan Farfeleder
>Release: FreeBSD 5.2-CURRENT i386
>Organization:
>Environment:
System: FreeBSD frog.fafoe.narf.at 5.2-CURRENT FreeBSD 5.2-CURRENT #38: Sat Apr 24 19:45:23 CEST 2004 freebsd at frog.fafoe.narf.at:/freebsd/frog/obj/freebsd/frog/src/sys/FROG i386
>Description:
Here's a list of identifiers defined in <math.h> that aren't protected
correctly and the namespace they should belong to.
C99 means __ISO_C_VISIBLE >= 1999
BSD means __BSD_VISIBLE
XSI means __XSI_VISIBLE
1 -> C99:
FP_ILOGB0, FP_ILOGBNAN, HUGE_VALF, HUGE_VALL, INFINITY, NAN,
FP_INFINITE, FP_NAN, FP_NORMAL, FP_SUBNORMAL, FP_ZERO,
fpclassify, isfinite, isinf, isnan, isnormal,
isgreater, isgreaterequal, isless, islessequal, islessgreater,
isunordered, signbit, double_t, float_t
1 -> BSD:
isnanf,
!_ANSI_SOURCE && !_POSIX_SOURCE -> C99 | XSI:
lgamma, expm1, log1p
!_ANSI_SOURCE && !_POSIX_SOURCE -> BSD:
drem, finite
!_ANSI_SOURCE && !_POSIX_SOURCE -> XSI:
M_E, M_E, M_LOG2E, M_LOG10E, M_LN2, M_LN10, M_PI, M_PI_2, M_PI_4,
M_1_PI, M_2_PI, M_2_SQRTPI, M_SQRT2, M_SQRT1_2, MAXFLOAT, signgam, j0,
j1, jn, y0, y1, yn
!_ANSI_SOURCE && !_POSIX_SOURCE && !_XOPEN_SOURCE -> C99:
tgamma, copysign, rint, scalbn, acosf, asinf, atanf, atan2f, cosf, sinf,
tanf, coshf, sinhf, tanhf, expf, frexpf, log10f, modff, powf, sqrtf,
ceilf, fabsf, floorf, fmodf, erff, erfcf, hypotf, lgammaf, acoshf,
asinhf, atanhf, cbrtf, nextafterf, remainderf, copysignf, ilogbf, rintf,
scalbnf, expm1f, log1pf, fabsl
!_ANSI_SOURCE && !_POSIX_SOURCE && !_XOPEN_SOURCE -> C99 | XSI:
erf, erfc, hypot, acosh, asinh, atanh, cbrt, logb, nextafter, remainder,
ilogb
!_ANSI_SOURCE && !_POSIX_SOURCE && !_XOPEN_SOURCE -> XSI:
gamma (_XOPEN_SOURCE <= 500 only), scalb
!_ANSI_SOURCE && !_POSIX_SOURCE && !_XOPEN_SOURCE -> BSD:
matherr, significand, finitef, gammaf, j0f, j1f, jnf, y0f, y1f, ynf,
scalbf, significandf, dremf,
The macro isnan() should be __XSI_VISIBLE too, but it currently uses C99's
fpclassify(). I also removed a stale comment about <values.h>, this should
probably be committed separately.
>How-To-Repeat:
>Fix:
--- math.h.diff begins here ---
Index: /usr/src/lib/msun/src/math.h
===================================================================
RCS file: /usr/home/ncvs/src/lib/msun/src/math.h,v
retrieving revision 1.29
diff -u -r1.29 math.h
--- /usr/src/lib/msun/src/math.h 12 Mar 2004 12:05:38 -0000 1.29
+++ /usr/src/lib/msun/src/math.h 24 Apr 2004 19:52:17 -0000
@@ -32,19 +32,19 @@
float __uf;
} __nan;
+#define HUGE_VAL (__infinity.__ud)
+
+#if __ISO_C_VISIBLE >= 1999
#define FP_ILOGB0 (-0x7fffffff - 1) /* INT_MIN */
#define FP_ILOGBNAN 0x7fffffff /* INT_MAX */
-#define HUGE_VAL (__infinity.__ud)
#define HUGE_VALF (float)HUGE_VAL
#define HUGE_VALL (long double)HUGE_VAL
#define INFINITY HUGE_VALF
#define NAN (__nan.__uf)
-#if __ISO_C_VISIBLE >= 1999
#define MATH_ERRNO 1
#define MATH_ERREXCEPT 2
#define math_errhandling 0
-#endif
/* Symbolic constants to classify floating point numbers. */
#define FP_INFINITE 0x01
@@ -60,7 +60,6 @@
#define isfinite(x) ((fpclassify(x) & (FP_INFINITE|FP_NAN)) == 0)
#define isinf(x) (fpclassify(x) == FP_INFINITE)
#define isnan(x) (fpclassify(x) == FP_NAN)
-#define isnanf(x) isnan(x)
#define isnormal(x) (fpclassify(x) == FP_NORMAL)
#define isgreater(x, y) (!isunordered((x), (y)) && (x) > (y))
@@ -75,11 +74,12 @@
typedef __double_t double_t;
typedef __float_t float_t;
+#endif /* __ISO_C_VISIBLE >= 1999 */
/*
* XOPEN/SVID
*/
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+#if __XSI_VISIBLE
#define M_E 2.7182818284590452354 /* e */
#define M_LOG2E 1.4426950408889634074 /* log 2e */
#define M_LOG10E 0.43429448190325182765 /* log 10e */
@@ -96,8 +96,9 @@
#define MAXFLOAT ((float)3.40282346638528860e+38)
extern int signgam;
+#endif
-#if !defined(_XOPEN_SOURCE)
+#if __BSD_VISIBLE
enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
#define _LIB_VERSION_TYPE enum fdversion
@@ -129,6 +130,8 @@
};
#endif
+#define isnanf(x) isnan(x)
+
#if 0
/* Old value from 4.4BSD-Lite math.h; this is probably better. */
#define HUGE HUGE_VAL
@@ -136,12 +139,7 @@
#define HUGE MAXFLOAT
#endif
-/*
- * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
- * (one may replace the following line by "#include <values.h>")
- */
-
-#define X_TLOSS 1.41484755040568800000e+16
+#define X_TLOSS 1.41484755040568800000e+16 /* pi*2**52 */
#define DOMAIN 1
#define SING 2
@@ -150,8 +148,7 @@
#define TLOSS 5
#define PLOSS 6
-#endif /* !_XOPEN_SOURCE */
-#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
+#endif /* __BSD_VISIBLE */
#include <sys/cdefs.h>
@@ -202,65 +199,70 @@
* These functions are not in C90 so they can be "right". The ones that
* never set errno in lib/msun are declared as __pure2.
*/
-#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+#if __ISO_C_VISIBLE >= 1999 || __XSI_VISIBLE
+double acosh(double);
+double asinh(double);
+double atanh(double);
+double cbrt(double) __pure2;
double erf(double);
double erfc(double) __pure2;
-int finite(double) __pure2;
-double gamma(double);
+double expm1(double) __pure2;
double hypot(double, double);
+int ilogb(double);
+double lgamma(double);
+double log1p(double) __pure2;
+double logb(double) __pure2;
+double nextafter(double, double);
+double remainder(double, double);
+double rint(double) __pure2;
+#endif
+
+#if __XSI_VISIBLE
double j0(double);
double j1(double);
double jn(int, double);
-double lgamma(double);
+double scalb(double, double);
double y0(double);
double y1(double);
double yn(int, double);
-#if !defined(_XOPEN_SOURCE)
-double acosh(double);
-double asinh(double);
-double atanh(double);
-double cbrt(double) __pure2;
-double logb(double) __pure2;
-double nextafter(double, double);
-double remainder(double, double);
-double scalb(double, double);
-double tgamma(double);
-
-#ifndef __cplusplus
-int matherr(struct exception *);
+#if __XSI_VISIBLE <= 500 || __BSD_VISIBLE
+double gamma(double);
#endif
+#endif /* __XSI_VISIBLE */
-/*
- * IEEE Test Vector
- */
-double significand(double);
-
-/*
- * Functions callable from C, intended to support IEEE arithmetic.
- */
+#if __ISO_C_VISIBLE >= 1999
double copysign(double, double) __pure2;
-int ilogb(double);
-double rint(double) __pure2;
double scalbn(double, int);
+double tgamma(double);
+#endif
/*
* BSD math library entry points
*/
+#if __BSD_VISIBLE
double drem(double, double);
-double expm1(double) __pure2;
-double log1p(double) __pure2;
+int finite(double) __pure2;
/*
* Reentrant version of gamma & lgamma; passes signgam back by reference
* as the second argument; user must allocate space for signgam.
*/
-#if __BSD_VISIBLE
double gamma_r(double, int *);
double lgamma_r(double, int *);
+
+/*
+ * IEEE Test Vector
+ */
+double significand(double);
+
+#ifndef __cplusplus
+int matherr(struct exception *);
+#endif
#endif /* __BSD_VISIBLE */
/* float versions of ANSI/POSIX functions */
+#if __ISO_C_VISIBLE >= 1999
float acosf(float);
float asinf(float);
float atanf(float);
@@ -274,10 +276,13 @@
float tanhf(float);
float expf(float);
+float expm1f(float) __pure2;
float frexpf(float, int *); /* fundamentally !__pure2 */
+int ilogbf(float);
float ldexpf(float, int);
-float logf(float);
float log10f(float);
+float log1pf(float) __pure2;
+float logf(float);
float modff(float, float *); /* fundamentally !__pure2 */
float powf(float, float);
@@ -290,60 +295,54 @@
float erff(float);
float erfcf(float) __pure2;
-int finitef(float) __pure2;
-float gammaf(float);
float hypotf(float, float) __pure2;
-float j0f(float);
-float j1f(float);
-float jnf(int, float);
float lgammaf(float);
-float y0f(float);
-float y1f(float);
-float ynf(int, float);
float acoshf(float);
float asinhf(float);
float atanhf(float);
float cbrtf(float) __pure2;
float logbf(float) __pure2;
+float copysignf(float, float) __pure2;
float nextafterf(float, float);
float remainderf(float, float);
-float scalbf(float, float);
-
-/*
- * float version of IEEE Test Vector
- */
-float significandf(float);
-
-/*
- * Float versions of functions callable from C, intended to support
- * IEEE arithmetic.
- */
-float copysignf(float, float) __pure2;
-int ilogbf(float);
float rintf(float);
float scalbnf(float, int);
+#endif
/*
* float versions of BSD math library entry points
*/
+#if __BSD_VISIBLE
float dremf(float, float);
-float expm1f(float) __pure2;
-float log1pf(float) __pure2;
+int finitef(float) __pure2;
+float gammaf(float);
+float j0f(float);
+float j1f(float);
+float jnf(int, float);
+float scalbf(float, float);
+float y0f(float);
+float y1f(float);
+float ynf(int, float);
/*
* Float versions of reentrant version of gamma & lgamma; passes
* signgam back by reference as the second argument; user must
* allocate space for signgam.
*/
-#if __BSD_VISIBLE
float gammaf_r(float, int *);
float lgammaf_r(float, int *);
+
+/*
+ * float version of IEEE Test Vector
+ */
+float significandf(float);
#endif /* __BSD_VISIBLE */
/*
* long double versions of ISO/POSIX math functions
*/
+#if __ISO_C_VISIBLE >= 1999
#if 0
long double acoshl(long double);
long double acosl(long double);
@@ -408,8 +407,7 @@
long double truncl(long double);
#endif
-#endif /* !_XOPEN_SOURCE */
-#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
+#endif /* __ISO_C_VISIBLE >= 1999 */
__END_DECLS
#endif /* !_MATH_H_ */
--- math.h.diff ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-standards
mailing list