Ticket #7396: fix_stdisnan.patch

File fix_stdisnan.patch, 5.3 KB (added by pulkomandy, 9 years ago)

Patch adding missing functions to cmath.

  • headers/cpp/cmath

    diff --git a/headers/cpp/cmath b/headers/cpp/cmath
    index b18ea0b..6ba8438 100644
    a b inline long double abs (long double x) { return fabs (x); }  
    7373
    7474} // extern "C++"
    7575
     76// These are possible macros imported from C99-land.
     77#undef fpclassify
     78#undef isfinite
     79#undef isinf
     80#undef isnan
     81#undef isnormal
     82#undef signbit
     83#undef isgreater
     84#undef isgreaterequal
     85#undef isless
     86#undef islessequal
     87#undef islessgreater
     88#undef isunordered
     89
     90namespace std
     91{
     92  inline int fpclassify(float __x) { return __fpclassifyf(__x); }
     93  inline int fpclassify(double __x) { return __fpclassify(__x); }
     94  inline int fpclassify(long double __x) { return __fpclassifyl(__x); }
     95
     96  inline bool isfinite(float __x) { return __finitef(__x); }
     97  inline bool isfinite(double __x) { return __finite(__x); }
     98  inline bool isfinite(long double __x) { return __finitel(__x); }
     99
     100  inline bool isinf(float __x) { return __isinff(__x); }
     101  inline bool isinf(double __x) { return __isinf(__x); }
     102  inline bool isinf(long double __x) { return __isinfl(__x); }
     103
     104  inline bool isnan(float __x) { return __isnanf(__x); }
     105  inline bool isnan(double __x) { return __isnan(__x); }
     106  inline bool isnan(long double __x) { return __isnanl(__x); }
     107
     108  inline bool isnormal(float __x) { return __fpclassifyf(__x) == FP_NORMAL; }
     109  inline bool isnormal(double __x) { return __fpclassify(__x) == FP_NORMAL; }
     110  inline bool isnormal(long double __x) { return __fpclassifyl(__x) == FP_NORMAL; }
     111
     112  inline bool signbit(float __x) { return __signbitf(__x); }
     113  inline bool signbit(double __x) { return __signbit(__x); }
     114  inline bool signbit(long double __x) { return __signbitl(__x); }
     115
     116#undef _wrap_expr_typeof
     117    #define _wrap_expr_typeof(x, y, body) ({    \
     118        __typeof(x) X = (x);                    \
     119        __typeof(y) Y = (y);                    \
     120        return (body);})
     121
     122  inline bool isgreater(float __x, float __y) {
     123    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X > Y);
     124  };
     125  inline bool isgreater(double __x, double __y) {
     126    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X > Y);
     127  };
     128  inline bool isgreater(long double __x, long double __y) {
     129    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X > Y);
     130  };
     131
     132  inline bool isgreaterequal(float __x, float __y) {
     133    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X >= Y);
     134  };
     135  inline bool isgreaterequal(double __x, double __y) {
     136    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X >= Y);
     137  };
     138  inline bool isgreaterequal(long double __x, long double __y) {
     139    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X >= Y);
     140  };
     141
     142  inline bool isless(float __x, float __y) {
     143    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X < Y);
     144  };
     145  inline bool isless(double __x, double __y) {
     146    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X < Y);
     147  };
     148  inline bool isless(long double __x, long double __y) {
     149    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X < Y);
     150  };
     151
     152  inline bool islessequal(float __x, float __y) {
     153    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X <= Y);
     154  };
     155  inline bool islessequal(double __x, double __y) {
     156    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X <= Y);
     157  };
     158  inline bool islessequal(long double __x, long double __y) {
     159    _wrap_expr_typeof(__x, __y, !isnan(X) && !isnan(Y) && X <= Y);
     160  };
     161
     162  inline bool islessgeater(float __x, float __y) {
     163    _wrap_expr_typeof(__x, __y, X < Y || Y < X);
     164  };
     165  inline bool islessgreater(double __x, double __y) {
     166    _wrap_expr_typeof(__x, __y, X < Y || Y < X);
     167  };
     168  inline bool islessgreater(long double __x, long double __y) {
     169    _wrap_expr_typeof(__x, __y, X < Y || Y < X);
     170  };
     171
     172  inline bool isunordered(float __x, float __y) {
     173    _wrap_expr_typeof(__x, __y, isnan(X) || isnan(Y));
     174  };
     175  inline bool isunordered(double __x, double __y) {
     176    _wrap_expr_typeof(__x, __y, isnan(X) || isnan(Y));
     177  };
     178  inline bool isunordered(long double __x, long double __y) {
     179    _wrap_expr_typeof(__x, __y, isnan(X) || isnan(Y));
     180  };
     181
     182#undef _wrap_expr_typeof
     183
     184} // namespace
     185
    76186#endif
  • src/system/libroot/posix/glibc/math/bits/mathcalls.h

    diff --git a/src/system/libroot/posix/glibc/math/bits/mathcalls.h b/src/system/libroot/posix/glibc/math/bits/mathcalls.h
    index c1181f7..a5773cd 100644
    a b __MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));  
    179179__MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
    180180
    181181#ifdef __USE_MISC
     182
     183#ifndef __cplusplus
    182184/* Return 0 if VALUE is finite or NaN, +1 if it
    183185   is +Infinity, -1 if it is -Infinity.  */
    184186__MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
     187#endif
    185188
    186189/* Return nonzero if VALUE is finite and not NaN.  */
    187190__MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
    __MATHCALLX (nan,, (__const char *__tagb), (__const__));  
    209212__MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
    210213
    211214#if defined __USE_MISC || defined __USE_XOPEN
     215
     216#ifndef __cplusplus
    212217/* Return nonzero if VALUE is not a number.  */
    213218__MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
     219#endif
    214220
    215221/* Bessel functions.  */
    216222__MATHCALL (j0,, (_Mdouble_));