1 | #ifndef _MATH_PRIVATE_H_ |
2 | #error "Never use <math_ldbl.h> directly; include <math_private.h> instead." |
3 | #endif |
4 | |
5 | /* A union which permits us to convert between a long double and |
6 | three 32 bit ints. */ |
7 | |
8 | typedef union |
9 | { |
10 | long double value; |
11 | struct |
12 | { |
13 | u_int32_t lsw; |
14 | u_int32_t msw; |
15 | int sign_exponent:16; |
16 | unsigned int empty1:16; |
17 | unsigned int empty0:32; |
18 | } parts; |
19 | } ieee_long_double_shape_type; |
20 | |
21 | /* Get three 32 bit ints from a double. */ |
22 | |
23 | #define GET_LDOUBLE_WORDS(exp,ix0,ix1,d) \ |
24 | do { \ |
25 | ieee_long_double_shape_type ew_u; \ |
26 | ew_u.value = (d); \ |
27 | (exp) = ew_u.parts.sign_exponent; \ |
28 | (ix0) = ew_u.parts.msw; \ |
29 | (ix1) = ew_u.parts.lsw; \ |
30 | } while (0) |
31 | |
32 | /* Set a double from two 32 bit ints. */ |
33 | |
34 | #define SET_LDOUBLE_WORDS(d,exp,ix0,ix1) \ |
35 | do { \ |
36 | ieee_long_double_shape_type iw_u; \ |
37 | iw_u.parts.sign_exponent = (exp); \ |
38 | iw_u.parts.msw = (ix0); \ |
39 | iw_u.parts.lsw = (ix1); \ |
40 | (d) = iw_u.value; \ |
41 | } while (0) |
42 | |
43 | /* Get the more significant 32 bits of a long double mantissa. */ |
44 | |
45 | #define GET_LDOUBLE_MSW(v,d) \ |
46 | do { \ |
47 | ieee_long_double_shape_type sh_u; \ |
48 | sh_u.value = (d); \ |
49 | (v) = sh_u.parts.msw; \ |
50 | } while (0) |
51 | |
52 | /* Set the more significant 32 bits of a long double mantissa from an int. */ |
53 | |
54 | #define SET_LDOUBLE_MSW(d,v) \ |
55 | do { \ |
56 | ieee_long_double_shape_type sh_u; \ |
57 | sh_u.value = (d); \ |
58 | sh_u.parts.msw = (v); \ |
59 | (d) = sh_u.value; \ |
60 | } while (0) |
61 | |
62 | /* Get int from the exponent of a long double. */ |
63 | |
64 | #define GET_LDOUBLE_EXP(exp,d) \ |
65 | do { \ |
66 | ieee_long_double_shape_type ge_u; \ |
67 | ge_u.value = (d); \ |
68 | (exp) = ge_u.parts.sign_exponent; \ |
69 | } while (0) |
70 | |
71 | /* Set exponent of a long double from an int. */ |
72 | |
73 | #define SET_LDOUBLE_EXP(d,exp) \ |
74 | do { \ |
75 | ieee_long_double_shape_type se_u; \ |
76 | se_u.value = (d); \ |
77 | se_u.parts.sign_exponent = (exp); \ |
78 | (d) = se_u.value; \ |
79 | } while (0) |
80 | |