2.9
[glibc/nacl-glibc.git] / sysdeps / ieee754 / ldbl-128 / math_ldbl.h
blobb3faa0484674e22cbc84a8195def6ee37621cfd5
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 four 32 bit ints or two 64 bit ints. */
8 #if __FLOAT_WORD_ORDER == BIG_ENDIAN
10 typedef union
12 long double value;
13 struct
15 u_int64_t msw;
16 u_int64_t lsw;
17 } parts64;
18 struct
20 u_int32_t w0, w1, w2, w3;
21 } parts32;
22 } ieee854_long_double_shape_type;
24 #endif
26 #if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
28 typedef union
30 long double value;
31 struct
33 u_int64_t lsw;
34 u_int64_t msw;
35 } parts64;
36 struct
38 u_int32_t w3, w2, w1, w0;
39 } parts32;
40 } ieee854_long_double_shape_type;
42 #endif
44 /* Get two 64 bit ints from a long double. */
46 #define GET_LDOUBLE_WORDS64(ix0,ix1,d) \
47 do { \
48 ieee854_long_double_shape_type qw_u; \
49 qw_u.value = (d); \
50 (ix0) = qw_u.parts64.msw; \
51 (ix1) = qw_u.parts64.lsw; \
52 } while (0)
54 /* Set a long double from two 64 bit ints. */
56 #define SET_LDOUBLE_WORDS64(d,ix0,ix1) \
57 do { \
58 ieee854_long_double_shape_type qw_u; \
59 qw_u.parts64.msw = (ix0); \
60 qw_u.parts64.lsw = (ix1); \
61 (d) = qw_u.value; \
62 } while (0)
64 /* Get the more significant 64 bits of a long double mantissa. */
66 #define GET_LDOUBLE_MSW64(v,d) \
67 do { \
68 ieee854_long_double_shape_type sh_u; \
69 sh_u.value = (d); \
70 (v) = sh_u.parts64.msw; \
71 } while (0)
73 /* Set the more significant 64 bits of a long double mantissa from an int. */
75 #define SET_LDOUBLE_MSW64(d,v) \
76 do { \
77 ieee854_long_double_shape_type sh_u; \
78 sh_u.value = (d); \
79 sh_u.parts64.msw = (v); \
80 (d) = sh_u.value; \
81 } while (0)
83 /* Get the least significant 64 bits of a long double mantissa. */
85 #define GET_LDOUBLE_LSW64(v,d) \
86 do { \
87 ieee854_long_double_shape_type sh_u; \
88 sh_u.value = (d); \
89 (v) = sh_u.parts64.lsw; \
90 } while (0)