Ticket #7007: 0001Addmissingdefinitionstomath.h.patch
File 0001Addmissingdefinitionstomath.h.patch, 3.1 KB (added by , 7 years ago) 


headers/posix/math.h
From e12a29d2f51aaae5976d601e2152a8096667c136 Mon Sep 17 00:00:00 2001 From: Sam Toyer <sam@qxcv.net> Date: Sat, 1 Dec 2012 19:18:57 +1000 Subject: [PATCH 1/5] Add missing definitions to math.h  headers/posix/math.h  71 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff git a/headers/posix/math.h b/headers/posix/math.h index df34b25..d094d0e 100644
a b 5 5 #ifndef _MATH_H_ 6 6 #define _MATH_H_ 7 7 8 /* (floatdouble)_t typedefs */ 9 10 #ifdef __FLT_EVAL_METHOD__ 11 #define FLT_EVAL_METHOD __FLT_EVAL_METHOD__ 12 #else 13 #define FLT_EVAL_METHOD 0 14 #endif 15 16 #if FLT_EVAL_METHOD == 1 17 typedef double float_t; 18 typedef double double_t; 19 #elif FLT_EVAL_METHOD == 2 20 typedef long double float_t; 21 typedef long double double_t; 22 #else 23 typedef float float_t; 24 typedef double double_t; 25 #endif 8 26 9 27 #define M_E 2.7182818284590452354 /* e */ 10 28 #define M_LOG2E 1.4426950408889634074 /* log 2e */ … … 50 68 # define INFINITY HUGE_VALF 51 69 #endif 52 70 71 #include <limits.h> 72 #define MAXFLOAT FLT_MAX 73 53 74 /* floatingpoint categories */ 54 75 #define FP_NAN 0 55 76 #define FP_INFINITE 1 … … 57 78 #define FP_SUBNORMAL 3 58 79 #define FP_NORMAL 4 59 80 81 #ifdef __FP_FAST_FMA 82 #define FP_FAST_FMA __FP_FAST_FMA 83 #else 84 #define FP_FAST_FMA 0 85 #endif 86 #ifdef __FP_FAST_FMAF 87 #define FP_FAST_FMAF __FP_FAST_FMAF 88 #else 89 #define FP_FAST_FMAF 0 90 #endif 91 #ifdef __FP_FAST_FMAL 92 #define FP_FAST_FMAL __FP_FAST_FMAL 93 #else 94 #define FP_FAST_FMAL 0 95 #endif 96 97 #define FP_ILOGB0 INT_MAX 98 #define FP_ILOGBNAN INT_MAX 99 60 100 #ifdef __cplusplus 61 101 struct __exception; 62 102 extern "C" int matherr(struct __exception *); … … struct exception { 73 113 double retval; 74 114 }; 75 115 116 #define MATH_ERRNO 1 117 #define MATH_ERREXCEPT 2 118 #define math_errhandling 0 119 76 120 #define DOMAIN 1 77 121 #define SING 2 78 122 #define OVERFLOW 3 … … extern int __isinf(double value); 348 392 : sizeof(value) == sizeof(double) ? __isinf(value) \ 349 393 : __isinfl(value)) 350 394 395 #if __GNUC__ >= 4 396 #define isgreater(x, y) __builtin_isgreater((x), (y)) 397 #define isgreaterequal(x, y) __builtin_isgreaterequal((x), (y)) 398 #define isless(x, y) __builtin_isless((x), (y)) 399 #define islessequal(x, y) __builtin_islessequal((x), (y)) 400 #define islessgreater(x, y) __builtin_islessgreater((x), (y)) 401 #define isunordered(x, y) __builtin_isunordered((x), (y)) 402 #else 403 /* these are only for GCC2, and require GNUC statement expressions */ 404 #define _wrap_expr_typeof(x, y, body) ({ \ 405 __typeof(x) X = (x); \ 406 __typeof(y) Y = (y); \ 407 body;}) 408 #define isgreater(x, y) \ 409 _wrap_expr_typeof(x, y, !isnan(X) && !isnan(Y) && X > Y) 410 #define isgreaterequal(x, y) \ 411 _wrap_expr_typeof(x, y, !isnan(X) && !isnan(Y) && X >= Y) 412 #define isless(x, y) \ 413 _wrap_expr_typeof(x, y, !isnan(X) && !isnan(Y) && X < Y) 414 #define islessequal(x, y) \ 415 _wrap_expr_typeof(x, y, !isnan(X) && !isnan(Y) && X <= Y) 416 #define islessgreater(x, y) \ 417 _wrap_expr_typeof(x, y, X < Y  Y < X) 418 #define isunordered(x, y) \ 419 _wrap_expr_typeof(x, y, isnan(X)  isnan(Y)) 420 #endif 421 351 422 #ifdef __cplusplus 352 423 } 353 424 #endif