Print this page
10882 math headers should stop supporting K&R C

@@ -34,17 +34,20 @@
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#ifndef __P
-#ifdef __STDC__
-#define __P(p)  p
-#else
-#define __P(p)  ()
-#endif
-#endif  /* !defined(__P) */
+#undef  FP_ZERO
+#define FP_ZERO         0
+#undef  FP_SUBNORMAL
+#define FP_SUBNORMAL    1
+#undef  FP_NORMAL
+#define FP_NORMAL       2
+#undef  FP_INFINITE
+#define FP_INFINITE     3
+#undef  FP_NAN
+#define FP_NAN          4
 
 #if defined(_STDC_C99) || _XOPEN_SOURCE - 0 >= 600 || defined(__C99FEATURES__)
 #if defined(__GNUC__)
 #undef  HUGE_VAL
 #define HUGE_VAL        (__builtin_huge_val())

@@ -63,19 +66,23 @@
 #undef  isnan
 #undef  isinf
 #if __GNUC__ >= 4
 #define isnan(x)        __builtin_isnan(x)
 #define isinf(x)        __builtin_isinf(x)
-#else
+#define fpclassify(x)   __builtin_fpclassify(FP_NAN, FP_INFINITE, FP_NORMAL, \
+    FP_SUBNORMAL, FP_ZERO, x)
+#define isfinite(x)     __builtin_isfinite(x)
+#define isnormal(x)     __builtin_isnormal(x)
+#define signbit(x)      __builtin_signbit(x)
+#else  /* __GNUC__ >= 4 */
 #define isnan(x)        __extension__( \
                         { __typeof(x) __x_n = (x); \
                         __builtin_isunordered(__x_n, __x_n); })
 #define isinf(x)        __extension__( \
                         { __typeof(x) __x_i = (x); \
                         __x_i == (__typeof(__x_i)) INFINITY || \
                         __x_i == (__typeof(__x_i)) (-INFINITY); })
-#endif
 #undef  isfinite
 #define isfinite(x)     __extension__( \
                         { __typeof(x) __x_f = (x); \
                         !isnan(__x_f) && !isinf(__x_f); })
 #undef  isnormal

@@ -96,20 +103,21 @@
                         FP_SUBNORMAL; })
 #undef  signbit
 #if defined(_BIG_ENDIAN)
 #define signbit(x)      __extension__( \
                         { __typeof(x) __x_s = (x); \
-                        (int) (*(unsigned *) &__x_s >> 31); })
+                        (int)(*(unsigned *)&__x_s >> 31); })
 #elif defined(_LITTLE_ENDIAN)
 #define signbit(x)      __extension__( \
                         { __typeof(x) __x_s = (x); \
                         (sizeof (__x_s) == sizeof (float) ? \
-                        (int) (*(unsigned *) &__x_s >> 31) : \
+                        (int)(*(unsigned *)&__x_s >> 31) : \
                         sizeof (__x_s) == sizeof (double) ? \
-                        (int) (((unsigned *) &__x_s)[1] >> 31) : \
-                        (int) (((unsigned short *) &__x_s)[4] >> 15)); })
-#endif
+                        (int)(((unsigned *)&__x_s)[1] >> 31) : \
+                        (int)(((unsigned short *)&__x_s)[4] >> 15)); })
+#endif  /* defined(_BIG_ENDIAN) */
+#endif  /* __GNUC__ >= 4 */
 
 /*
  * C99 7.12.14 comparison macros
  */
 #undef  isgreater

@@ -188,21 +196,10 @@
 #elif defined(__i386)
 typedef long double float_t;
 typedef long double double_t;
 #endif
 
-#undef  FP_ZERO
-#define FP_ZERO         0
-#undef  FP_SUBNORMAL
-#define FP_SUBNORMAL    1
-#undef  FP_NORMAL
-#define FP_NORMAL       2
-#undef  FP_INFINITE
-#define FP_INFINITE     3
-#undef  FP_NAN
-#define FP_NAN          4
-
 #undef  FP_ILOGB0
 #define FP_ILOGB0       (-2147483647)
 #undef  FP_ILOGBNAN
 #define FP_ILOGBNAN     2147483647
 

@@ -211,192 +208,192 @@
 #undef  MATH_ERREXCEPT
 #define MATH_ERREXCEPT  2
 #undef  math_errhandling
 #define math_errhandling        MATH_ERREXCEPT
 
-extern double acosh __P((double));
-extern double asinh __P((double));
-extern double atanh __P((double));
-
-extern double exp2 __P((double));
-extern double expm1 __P((double));
-extern int ilogb __P((double));
-extern double log1p __P((double));
-extern double log2 __P((double));
-extern double logb __P((double));
-extern double scalbn __P((double, int));
-extern double scalbln __P((double, long int));
-
-extern double cbrt __P((double));
-extern double hypot __P((double, double));
-
-extern double erf __P((double));
-extern double erfc __P((double));
-extern double lgamma __P((double));
-extern double tgamma __P((double));
-
-extern double nearbyint __P((double));
-extern double rint __P((double));
-extern long int lrint __P((double));
-extern double round __P((double));
-extern long int lround __P((double));
-extern double trunc __P((double));
-
-extern double remainder __P((double, double));
-extern double remquo __P((double, double, int *));
-
-extern double copysign __P((double, double));
-extern double nan __P((const char *));
-extern double nextafter __P((double, double));
-extern double nexttoward __P((double, long double));
-
-extern double fdim __P((double, double));
-extern double fmax __P((double, double));
-extern double fmin __P((double, double));
-
-extern double fma __P((double, double, double));
-
-extern float acosf __P((float));
-extern float asinf __P((float));
-extern float atanf __P((float));
-extern float atan2f __P((float, float));
-extern float cosf __P((float));
-extern float sinf __P((float));
-extern float tanf __P((float));
-
-extern float acoshf __P((float));
-extern float asinhf __P((float));
-extern float atanhf __P((float));
-extern float coshf __P((float));
-extern float sinhf __P((float));
-extern float tanhf __P((float));
-
-extern float expf __P((float));
-extern float exp2f __P((float));
-extern float expm1f __P((float));
-extern float frexpf __P((float, int *));
-extern int ilogbf __P((float));
-extern float ldexpf __P((float, int));
-extern float logf __P((float));
-extern float log10f __P((float));
-extern float log1pf __P((float));
-extern float log2f __P((float));
-extern float logbf __P((float));
-extern float modff __P((float, float *));
-extern float scalbnf __P((float, int));
-extern float scalblnf __P((float, long int));
-
-extern float cbrtf __P((float));
-extern float fabsf __P((float));
-extern float hypotf __P((float, float));
-extern float powf __P((float, float));
-extern float sqrtf __P((float));
-
-extern float erff __P((float));
-extern float erfcf __P((float));
-extern float lgammaf __P((float));
-extern float tgammaf __P((float));
-
-extern float ceilf __P((float));
-extern float floorf __P((float));
-extern float nearbyintf __P((float));
-extern float rintf __P((float));
-extern long int lrintf __P((float));
-extern float roundf __P((float));
-extern long int lroundf __P((float));
-extern float truncf __P((float));
-
-extern float fmodf __P((float, float));
-extern float remainderf __P((float, float));
-extern float remquof __P((float, float, int *));
-
-extern float copysignf __P((float, float));
-extern float nanf __P((const char *));
-extern float nextafterf __P((float, float));
-extern float nexttowardf __P((float, long double));
-
-extern float fdimf __P((float, float));
-extern float fmaxf __P((float, float));
-extern float fminf __P((float, float));
-
-extern float fmaf __P((float, float, float));
-
-extern long double acosl __P((long double));
-extern long double asinl __P((long double));
-extern long double atanl __P((long double));
-extern long double atan2l __P((long double, long double));
-extern long double cosl __P((long double));
-extern long double sinl __P((long double));
-extern long double tanl __P((long double));
-
-extern long double acoshl __P((long double));
-extern long double asinhl __P((long double));
-extern long double atanhl __P((long double));
-extern long double coshl __P((long double));
-extern long double sinhl __P((long double));
-extern long double tanhl __P((long double));
-
-extern long double expl __P((long double));
-extern long double exp2l __P((long double));
-extern long double expm1l __P((long double));
-extern long double frexpl __P((long double, int *));
-extern int ilogbl __P((long double));
-extern long double ldexpl __P((long double, int));
-extern long double logl __P((long double));
-extern long double log10l __P((long double));
-extern long double log1pl __P((long double));
-extern long double log2l __P((long double));
-extern long double logbl __P((long double));
-extern long double modfl __P((long double, long double *));
-extern long double scalbnl __P((long double, int));
-extern long double scalblnl __P((long double, long int));
-
-extern long double cbrtl __P((long double));
-extern long double fabsl __P((long double));
-extern long double hypotl __P((long double, long double));
-extern long double powl __P((long double, long double));
-extern long double sqrtl __P((long double));
-
-extern long double erfl __P((long double));
-extern long double erfcl __P((long double));
-extern long double lgammal __P((long double));
-extern long double tgammal __P((long double));
-
-extern long double ceill __P((long double));
-extern long double floorl __P((long double));
-extern long double nearbyintl __P((long double));
-extern long double rintl __P((long double));
-extern long int lrintl __P((long double));
-extern long double roundl __P((long double));
-extern long int lroundl __P((long double));
-extern long double truncl __P((long double));
-
-extern long double fmodl __P((long double, long double));
-extern long double remainderl __P((long double, long double));
-extern long double remquol __P((long double, long double, int *));
-
-extern long double copysignl __P((long double, long double));
-extern long double nanl __P((const char *));
-extern long double nextafterl __P((long double, long double));
-extern long double nexttowardl __P((long double, long double));
-
-extern long double fdiml __P((long double, long double));
-extern long double fmaxl __P((long double, long double));
-extern long double fminl __P((long double, long double));
+extern double acosh(double);
+extern double asinh(double);
+extern double atanh(double);
+
+extern double exp2(double);
+extern double expm1(double);
+extern int ilogb(double);
+extern double log1p(double);
+extern double log2(double);
+extern double logb(double);
+extern double scalbn(double, int);
+extern double scalbln(double, long int);
+
+extern double cbrt(double);
+extern double hypot(double, double);
+
+extern double erf(double);
+extern double erfc(double);
+extern double lgamma(double);
+extern double tgamma(double);
+
+extern double nearbyint(double);
+extern double rint(double);
+extern long int lrint(double);
+extern double round(double);
+extern long int lround(double);
+extern double trunc(double);
+
+extern double remainder(double, double);
+extern double remquo(double, double, int *);
+
+extern double copysign(double, double);
+extern double nan(const char *);
+extern double nextafter(double, double);
+extern double nexttoward(double, long double);
+
+extern double fdim(double, double);
+extern double fmax(double, double);
+extern double fmin(double, double);
+
+extern double fma(double, double, double);
+
+extern float acosf(float);
+extern float asinf(float);
+extern float atanf(float);
+extern float atan2f(float, float);
+extern float cosf(float);
+extern float sinf(float);
+extern float tanf(float);
+
+extern float acoshf(float);
+extern float asinhf(float);
+extern float atanhf(float);
+extern float coshf(float);
+extern float sinhf(float);
+extern float tanhf(float);
+
+extern float expf(float);
+extern float exp2f(float);
+extern float expm1f(float);
+extern float frexpf(float, int *);
+extern int ilogbf(float);
+extern float ldexpf(float, int);
+extern float logf(float);
+extern float log10f(float);
+extern float log1pf(float);
+extern float log2f(float);
+extern float logbf(float);
+extern float modff(float, float *);
+extern float scalbnf(float, int);
+extern float scalblnf(float, long int);
+
+extern float cbrtf(float);
+extern float fabsf(float);
+extern float hypotf(float, float);
+extern float powf(float, float);
+extern float sqrtf(float);
+
+extern float erff(float);
+extern float erfcf(float);
+extern float lgammaf(float);
+extern float tgammaf(float);
+
+extern float ceilf(float);
+extern float floorf(float);
+extern float nearbyintf(float);
+extern float rintf(float);
+extern long int lrintf(float);
+extern float roundf(float);
+extern long int lroundf(float);
+extern float truncf(float);
+
+extern float fmodf(float, float);
+extern float remainderf(float, float);
+extern float remquof(float, float, int *);
+
+extern float copysignf(float, float);
+extern float nanf(const char *);
+extern float nextafterf(float, float);
+extern float nexttowardf(float, long double);
+
+extern float fdimf(float, float);
+extern float fmaxf(float, float);
+extern float fminf(float, float);
+
+extern float fmaf(float, float, float);
+
+extern long double acosl(long double);
+extern long double asinl(long double);
+extern long double atanl(long double);
+extern long double atan2l(long double, long double);
+extern long double cosl(long double);
+extern long double sinl(long double);
+extern long double tanl(long double);
+
+extern long double acoshl(long double);
+extern long double asinhl(long double);
+extern long double atanhl(long double);
+extern long double coshl(long double);
+extern long double sinhl(long double);
+extern long double tanhl(long double);
+
+extern long double expl(long double);
+extern long double exp2l(long double);
+extern long double expm1l(long double);
+extern long double frexpl(long double, int *);
+extern int ilogbl(long double);
+extern long double ldexpl(long double, int);
+extern long double logl(long double);
+extern long double log10l(long double);
+extern long double log1pl(long double);
+extern long double log2l(long double);
+extern long double logbl(long double);
+extern long double modfl(long double, long double *);
+extern long double scalbnl(long double, int);
+extern long double scalblnl(long double, long int);
+
+extern long double cbrtl(long double);
+extern long double fabsl(long double);
+extern long double hypotl(long double, long double);
+extern long double powl(long double, long double);
+extern long double sqrtl(long double);
+
+extern long double erfl(long double);
+extern long double erfcl(long double);
+extern long double lgammal(long double);
+extern long double tgammal(long double);
+
+extern long double ceill(long double);
+extern long double floorl(long double);
+extern long double nearbyintl(long double);
+extern long double rintl(long double);
+extern long int lrintl(long double);
+extern long double roundl(long double);
+extern long int lroundl(long double);
+extern long double truncl(long double);
+
+extern long double fmodl(long double, long double);
+extern long double remainderl(long double, long double);
+extern long double remquol(long double, long double, int *);
+
+extern long double copysignl(long double, long double);
+extern long double nanl(const char *);
+extern long double nextafterl(long double, long double);
+extern long double nexttowardl(long double, long double);
+
+extern long double fdiml(long double, long double);
+extern long double fmaxl(long double, long double);
+extern long double fminl(long double, long double);
 
-extern long double fmal __P((long double, long double, long double));
+extern long double fmal(long double, long double, long double);
 
 #if !defined(_STRICT_STDC) && !defined(_NO_LONGLONG) || defined(_STDC_C99) || \
         defined(__C99FEATURES__)
-extern long long int llrint __P((double));
-extern long long int llround __P((double));
+extern long long int llrint(double);
+extern long long int llround(double);
 
-extern long long int llrintf __P((float));
-extern long long int llroundf __P((float));
+extern long long int llrintf(float);
+extern long long int llroundf(float);
 
-extern long long int llrintl __P((long double));
-extern long long int llroundl __P((long double));
+extern long long int llrintl(long double);
+extern long long int llroundl(long double);
 #endif
 
 #if !defined(__cplusplus)
 #pragma does_not_read_global_data(asinh, exp2, expm1)
 #pragma does_not_read_global_data(ilogb, log2)