]>
Commit | Line | Data |
---|---|---|
d5efd131 MF |
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 | #if __FLOAT_WORD_ORDER == BIG_ENDIAN | |
9 | ||
10 | typedef union | |
11 | { | |
12 | long double value; | |
13 | struct | |
14 | { | |
15 | unsigned int empty0:32; | |
16 | int sign_exponent:16; | |
17 | unsigned int empty1:16; | |
18 | u_int32_t msw; | |
19 | u_int32_t lsw; | |
20 | } parts; | |
21 | } ieee_long_double_shape_type; | |
22 | ||
23 | #endif | |
24 | ||
25 | #if __FLOAT_WORD_ORDER == LITTLE_ENDIAN | |
26 | ||
27 | typedef union | |
28 | { | |
29 | long double value; | |
30 | struct | |
31 | { | |
32 | u_int32_t lsw; | |
33 | u_int32_t msw; | |
34 | int sign_exponent:16; | |
35 | unsigned int empty1:16; | |
36 | unsigned int empty0:32; | |
37 | } parts; | |
38 | } ieee_long_double_shape_type; | |
39 | ||
40 | #endif | |
41 | ||
42 | /* Get three 32 bit ints from a double. */ | |
43 | ||
44 | #define GET_LDOUBLE_WORDS(exp,ix0,ix1,d) \ | |
45 | do { \ | |
46 | ieee_long_double_shape_type ew_u; \ | |
47 | ew_u.value = (d); \ | |
48 | (exp) = ew_u.parts.sign_exponent; \ | |
49 | (ix0) = ew_u.parts.msw; \ | |
50 | (ix1) = ew_u.parts.lsw; \ | |
51 | } while (0) | |
52 | ||
53 | /* Set a double from two 32 bit ints. */ | |
54 | ||
55 | #define SET_LDOUBLE_WORDS(d,exp,ix0,ix1) \ | |
56 | do { \ | |
57 | ieee_long_double_shape_type iw_u; \ | |
58 | iw_u.parts.sign_exponent = (exp); \ | |
59 | iw_u.parts.msw = (ix0); \ | |
60 | iw_u.parts.lsw = (ix1); \ | |
61 | (d) = iw_u.value; \ | |
62 | } while (0) | |
63 | ||
64 | /* Get the more significant 32 bits of a long double mantissa. */ | |
65 | ||
66 | #define GET_LDOUBLE_MSW(v,d) \ | |
67 | do { \ | |
68 | ieee_long_double_shape_type sh_u; \ | |
69 | sh_u.value = (d); \ | |
70 | (v) = sh_u.parts.msw; \ | |
71 | } while (0) | |
72 | ||
73 | /* Set the more significant 32 bits of a long double mantissa from an int. */ | |
74 | ||
75 | #define SET_LDOUBLE_MSW(d,v) \ | |
76 | do { \ | |
77 | ieee_long_double_shape_type sh_u; \ | |
78 | sh_u.value = (d); \ | |
79 | sh_u.parts.msw = (v); \ | |
80 | (d) = sh_u.value; \ | |
81 | } while (0) | |
82 | ||
83 | /* Get int from the exponent of a long double. */ | |
84 | ||
85 | #define GET_LDOUBLE_EXP(exp,d) \ | |
86 | do { \ | |
87 | ieee_long_double_shape_type ge_u; \ | |
88 | ge_u.value = (d); \ | |
89 | (exp) = ge_u.parts.sign_exponent; \ | |
90 | } while (0) | |
91 | ||
92 | /* Set exponent of a long double from an int. */ | |
93 | ||
94 | #define SET_LDOUBLE_EXP(d,exp) \ | |
95 | do { \ | |
96 | ieee_long_double_shape_type se_u; \ | |
97 | se_u.value = (d); \ | |
98 | se_u.parts.sign_exponent = (exp); \ | |
99 | (d) = se_u.value; \ | |
100 | } while (0) |