1 #ifndef _MACHINE_IEEE_H_
2 #define _MACHINE_IEEE_H_
3 #include <sys/types.h>
4 #include <sys/cdefs.h>
5 #include <machine/ieeefp.h>
6 #include <float.h>
7 
8 #if LDBL_MANT_DIG == 24
9 #define EXT_IMPLICIT_NBIT
10 #define EXT_TO_ARRAY32(p, a) do {      \
11     (a)[0] = (p)->ext_frac;  \
12 } while (0)
13 #ifdef __IEEE_LITTLE_ENDIAN
14 struct ieee_ext {
15     uint32_t   ext_frac:23;
16     uint32_t   ext_exp:8;
17     uint32_t   ext_sign:1;
18 };
19 #endif
20 #ifdef __IEEE_BIG_ENDIAN
21 struct ieee_ext {
22 #ifndef ___IEEE_BYTES_LITTLE_ENDIAN
23     uint32_t   ext_sign:1;
24     uint32_t   ext_exp:8;
25     uint32_t   ext_frac:23;
26 #else /* ARMEL without __VFP_FP__ */
27     uint32_t   ext_frac:23;
28     uint32_t   ext_exp:8;
29     uint32_t   ext_sign:1;
30 #endif
31 };
32 #endif
33 #elif LDBL_MANT_DIG == 53
34 #define EXT_IMPLICIT_NBIT
35 #define EXT_TO_ARRAY32(p, a) do {       \
36     (a)[0] = (p)->ext_fracl;  \
37     (a)[1] = (p)->ext_frach;  \
38 } while (0)
39 #ifdef __IEEE_LITTLE_ENDIAN
40 struct ieee_ext {
41     uint32_t   ext_fracl;
42     uint32_t   ext_frach:20;
43     uint32_t   ext_exp:11;
44     uint32_t   ext_sign:1;
45 };
46 #endif
47 #ifdef __IEEE_BIG_ENDIAN
48 struct ieee_ext {
49 #ifndef ___IEEE_BYTES_LITTLE_ENDIAN
50     uint32_t   ext_sign:1;
51     uint32_t   ext_exp:11;
52     uint32_t   ext_frach:20;
53 #else /* ARMEL without __VFP_FP__ */
54     uint32_t   ext_frach:20;
55     uint32_t   ext_exp:11;
56     uint32_t   ext_sign:1;
57 #endif
58     uint32_t   ext_fracl;
59 };
60 #endif
61 #elif LDBL_MANT_DIG == 64
62 #define EXT_TO_ARRAY32(p, a) do {       \
63     (a)[0] = (p)->ext_fracl;  \
64     (a)[1] = (p)->ext_frach;  \
65 } while (0)
66 #ifdef __IEEE_LITTLE_ENDIAN /* for Intel CPU */
67 struct ieee_ext {
68     uint32_t   ext_fracl;
69     uint32_t   ext_frach;
70     uint32_t   ext_exp:15;
71     uint32_t   ext_sign:1;
72     uint32_t   ext_padl:16;
73     uint32_t   ext_padh;
74 };
75 #endif
76 #ifdef __IEEE_BIG_ENDIAN
77 struct ieee_ext {
78 #ifndef ___IEEE_BYTES_LITTLE_ENDIAN /* for m68k */
79     uint32_t   ext_sign:1;
80     uint32_t   ext_exp:15;
81     uint32_t   ext_pad:16;
82 #else /* ARM FPA10 math coprocessor */
83     uint32_t   ext_exp:15;
84     uint32_t   ext_pad:16;
85     uint32_t   ext_sign:1;
86 #endif
87     uint32_t   ext_frach;
88     uint32_t   ext_fracl;
89 };
90 #endif
91 #elif LDBL_MANT_DIG == 113
92 #define EXT_IMPLICIT_NBIT
93 #define EXT_TO_ARRAY32(p, a) do {        \
94     (a)[0] = (p)->ext_fracl;   \
95     (a)[1] = (p)->ext_fraclm;  \
96     (a)[2] = (p)->ext_frachm;  \
97     (a)[3] = (p)->ext_frach;   \
98 } while (0)
99 #ifdef __IEEE_LITTLE_ENDIAN
100 struct ieee_ext {
101     uint32_t   ext_fracl;
102     uint32_t   ext_fraclm;
103     uint32_t   ext_frachm;
104     uint32_t   ext_frach:16;
105     uint32_t   ext_exp:15;
106     uint32_t   ext_sign:1;
107 };
108 #endif
109 #ifdef __IEEE_BIG_ENDIAN
110 struct ieee_ext {
111 #ifndef ___IEEE_BYTES_LITTLE_ENDIAN
112     uint32_t   ext_sign:1;
113     uint32_t   ext_exp:15;
114     uint32_t   ext_frach:16;
115 #else /* ARMEL without __VFP_FP__ */
116     uint32_t   ext_frach:16;
117     uint32_t   ext_exp:15;
118     uint32_t   ext_sign:1;
119 #endif
120     uint32_t   ext_frachm;
121     uint32_t   ext_fraclm;
122     uint32_t   ext_fracl;
123 };
124 #endif
125 #endif
126 
127 #endif /* _MACHINE_IEEE_H_ */
128