1 /*****************************************************************************/ 2 /*****************************************************************************/ 3 // portions extracted from musl-0.9.15 libm.h 4 /*****************************************************************************/ 5 /*****************************************************************************/ 6 7 /* origin: FreeBSD /usr/src/lib/msun/src/math_private.h */ 8 /* 9 * ==================================================== 10 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 11 * 12 * Developed at SunPro, a Sun Microsystems, Inc. business. 13 * Permission to use, copy, modify, and distribute this 14 * software is freely granted, provided that this notice 15 * is preserved. 16 * ==================================================== 17 */ 18 19 #include <stdint.h> 20 #include <math.h> 21 22 #define FLT_EVAL_METHOD 0 23 24 #define FORCE_EVAL(x) do { \ 25 if (sizeof(x) == sizeof(float)) { \ 26 volatile float __x; \ 27 __x = (x); \ 28 (void)__x; \ 29 } else if (sizeof(x) == sizeof(double)) { \ 30 volatile double __x; \ 31 __x = (x); \ 32 (void)__x; \ 33 } else { \ 34 volatile long double __x; \ 35 __x = (x); \ 36 (void)__x; \ 37 } \ 38 } while(0) 39 40 /* Get a 32 bit int from a float. */ 41 #define GET_FLOAT_WORD(w,d) \ 42 do { \ 43 union {float f; uint32_t i;} __u; \ 44 __u.f = (d); \ 45 (w) = __u.i; \ 46 } while (0) 47 48 /* Set a float from a 32 bit int. */ 49 #define SET_FLOAT_WORD(d,w) \ 50 do { \ 51 union {float f; uint32_t i;} __u; \ 52 __u.i = (w); \ 53 (d) = __u.f; \ 54 } while (0) 55