2.9
[glibc/nacl-glibc.git] / sysdeps / ia64 / fpu / math_ldbl.h
blob475ca795fac10f32ec5e1ad007295516d3c05a69
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 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;
23 #endif
25 #if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
27 typedef union
29 long double value;
30 struct
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;
40 #endif
42 /* Get three 32 bit ints from a double. */
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)
53 /* Set a double from two 32 bit ints. */
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)
64 /* Get the more significant 32 bits of a long double mantissa. */
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)
73 /* Set the more significant 32 bits of a long double mantissa from an int. */
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)
83 /* Get int from the exponent of a long double. */
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)
92 /* Set exponent of a long double from an int. */
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)