beifg: Simplify the implementation of be_ifg_foreach_node().
[libfirm] / win32 / ieee754.h
1 /* Copyright (C) 1992, 1995, 1996, 1999 Free Software Foundation, Inc.
2    This file is part of the GNU C Library.
3
4    The GNU C Library is free software; you can redistribute it and/or
5    modify it under the terms of the GNU Lesser General Public
6    License as published by the Free Software Foundation; either
7    version 2.1 of the License, or (at your option) any later version.
8
9    The GNU C Library is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12    Lesser General Public License for more details.
13
14    You should have received a copy of the GNU Lesser General Public
15    License along with the GNU C Library; if not, write to the Free
16    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17    02111-1307 USA.  */
18
19 #ifndef __IEEE754_H
20 #define __IEEE754_H 1
21
22 #ifdef _MSC_VER
23 #define LITTLE_ENDIAN 0x76543210
24 #define BIG_ENDIAN    0x01234567
25 #define __FLOAT_WORD_ORDER LITTLE_ENDIAN
26 #endif
27
28 union ieee754_float
29   {
30     float f;
31
32     /* This is the IEEE 754 single-precision format.  */
33     struct
34       {
35 #ifdef WORDS_BIGENDIAN
36         unsigned int negative:1;
37         unsigned int exponent:8;
38         unsigned int mantissa:23;
39 #else
40         unsigned int mantissa:23;
41         unsigned int exponent:8;
42         unsigned int negative:1;
43 #endif              /* Little endian.  */
44       } ieee;
45
46     /* This format makes it easier to see if a NaN is a signalling NaN.  */
47     struct
48       {
49 #ifdef WORDS_BIGENDIAN
50         unsigned int negative:1;
51         unsigned int exponent:8;
52         unsigned int quiet_nan:1;
53         unsigned int mantissa:22;
54 #else
55         unsigned int mantissa:22;
56         unsigned int quiet_nan:1;
57         unsigned int exponent:8;
58         unsigned int negative:1;
59 #endif             /* Little endian.  */
60       } ieee_nan;
61   };
62
63 #define IEEE754_FLOAT_BIAS 0x7f /* Added to exponent.  */
64
65
66 union ieee754_double
67   {
68     double d;
69
70     /* This is the IEEE 754 double-precision format.  */
71     struct
72       {
73 #ifdef WORDS_BIGENDIAN
74         unsigned int negative:1;
75         unsigned int exponent:11;
76         /* Together these comprise the mantissa.  */
77         unsigned int mantissa0:20;
78         unsigned int mantissa1:32;
79 #else
80 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
81         unsigned int mantissa0:20;
82         unsigned int exponent:11;
83         unsigned int negative:1;
84         unsigned int mantissa1:32;
85 # else
86         /* Together these comprise the mantissa.  */
87         unsigned int mantissa1:32;
88         unsigned int mantissa0:20;
89         unsigned int exponent:11;
90         unsigned int negative:1;
91 # endif
92 #endif              /* Little endian.  */
93       } ieee;
94
95     /* This format makes it easier to see if a NaN is a signalling NaN.  */
96     struct
97       {
98 #ifdef WORDS_BIGENDIAN
99         unsigned int negative:1;
100         unsigned int exponent:11;
101         unsigned int quiet_nan:1;
102         /* Together these comprise the mantissa.  */
103         unsigned int mantissa0:19;
104         unsigned int mantissa1:32;
105 #else
106 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
107         unsigned int mantissa0:19;
108         unsigned int quiet_nan:1;
109         unsigned int exponent:11;
110         unsigned int negative:1;
111         unsigned int mantissa1:32;
112 # else
113         /* Together these comprise the mantissa.  */
114         unsigned int mantissa1:32;
115         unsigned int mantissa0:19;
116         unsigned int quiet_nan:1;
117         unsigned int exponent:11;
118         unsigned int negative:1;
119 # endif
120 #endif
121       } ieee_nan;
122   };
123
124 #define IEEE754_DOUBLE_BIAS 0x3ff /* Added to exponent.  */
125
126
127 union ieee854_long_double
128   {
129     long double d;
130
131     /* This is the IEEE 854 double-extended-precision format.  */
132     struct
133       {
134 #ifdef WORDS_BIGENDIAN
135         unsigned int negative:1;
136         unsigned int exponent:15;
137         unsigned int empty:16;
138         unsigned int mantissa0:32;
139         unsigned int mantissa1:32;
140 #else
141 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
142         unsigned int exponent:15;
143         unsigned int negative:1;
144         unsigned int empty:16;
145         unsigned int mantissa0:32;
146         unsigned int mantissa1:32;
147 # else
148         unsigned int mantissa1:32;
149         unsigned int mantissa0:32;
150         unsigned int exponent:15;
151         unsigned int negative:1;
152         unsigned int empty:16;
153 # endif
154 #endif
155       } ieee;
156
157     /* This is for NaNs in the IEEE 854 double-extended-precision format.  */
158     struct
159       {
160 #ifdef WORDS_BIGENDIAN
161         unsigned int negative:1;
162         unsigned int exponent:15;
163         unsigned int empty:16;
164         unsigned int one:1;
165         unsigned int quiet_nan:1;
166         unsigned int mantissa0:30;
167         unsigned int mantissa1:32;
168 #else
169 # if __FLOAT_WORD_ORDER == BIG_ENDIAN
170         unsigned int exponent:15;
171         unsigned int negative:1;
172         unsigned int empty:16;
173         unsigned int mantissa0:30;
174         unsigned int quiet_nan:1;
175         unsigned int one:1;
176         unsigned int mantissa1:32;
177 # else
178         unsigned int mantissa1:32;
179         unsigned int mantissa0:30;
180         unsigned int quiet_nan:1;
181         unsigned int one:1;
182         unsigned int exponent:15;
183         unsigned int negative:1;
184         unsigned int empty:16;
185 # endif
186 #endif
187       } ieee_nan;
188   };
189
190 #define IEEE854_LONG_DOUBLE_BIAS 0x3fff
191
192 #ifdef _MSC_VER
193 #undef LITTLE_ENDIAN
194 #undef BIG_ENDIAN
195 #undef __FLOAT_WORD_ORDER
196 #endif
197
198 #endif /* ieee754.h */