Back to index

glibc  2.9
math_ldbl.h
Go to the documentation of this file.
00001 #ifndef _MATH_PRIVATE_H_
00002 #error "Never use <math_ldbl.h> directly; include <math_private.h> instead."
00003 #endif
00004 
00005 /* A union which permits us to convert between a long double and
00006    four 32 bit ints or two 64 bit ints.  */
00007 
00008 #if __FLOAT_WORD_ORDER == BIG_ENDIAN
00009 
00010 typedef union
00011 {
00012   long double value;
00013   struct
00014   {
00015     u_int64_t msw;
00016     u_int64_t lsw;
00017   } parts64;
00018   struct
00019   {
00020     u_int32_t w0, w1, w2, w3;
00021   } parts32;
00022 } ieee854_long_double_shape_type;
00023 
00024 #endif
00025 
00026 #if __FLOAT_WORD_ORDER == LITTLE_ENDIAN
00027 
00028 typedef union
00029 {
00030   long double value;
00031   struct
00032   {
00033     u_int64_t lsw;
00034     u_int64_t msw;
00035   } parts64;
00036   struct
00037   {
00038     u_int32_t w3, w2, w1, w0;
00039   } parts32;
00040 } ieee854_long_double_shape_type;
00041 
00042 #endif
00043 
00044 /* Get two 64 bit ints from a long double.  */
00045 
00046 #define GET_LDOUBLE_WORDS64(ix0,ix1,d)                         \
00047 do {                                                    \
00048   ieee854_long_double_shape_type qw_u;                         \
00049   qw_u.value = (d);                                     \
00050   (ix0) = qw_u.parts64.msw;                             \
00051   (ix1) = qw_u.parts64.lsw;                             \
00052 } while (0)
00053 
00054 /* Set a long double from two 64 bit ints.  */
00055 
00056 #define SET_LDOUBLE_WORDS64(d,ix0,ix1)                         \
00057 do {                                                    \
00058   ieee854_long_double_shape_type qw_u;                         \
00059   qw_u.parts64.msw = (ix0);                             \
00060   qw_u.parts64.lsw = (ix1);                             \
00061   (d) = qw_u.value;                                     \
00062 } while (0)
00063 
00064 /* Get the more significant 64 bits of a long double mantissa.  */
00065 
00066 #define GET_LDOUBLE_MSW64(v,d)                                 \
00067 do {                                                    \
00068   ieee854_long_double_shape_type sh_u;                         \
00069   sh_u.value = (d);                                     \
00070   (v) = sh_u.parts64.msw;                               \
00071 } while (0)
00072 
00073 /* Set the more significant 64 bits of a long double mantissa from an int.  */
00074 
00075 #define SET_LDOUBLE_MSW64(d,v)                                 \
00076 do {                                                    \
00077   ieee854_long_double_shape_type sh_u;                         \
00078   sh_u.value = (d);                                     \
00079   sh_u.parts64.msw = (v);                               \
00080   (d) = sh_u.value;                                     \
00081 } while (0)
00082 
00083 /* Get the least significant 64 bits of a long double mantissa.  */
00084 
00085 #define GET_LDOUBLE_LSW64(v,d)                                 \
00086 do {                                                    \
00087   ieee854_long_double_shape_type sh_u;                         \
00088   sh_u.value = (d);                                     \
00089   (v) = sh_u.parts64.lsw;                               \
00090 } while (0)