1 /* Native implementation of soft float functions */
3 #if defined(_BSD) && !defined(__APPLE__)
10 typedef double float64;
12 typedef long double floatx80;
33 /*----------------------------------------------------------------------------
34 | Software IEC/IEEE floating-point rounding mode.
35 *----------------------------------------------------------------------------*/
36 #if defined(_BSD) && !defined(__APPLE__)
38 float_round_nearest_even = FP_RN,
39 float_round_down = FE_RM,
40 float_round_up = FE_RP,
41 float_round_to_zero = FE_RZ
43 #elif defined(__arm__)
45 float_round_nearest_even = 0,
48 float_round_to_zero = 3
52 float_round_nearest_even = FE_TONEAREST,
53 float_round_down = FE_DOWNWARD,
54 float_round_up = FE_UPWARD,
55 float_round_to_zero = FE_TOWARDZERO
59 typedef struct float_status {
60 signed char float_rounding_mode;
62 signed char floatx80_rounding_precision;
66 void set_float_rounding_mode(int val STATUS_PARAM);
68 void set_floatx80_rounding_precision(int val STATUS_PARAM);
71 /*----------------------------------------------------------------------------
72 | Software IEC/IEEE integer-to-floating-point conversion routines.
73 *----------------------------------------------------------------------------*/
74 float32 int32_to_float32( int STATUS_PARAM);
75 float64 int32_to_float64( int STATUS_PARAM);
77 floatx80 int32_to_floatx80( int STATUS_PARAM);
80 float128 int32_to_float128( int STATUS_PARAM);
82 float32 int64_to_float32( int64_t STATUS_PARAM);
83 float64 int64_to_float64( int64_t STATUS_PARAM);
85 floatx80 int64_to_floatx80( int64_t STATUS_PARAM);
88 float128 int64_to_float128( int64_t STATUS_PARAM);
91 /*----------------------------------------------------------------------------
92 | Software IEC/IEEE single-precision conversion routines.
93 *----------------------------------------------------------------------------*/
94 int float32_to_int32( float32 STATUS_PARAM);
95 int float32_to_int32_round_to_zero( float32 STATUS_PARAM);
96 int64_t float32_to_int64( float32 STATUS_PARAM);
97 int64_t float32_to_int64_round_to_zero( float32 STATUS_PARAM);
98 float64 float32_to_float64( float32 STATUS_PARAM);
100 floatx80 float32_to_floatx80( float32 STATUS_PARAM);
103 float128 float32_to_float128( float32 STATUS_PARAM);
106 /*----------------------------------------------------------------------------
107 | Software IEC/IEEE single-precision operations.
108 *----------------------------------------------------------------------------*/
109 float32 float32_round_to_int( float32 STATUS_PARAM);
110 INLINE float32 float32_add( float32 a, float32 b STATUS_PARAM)
114 INLINE float32 float32_sub( float32 a, float32 b STATUS_PARAM)
118 INLINE float32 float32_mul( float32 a, float32 b STATUS_PARAM)
122 INLINE float32 float32_div( float32 a, float32 b STATUS_PARAM)
126 float32 float32_rem( float32, float32 STATUS_PARAM);
127 float32 float32_sqrt( float32 STATUS_PARAM);
128 INLINE char float32_eq( float32 a, float32 b STATUS_PARAM)
132 INLINE char float32_le( float32 a, float32 b STATUS_PARAM)
136 INLINE char float32_lt( float32 a, float32 b STATUS_PARAM)
140 INLINE char float32_eq_signaling( float32 a, float32 b STATUS_PARAM)
142 return a <= b && a >= b;
144 INLINE char float32_le_quiet( float32 a, float32 b STATUS_PARAM)
146 return islessequal(a, b);
148 INLINE char float32_lt_quiet( float32 a, float32 b STATUS_PARAM)
152 INLINE char float32_unordered( float32 a, float32 b STATUS_PARAM)
154 return isunordered(a, b);
157 char float32_compare( float32, float32 STATUS_PARAM );
158 char float32_compare_quiet( float32, float32 STATUS_PARAM );
159 char float32_is_signaling_nan( float32 );
161 INLINE float32 float32_abs(float32 a)
166 INLINE float32 float32_chs(float32 a)
171 /*----------------------------------------------------------------------------
172 | Software IEC/IEEE double-precision conversion routines.
173 *----------------------------------------------------------------------------*/
174 int float64_to_int32( float64 STATUS_PARAM );
175 int float64_to_int32_round_to_zero( float64 STATUS_PARAM );
176 int64_t float64_to_int64( float64 STATUS_PARAM );
177 int64_t float64_to_int64_round_to_zero( float64 STATUS_PARAM );
178 float32 float64_to_float32( float64 STATUS_PARAM );
180 floatx80 float64_to_floatx80( float64 STATUS_PARAM );
183 float128 float64_to_float128( float64 STATUS_PARAM );
186 /*----------------------------------------------------------------------------
187 | Software IEC/IEEE double-precision operations.
188 *----------------------------------------------------------------------------*/
189 float64 float64_round_to_int( float64 STATUS_PARAM );
190 INLINE float64 float64_add( float64 a, float64 b STATUS_PARAM)
194 INLINE float64 float64_sub( float64 a, float64 b STATUS_PARAM)
198 INLINE float64 float64_mul( float64 a, float64 b STATUS_PARAM)
202 INLINE float64 float64_div( float64 a, float64 b STATUS_PARAM)
206 float64 float64_rem( float64, float64 STATUS_PARAM );
207 float64 float64_sqrt( float64 STATUS_PARAM );
208 INLINE char float64_eq( float64 a, float64 b STATUS_PARAM)
212 INLINE char float64_le( float64 a, float64 b STATUS_PARAM)
216 INLINE char float64_lt( float64 a, float64 b STATUS_PARAM)
220 INLINE char float64_eq_signaling( float64 a, float64 b STATUS_PARAM)
222 return a <= b && a >= b;
224 INLINE char float64_le_quiet( float64 a, float64 b STATUS_PARAM)
226 return islessequal(a, b);
228 INLINE char float64_lt_quiet( float64 a, float64 b STATUS_PARAM)
233 INLINE char float64_unordered( float64 a, float64 b STATUS_PARAM)
235 return isunordered(a, b);
238 char float64_compare( float64, float64 STATUS_PARAM );
239 char float64_compare_quiet( float64, float64 STATUS_PARAM );
240 char float64_is_signaling_nan( float64 );
242 INLINE float64 float64_abs(float64 a)
247 INLINE float64 float64_chs(float64 a)
254 /*----------------------------------------------------------------------------
255 | Software IEC/IEEE extended double-precision conversion routines.
256 *----------------------------------------------------------------------------*/
257 int floatx80_to_int32( floatx80 STATUS_PARAM );
258 int floatx80_to_int32_round_to_zero( floatx80 STATUS_PARAM );
259 int64_t floatx80_to_int64( floatx80 STATUS_PARAM);
260 int64_t floatx80_to_int64_round_to_zero( floatx80 STATUS_PARAM);
261 float32 floatx80_to_float32( floatx80 STATUS_PARAM );
262 float64 floatx80_to_float64( floatx80 STATUS_PARAM );
264 float128 floatx80_to_float128( floatx80 STATUS_PARAM );
267 /*----------------------------------------------------------------------------
268 | Software IEC/IEEE extended double-precision operations.
269 *----------------------------------------------------------------------------*/
270 floatx80 floatx80_round_to_int( floatx80 STATUS_PARAM );
271 INLINE floatx80 floatx80_add( floatx80 a, floatx80 b STATUS_PARAM)
275 INLINE floatx80 floatx80_sub( floatx80 a, floatx80 b STATUS_PARAM)
279 INLINE floatx80 floatx80_mul( floatx80 a, floatx80 b STATUS_PARAM)
283 INLINE floatx80 floatx80_div( floatx80 a, floatx80 b STATUS_PARAM)
287 floatx80 floatx80_rem( floatx80, floatx80 STATUS_PARAM );
288 floatx80 floatx80_sqrt( floatx80 STATUS_PARAM );
289 INLINE char floatx80_eq( floatx80 a, floatx80 b STATUS_PARAM)
293 INLINE char floatx80_le( floatx80 a, floatx80 b STATUS_PARAM)
297 INLINE char floatx80_lt( floatx80 a, floatx80 b STATUS_PARAM)
301 INLINE char floatx80_eq_signaling( floatx80 a, floatx80 b STATUS_PARAM)
303 return a <= b && a >= b;
305 INLINE char floatx80_le_quiet( floatx80 a, floatx80 b STATUS_PARAM)
307 return islessequal(a, b);
309 INLINE char floatx80_lt_quiet( floatx80 a, floatx80 b STATUS_PARAM)
314 INLINE char floatx80_unordered( floatx80 a, floatx80 b STATUS_PARAM)
316 return isunordered(a, b);
319 char floatx80_compare( floatx80, floatx80 STATUS_PARAM );
320 char floatx80_compare_quiet( floatx80, floatx80 STATUS_PARAM );
321 char floatx80_is_signaling_nan( floatx80 );
323 INLINE floatx80 floatx80_abs(floatx80 a)
328 INLINE floatx80 floatx80_chs(floatx80 a)