vfs: check userland buffers before reading them.
[haiku.git] / src / system / libroot / posix / glibc / include / arch / x86 / math_ldbl.h
blobcca30657cefcf4323712e8441e7746e22a3cdf98
1 #ifndef _MATH_PRIVATE_H_
2 #error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
3 #endif
5 /* A union which permits us to convert between a long double and
6 three 32 bit ints. */
8 #if __FLOAT_WORD_ORDER == BIG_ENDIAN
10 typedef union
12 long double value;
13 struct
15 int sign_exponent:16;
16 unsigned int empty:16;
17 u_int32_t msw;
18 u_int32_t lsw;
19 } parts;
20 } ieee_long_double_shape_type;
22 #endif
24 #if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
26 typedef union
28 long double value;
29 struct
31 u_int32_t lsw;
32 u_int32_t msw;
33 int sign_exponent:16;
34 unsigned int empty:16;
35 } parts;
36 } ieee_long_double_shape_type;
38 #endif
40 /* Get three 32 bit ints from a double. */
42 #define GET_LDOUBLE_WORDS(exp,ix0,ix1,d) \
43 do { \
44 ieee_long_double_shape_type ew_u; \
45 ew_u.value = (d); \
46 (exp) = ew_u.parts.sign_exponent; \
47 (ix0) = ew_u.parts.msw; \
48 (ix1) = ew_u.parts.lsw; \
49 } while (0)
51 /* Set a double from two 32 bit ints. */
53 #define SET_LDOUBLE_WORDS(d,exp,ix0,ix1) \
54 do { \
55 ieee_long_double_shape_type iw_u; \
56 iw_u.parts.sign_exponent = (exp); \
57 iw_u.parts.msw = (ix0); \
58 iw_u.parts.lsw = (ix1); \
59 (d) = iw_u.value; \
60 } while (0)
62 /* Get the more significant 32 bits of a long double mantissa. */
64 #define GET_LDOUBLE_MSW(v,d) \
65 do { \
66 ieee_long_double_shape_type sh_u; \
67 sh_u.value = (d); \
68 (v) = sh_u.parts.msw; \
69 } while (0)
71 /* Set the more significant 32 bits of a long double mantissa from an int. */
73 #define SET_LDOUBLE_MSW(d,v) \
74 do { \
75 ieee_long_double_shape_type sh_u; \
76 sh_u.value = (d); \
77 sh_u.parts.msw = (v); \
78 (d) = sh_u.value; \
79 } while (0)
81 /* Get int from the exponent of a long double. */
83 #define GET_LDOUBLE_EXP(exp,d) \
84 do { \
85 ieee_long_double_shape_type ge_u; \
86 ge_u.value = (d); \
87 (exp) = ge_u.parts.sign_exponent; \
88 } while (0)
90 /* Set exponent of a long double from an int. */
92 #define SET_LDOUBLE_EXP(d,exp) \
93 do { \
94 ieee_long_double_shape_type se_u; \
95 se_u.value = (d); \
96 se_u.parts.sign_exponent = (exp); \
97 (d) = se_u.value; \
98 } while (0)