CMS 3D CMS Logo

math_private.h
Go to the documentation of this file.
1 // abridged from GNU libc 2.6.1 - in detail from
2 // math/math_private.h
3 // sysdeps/ieee754/ldbl-96/math_ldbl.h
4 
5 // part of ths file:
6 /*
7  * ====================================================
8  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
9  *
10  * Developed at SunPro, a Sun Microsystems, Inc. business.
11  * Permission to use, copy, modify, and distribute this
12  * software is freely granted, provided that this notice
13  * is preserved.
14  * ====================================================
15  */
16 
17 #ifndef math_private_h
18 #define math_private_h
19 
20 #include <sys/types.h>
21 
22 namespace edm {
23  namespace math_private {
24 
25  // A union which permits us to convert between a float and a 32 bit int.
26  typedef union
27  {
28  float value;
29  u_int32_t word;
31 
32  // A union which permits us to convert between a double and two 32 bit ints.
33  typedef union
34  {
35  double value;
36  struct
37  {
38  u_int32_t lsw;
39  u_int32_t msw;
40  } parts;
42 
43  // A union which permits us to convert between a long double and three 32 bit ints.
44  typedef union
45  {
46  long double value;
47  struct
48  {
49  u_int32_t lsw;
50  u_int32_t msw;
51  int sign_exponent:16;
52  unsigned int empty:16;
53  // unsigned int empty1:32; // maybe needed for 128-bit long double ? (x86-64 and/or -m128bit-long-double)
54  } parts;
56 
57  /* Get a 32 bit int from a float. */
58  #define GET_FLOAT_WORD(i,d) \
59  do { \
60  edm::math_private::ieee_float_shape_type gf_u; \
61  gf_u.value = (d); \
62  (i) = gf_u.word; \
63  } while (0)
64 
65  /* Get two 32 bit ints from a double. */
66  #define EXTRACT_WORDS(ix0,ix1,d) \
67  do { \
68  edm::math_private::ieee_double_shape_type ew_u; \
69  ew_u.value = (d); \
70  (ix0) = ew_u.parts.msw; \
71  (ix1) = ew_u.parts.lsw; \
72  } while (0)
73 
74  /* Get three 32 bit ints from a long double. */
75  #define GET_LDOUBLE_WORDS(exp,ix0,ix1,d) \
76  do { \
77  edm::math_private::ieee_long_double_shape_type ew_u; \
78  ew_u.value = (d); \
79  (exp) = ew_u.parts.sign_exponent; \
80  (ix0) = ew_u.parts.msw; \
81  (ix1) = ew_u.parts.lsw; \
82  } while (0)
83 
84  } // namespace math_private
85 } // namespace edm
86 
87 #endif // math_private_h
HLT enums.