| 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 | |
| 90 | namespace 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 | |