Update contrib.
2 * Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
31 #include <libc/machine/ieeefp.h>
33 /* FIX THIS FIX THIS FIX THIS:
34 Neither of __ieee_{float,double}_shape_tape seem to be used anywhere
35 except in libm/test. If that is the case, please delete these from here.
36 If that is not the case, please insert documentation here describing why
39 #ifdef __IEEE_BIG_ENDIAN
46 unsigned int sign : 1;
47 unsigned int exponent: 11;
48 unsigned int fraction0:4;
49 unsigned int fraction1:16;
50 unsigned int fraction2:16;
51 unsigned int fraction3:16;
56 unsigned int sign : 1;
57 unsigned int exponent: 11;
59 unsigned int function0:3;
60 unsigned int function1:16;
61 unsigned int function2:16;
62 unsigned int function3:16;
70 } __ieee_double_shape_type;
74 #ifdef __IEEE_LITTLE_ENDIAN
81 #ifdef __SMALL_BITFIELDS
82 unsigned int fraction3:16;
83 unsigned int fraction2:16;
84 unsigned int fraction1:16;
85 unsigned int fraction0: 4;
87 unsigned int fraction1:32;
88 unsigned int fraction0:20;
90 unsigned int exponent :11;
91 unsigned int sign : 1;
95 #ifdef __SMALL_BITFIELDS
96 unsigned int function3:16;
97 unsigned int function2:16;
98 unsigned int function1:16;
99 unsigned int function0:3;
101 unsigned int function1:32;
102 unsigned int function0:19;
104 unsigned int quiet:1;
105 unsigned int exponent: 11;
106 unsigned int sign : 1;
116 } __ieee_double_shape_type;
120 #ifdef __IEEE_BIG_ENDIAN
127 unsigned int sign : 1;
128 unsigned int exponent: 8;
129 unsigned int fraction0: 7;
130 unsigned int fraction1: 16;
135 unsigned int exponent:8;
136 unsigned int quiet:1;
137 unsigned int function0:6;
138 unsigned int function1:16;
142 } __ieee_float_shape_type;
146 #ifdef __IEEE_LITTLE_ENDIAN
153 unsigned int fraction0: 7;
154 unsigned int fraction1: 16;
155 unsigned int exponent: 8;
156 unsigned int sign : 1;
160 unsigned int function1:16;
161 unsigned int function0:6;
162 unsigned int quiet:1;
163 unsigned int exponent:8;
168 } __ieee_float_shape_type;
178 #define FP_RN 0 /* Round to nearest */
179 #define FP_RM 1 /* Round down */
180 #define FP_RP 2 /* Round up */
181 #define FP_RZ 3 /* Round to zero (trunate) */
183 fp_rnd fpgetround(void);
184 fp_rnd fpsetround(fp_rnd);
189 typedef int fp_except;
191 #define FP_X_INV 0x10 /* Invalid operation */
192 #define FP_X_DX 0x80 /* Divide by zero */
193 #define FP_X_OFL 0x04 /* Overflow exception */
194 #define FP_X_UFL 0x02 /* Underflow exception */
195 #define FP_X_IMP 0x01 /* imprecise exception */
197 fp_except fpgetmask(void);
198 fp_except fpsetmask(fp_except);
199 fp_except fpgetsticky(void);
200 fp_except fpsetsticky(fp_except);
206 #define FP_RDI_TOZ 0 /* Round to Zero */
207 #define FP_RDI_RD 1 /* Follow float mode */
209 fp_rdi fpgetroundtoi(void);
210 fp_rdi fpsetroundtoi(fp_rdi);
220 #define __IEEE_DBL_EXPBIAS 1023
221 #define __IEEE_FLT_EXPBIAS 127
222 #define __IEEE_DBL_EXPLEN 11
223 #define __IEEE_FLT_EXPLEN 8
224 #define __IEEE_DBL_FRACLEN (64 - (__IEEE_DBL_EXPLEN + 1))
225 #define __IEEE_FLT_FRACLEN (32 - (__IEEE_FLT_EXPLEN + 1))
226 #define __IEEE_DBL_MAXPOWTWO ((double)(1L << 32 - 2) * (1L << (32-11) - 32 + 1))
227 #define __IEEE_FLT_MAXPOWTWO ((float)(1L << (32-8) - 1))
228 #define __IEEE_DBL_NAN_EXP 0x7ff
229 #define __IEEE_FLT_NAN_EXP 0xff
231 #define isnanf(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
232 ((*(long *)&(x) & 0x007fffffL)!=0000000000L))
233 #define isinff(x) (((*(long *)&(x) & 0x7f800000L)==0x7f800000L) && \
234 ((*(long *)&(x) & 0x007fffffL)==0000000000L))
235 #define finitef(x) (((*(long *)&(x) & 0x7f800000L)!=0x7f800000L))
237 #endif /* _IEEE_FP_H_ */