xref: /openbsd/gnu/gcc/gcc/config/s390/fixdfdi.h (revision 404b540a)
1*404b540aSrobert /* Definitions of target machine for GNU compiler, for IBM S/390
2*404b540aSrobert    Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
3*404b540aSrobert    Contributed by Hartmut Penner (hpenner@de.ibm.com) and
4*404b540aSrobert                   Ulrich Weigand (uweigand@de.ibm.com).
5*404b540aSrobert 
6*404b540aSrobert This file is part of GCC.
7*404b540aSrobert 
8*404b540aSrobert GCC is free software; you can redistribute it and/or modify it under
9*404b540aSrobert the terms of the GNU General Public License as published by the Free
10*404b540aSrobert Software Foundation; either version 2, or (at your option) any later
11*404b540aSrobert version.
12*404b540aSrobert 
13*404b540aSrobert GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14*404b540aSrobert WARRANTY; without even the implied warranty of MERCHANTABILITY or
15*404b540aSrobert FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16*404b540aSrobert for more details.
17*404b540aSrobert 
18*404b540aSrobert You should have received a copy of the GNU General Public License
19*404b540aSrobert along with GCC; see the file COPYING.  If not, write to the Free
20*404b540aSrobert Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
21*404b540aSrobert 02110-1301, USA.  */
22*404b540aSrobert 
23*404b540aSrobert #ifdef L_fixunstfdi
24*404b540aSrobert 
25*404b540aSrobert #define EXPD(fp)	   (((fp.l.i[0]) >> 16) & 0x7FFF)
26*404b540aSrobert #define EXPONENT_BIAS	   16383
27*404b540aSrobert #define MANTISSA_BITS      112
28*404b540aSrobert #define PRECISION          (MANTISSA_BITS + 1)
29*404b540aSrobert #define SIGNBIT		   0x80000000
30*404b540aSrobert #define SIGND(fp)	   ((fp.l.i[0]) & SIGNBIT)
31*404b540aSrobert #define MANTD_HIGH_LL(fp)  ((fp.ll[0] & HIGH_LL_FRAC_MASK) | HIGH_LL_UNIT_BIT)
32*404b540aSrobert #define MANTD_LOW_LL(fp)   (fp.ll[1])
33*404b540aSrobert #define FRACD_ZERO_P(fp)   (!fp.ll[1] && !(fp.ll[0] & HIGH_LL_FRAC_MASK))
34*404b540aSrobert #define HIGH_LL_FRAC_BITS  48
35*404b540aSrobert #define HIGH_LL_UNIT_BIT   ((UDItype_x)1 << HIGH_LL_FRAC_BITS)
36*404b540aSrobert #define HIGH_LL_FRAC_MASK  (HIGH_LL_UNIT_BIT - 1)
37*404b540aSrobert 
38*404b540aSrobert typedef int DItype_x __attribute__ ((mode (DI)));
39*404b540aSrobert typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
40*404b540aSrobert typedef int SItype_x __attribute__ ((mode (SI)));
41*404b540aSrobert typedef unsigned int USItype_x __attribute__ ((mode (SI)));
42*404b540aSrobert 
43*404b540aSrobert union double_long {
44*404b540aSrobert   long double d;
45*404b540aSrobert   struct {
46*404b540aSrobert       SItype_x i[4]; /* 32 bit parts: 0 upper ... 3 lowest */
47*404b540aSrobert     } l;
48*404b540aSrobert   UDItype_x ll[2];   /* 64 bit parts: 0 upper, 1 lower */
49*404b540aSrobert };
50*404b540aSrobert 
51*404b540aSrobert UDItype_x __fixunstfdi (long double a1);
52*404b540aSrobert 
53*404b540aSrobert /* convert double to unsigned int */
54*404b540aSrobert UDItype_x
__fixunstfdi(long double a1)55*404b540aSrobert __fixunstfdi (long double a1)
56*404b540aSrobert {
57*404b540aSrobert     register union double_long dl1;
58*404b540aSrobert     register int exp;
59*404b540aSrobert     register UDItype_x l;
60*404b540aSrobert 
61*404b540aSrobert     dl1.d = a1;
62*404b540aSrobert 
63*404b540aSrobert     /* +/- 0, denormalized, negative */
64*404b540aSrobert     if (!EXPD (dl1) || SIGND(dl1))
65*404b540aSrobert       return 0;
66*404b540aSrobert 
67*404b540aSrobert     /* The exponent - considered the binary point at the right end of
68*404b540aSrobert        the mantissa.  */
69*404b540aSrobert     exp = EXPD (dl1) - EXPONENT_BIAS - MANTISSA_BITS;
70*404b540aSrobert 
71*404b540aSrobert     /* number < 1: If the mantissa would need to be right-shifted more bits than
72*404b540aSrobert        its size (plus the implied one bit on the left) the result would be
73*404b540aSrobert        zero.  */
74*404b540aSrobert     if (exp <= -PRECISION)
75*404b540aSrobert       return 0;
76*404b540aSrobert 
77*404b540aSrobert     /* NaN: All exponent bits set and a nonzero fraction.  */
78*404b540aSrobert     if ((EXPD(dl1) == 0x7fff) && !FRACD_ZERO_P (dl1))
79*404b540aSrobert       return 0x0ULL;
80*404b540aSrobert 
81*404b540aSrobert     /* If the upper ll part of the mantissa isn't
82*404b540aSrobert        zeroed out after shifting the number would be to large.  */
83*404b540aSrobert     if (exp >= -HIGH_LL_FRAC_BITS)
84*404b540aSrobert       return 0xFFFFFFFFFFFFFFFFULL;
85*404b540aSrobert 
86*404b540aSrobert     exp += HIGH_LL_FRAC_BITS + 1;
87*404b540aSrobert 
88*404b540aSrobert     l = MANTD_LOW_LL (dl1) >> (HIGH_LL_FRAC_BITS + 1)
89*404b540aSrobert         | MANTD_HIGH_LL (dl1) << (64 - (HIGH_LL_FRAC_BITS + 1));
90*404b540aSrobert 
91*404b540aSrobert     return l >> -exp;
92*404b540aSrobert }
93*404b540aSrobert #define __fixunstfdi ___fixunstfdi
94*404b540aSrobert #endif
95*404b540aSrobert #undef L_fixunstfdi
96*404b540aSrobert 
97*404b540aSrobert #ifdef L_fixtfdi
98*404b540aSrobert #define EXPD(fp)	   (((fp.l.i[0]) >> 16) & 0x7FFF)
99*404b540aSrobert #define EXPONENT_BIAS	   16383
100*404b540aSrobert #define MANTISSA_BITS      112
101*404b540aSrobert #define PRECISION          (MANTISSA_BITS + 1)
102*404b540aSrobert #define SIGNBIT		   0x80000000
103*404b540aSrobert #define SIGND(fp)	   ((fp.l.i[0]) & SIGNBIT)
104*404b540aSrobert #define MANTD_HIGH_LL(fp)  ((fp.ll[0] & HIGH_LL_FRAC_MASK) | HIGH_LL_UNIT_BIT)
105*404b540aSrobert #define MANTD_LOW_LL(fp)   (fp.ll[1])
106*404b540aSrobert #define FRACD_ZERO_P(fp)   (!fp.ll[1] && !(fp.ll[0] & HIGH_LL_FRAC_MASK))
107*404b540aSrobert #define HIGH_LL_FRAC_BITS  48
108*404b540aSrobert #define HIGH_LL_UNIT_BIT   ((UDItype_x)1 << HIGH_LL_FRAC_BITS)
109*404b540aSrobert #define HIGH_LL_FRAC_MASK  (HIGH_LL_UNIT_BIT - 1)
110*404b540aSrobert 
111*404b540aSrobert typedef int DItype_x __attribute__ ((mode (DI)));
112*404b540aSrobert typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
113*404b540aSrobert typedef int SItype_x __attribute__ ((mode (SI)));
114*404b540aSrobert typedef unsigned int USItype_x __attribute__ ((mode (SI)));
115*404b540aSrobert 
116*404b540aSrobert union double_long {
117*404b540aSrobert   long double d;
118*404b540aSrobert   struct {
119*404b540aSrobert       SItype_x i[4]; /* 32 bit parts: 0 upper ... 3 lowest */
120*404b540aSrobert     } l;
121*404b540aSrobert   DItype_x ll[2];   /* 64 bit parts: 0 upper, 1 lower */
122*404b540aSrobert };
123*404b540aSrobert 
124*404b540aSrobert DItype_x __fixtfdi (long double a1);
125*404b540aSrobert 
126*404b540aSrobert /* convert double to unsigned int */
127*404b540aSrobert DItype_x
__fixtfdi(long double a1)128*404b540aSrobert __fixtfdi (long double a1)
129*404b540aSrobert {
130*404b540aSrobert     register union double_long dl1;
131*404b540aSrobert     register int exp;
132*404b540aSrobert     register UDItype_x l;
133*404b540aSrobert 
134*404b540aSrobert     dl1.d = a1;
135*404b540aSrobert 
136*404b540aSrobert     /* +/- 0, denormalized */
137*404b540aSrobert     if (!EXPD (dl1))
138*404b540aSrobert       return 0;
139*404b540aSrobert 
140*404b540aSrobert     /* The exponent - considered the binary point at the right end of
141*404b540aSrobert        the mantissa.  */
142*404b540aSrobert     exp = EXPD (dl1) - EXPONENT_BIAS - MANTISSA_BITS;
143*404b540aSrobert 
144*404b540aSrobert     /* number < 1: If the mantissa would need to be right-shifted more bits than
145*404b540aSrobert        its size the result would be zero.  */
146*404b540aSrobert     if (exp <= -PRECISION)
147*404b540aSrobert       return 0;
148*404b540aSrobert 
149*404b540aSrobert     /* NaN: All exponent bits set and a nonzero fraction.  */
150*404b540aSrobert     if ((EXPD(dl1) == 0x7fff) && !FRACD_ZERO_P (dl1))
151*404b540aSrobert       return 0x8000000000000000ULL;
152*404b540aSrobert 
153*404b540aSrobert     /* If the upper ll part of the mantissa isn't
154*404b540aSrobert        zeroed out after shifting the number would be to large.  */
155*404b540aSrobert     if (exp >= -HIGH_LL_FRAC_BITS)
156*404b540aSrobert       {
157*404b540aSrobert 	l = (long long)1 << 63; /* long int min */
158*404b540aSrobert 	return SIGND (dl1) ? l : l - 1;
159*404b540aSrobert       }
160*404b540aSrobert 
161*404b540aSrobert     /* The extra bit is needed for the sign bit.  */
162*404b540aSrobert     exp += HIGH_LL_FRAC_BITS + 1;
163*404b540aSrobert 
164*404b540aSrobert     l = MANTD_LOW_LL (dl1) >> (HIGH_LL_FRAC_BITS + 1)
165*404b540aSrobert         | MANTD_HIGH_LL (dl1) << (64 - (HIGH_LL_FRAC_BITS + 1));
166*404b540aSrobert 
167*404b540aSrobert     return SIGND (dl1) ? -(l >> -exp) : l >> -exp;
168*404b540aSrobert }
169*404b540aSrobert #define __fixtfdi ___fixtfdi
170*404b540aSrobert #endif
171*404b540aSrobert #undef L_fixtfdi
172*404b540aSrobert 
173*404b540aSrobert #ifdef L_fixunsdfdi
174*404b540aSrobert #define EXPD(fp)	(((fp.l.upper) >> 20) & 0x7FF)
175*404b540aSrobert #define EXCESSD		1022
176*404b540aSrobert #define SIGNBIT		0x80000000
177*404b540aSrobert #define SIGND(fp)	((fp.l.upper) & SIGNBIT)
178*404b540aSrobert #define MANTD_LL(fp)	((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
179*404b540aSrobert #define FRACD_LL(fp)	(fp.ll & (HIDDEND_LL-1))
180*404b540aSrobert #define HIDDEND_LL	((UDItype_x)1 << 52)
181*404b540aSrobert 
182*404b540aSrobert typedef int DItype_x __attribute__ ((mode (DI)));
183*404b540aSrobert typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
184*404b540aSrobert typedef int SItype_x __attribute__ ((mode (SI)));
185*404b540aSrobert typedef unsigned int USItype_x __attribute__ ((mode (SI)));
186*404b540aSrobert 
187*404b540aSrobert union double_long {
188*404b540aSrobert     double d;
189*404b540aSrobert     struct {
190*404b540aSrobert       SItype_x upper;
191*404b540aSrobert       USItype_x lower;
192*404b540aSrobert     } l;
193*404b540aSrobert     UDItype_x ll;
194*404b540aSrobert };
195*404b540aSrobert 
196*404b540aSrobert UDItype_x __fixunsdfdi (double a1);
197*404b540aSrobert 
198*404b540aSrobert /* convert double to unsigned int */
199*404b540aSrobert UDItype_x
__fixunsdfdi(double a1)200*404b540aSrobert __fixunsdfdi (double a1)
201*404b540aSrobert {
202*404b540aSrobert     register union double_long dl1;
203*404b540aSrobert     register int exp;
204*404b540aSrobert     register UDItype_x l;
205*404b540aSrobert 
206*404b540aSrobert     dl1.d = a1;
207*404b540aSrobert 
208*404b540aSrobert     /* +/- 0, denormalized, negative */
209*404b540aSrobert 
210*404b540aSrobert     if (!EXPD (dl1) || SIGND(dl1))
211*404b540aSrobert       return 0;
212*404b540aSrobert 
213*404b540aSrobert     exp = EXPD (dl1) - EXCESSD - 53;
214*404b540aSrobert 
215*404b540aSrobert     /* number < 1 */
216*404b540aSrobert 
217*404b540aSrobert     if (exp < -53)
218*404b540aSrobert       return 0;
219*404b540aSrobert 
220*404b540aSrobert     /* NaN */
221*404b540aSrobert 
222*404b540aSrobert     if ((EXPD(dl1) == 0x7ff) && (FRACD_LL(dl1) != 0)) /* NaN */
223*404b540aSrobert       return 0x0ULL;
224*404b540aSrobert 
225*404b540aSrobert     /* Number big number & + inf */
226*404b540aSrobert 
227*404b540aSrobert     if (exp >= 12) {
228*404b540aSrobert       return 0xFFFFFFFFFFFFFFFFULL;
229*404b540aSrobert     }
230*404b540aSrobert 
231*404b540aSrobert     l = MANTD_LL(dl1);
232*404b540aSrobert 
233*404b540aSrobert     /* shift down until exp < 12 or l = 0 */
234*404b540aSrobert     if (exp > 0)
235*404b540aSrobert       l <<= exp;
236*404b540aSrobert     else
237*404b540aSrobert       l >>= -exp;
238*404b540aSrobert 
239*404b540aSrobert     return l;
240*404b540aSrobert }
241*404b540aSrobert #define __fixunsdfdi ___fixunsdfdi
242*404b540aSrobert #endif
243*404b540aSrobert #undef L_fixunsdfdi
244*404b540aSrobert 
245*404b540aSrobert #ifdef L_fixdfdi
246*404b540aSrobert #define EXPD(fp)	(((fp.l.upper) >> 20) & 0x7FF)
247*404b540aSrobert #define EXCESSD		1022
248*404b540aSrobert #define SIGNBIT		0x80000000
249*404b540aSrobert #define SIGND(fp)	((fp.l.upper) & SIGNBIT)
250*404b540aSrobert #define MANTD_LL(fp)	((fp.ll & (HIDDEND_LL-1)) | HIDDEND_LL)
251*404b540aSrobert #define FRACD_LL(fp)	(fp.ll & (HIDDEND_LL-1))
252*404b540aSrobert #define HIDDEND_LL	((UDItype_x)1 << 52)
253*404b540aSrobert 
254*404b540aSrobert typedef int DItype_x __attribute__ ((mode (DI)));
255*404b540aSrobert typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
256*404b540aSrobert typedef int SItype_x __attribute__ ((mode (SI)));
257*404b540aSrobert typedef unsigned int USItype_x __attribute__ ((mode (SI)));
258*404b540aSrobert 
259*404b540aSrobert union double_long {
260*404b540aSrobert     double d;
261*404b540aSrobert     struct {
262*404b540aSrobert       SItype_x upper;
263*404b540aSrobert       USItype_x lower;
264*404b540aSrobert     } l;
265*404b540aSrobert     UDItype_x ll;
266*404b540aSrobert };
267*404b540aSrobert 
268*404b540aSrobert DItype_x __fixdfdi (double a1);
269*404b540aSrobert 
270*404b540aSrobert /* convert double to int */
271*404b540aSrobert DItype_x
__fixdfdi(double a1)272*404b540aSrobert __fixdfdi (double a1)
273*404b540aSrobert {
274*404b540aSrobert     register union double_long dl1;
275*404b540aSrobert     register int exp;
276*404b540aSrobert     register DItype_x l;
277*404b540aSrobert 
278*404b540aSrobert     dl1.d = a1;
279*404b540aSrobert 
280*404b540aSrobert     /* +/- 0, denormalized */
281*404b540aSrobert 
282*404b540aSrobert     if (!EXPD (dl1))
283*404b540aSrobert       return 0;
284*404b540aSrobert 
285*404b540aSrobert     exp = EXPD (dl1) - EXCESSD - 53;
286*404b540aSrobert 
287*404b540aSrobert     /* number < 1 */
288*404b540aSrobert 
289*404b540aSrobert     if (exp < -53)
290*404b540aSrobert       return 0;
291*404b540aSrobert 
292*404b540aSrobert     /* NaN */
293*404b540aSrobert 
294*404b540aSrobert     if ((EXPD(dl1) == 0x7ff) && (FRACD_LL(dl1) != 0)) /* NaN */
295*404b540aSrobert       return 0x8000000000000000ULL;
296*404b540aSrobert 
297*404b540aSrobert     /* Number big number & +/- inf */
298*404b540aSrobert 
299*404b540aSrobert     if (exp >= 11) {
300*404b540aSrobert 	l = (long long)1<<63;
301*404b540aSrobert 	if (!SIGND(dl1))
302*404b540aSrobert 	    l--;
303*404b540aSrobert 	return l;
304*404b540aSrobert     }
305*404b540aSrobert 
306*404b540aSrobert     l = MANTD_LL(dl1);
307*404b540aSrobert 
308*404b540aSrobert     /* shift down until exp < 12 or l = 0 */
309*404b540aSrobert     if (exp > 0)
310*404b540aSrobert       l <<= exp;
311*404b540aSrobert     else
312*404b540aSrobert       l >>= -exp;
313*404b540aSrobert 
314*404b540aSrobert     return (SIGND (dl1) ? -l : l);
315*404b540aSrobert }
316*404b540aSrobert #define __fixdfdi ___fixdfdi
317*404b540aSrobert #endif
318*404b540aSrobert #undef L_fixdfdi
319*404b540aSrobert 
320*404b540aSrobert #ifdef L_fixunssfdi
321*404b540aSrobert #define EXP(fp)         (((fp.l) >> 23) & 0xFF)
322*404b540aSrobert #define EXCESS          126
323*404b540aSrobert #define SIGNBIT         0x80000000
324*404b540aSrobert #define SIGN(fp)        ((fp.l) & SIGNBIT)
325*404b540aSrobert #define HIDDEN          (1 << 23)
326*404b540aSrobert #define MANT(fp)        (((fp.l) & 0x7FFFFF) | HIDDEN)
327*404b540aSrobert #define FRAC(fp)        ((fp.l) & 0x7FFFFF)
328*404b540aSrobert 
329*404b540aSrobert typedef int DItype_x __attribute__ ((mode (DI)));
330*404b540aSrobert typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
331*404b540aSrobert typedef int SItype_x __attribute__ ((mode (SI)));
332*404b540aSrobert typedef unsigned int USItype_x __attribute__ ((mode (SI)));
333*404b540aSrobert 
334*404b540aSrobert union float_long
335*404b540aSrobert   {
336*404b540aSrobert     float f;
337*404b540aSrobert     USItype_x l;
338*404b540aSrobert   };
339*404b540aSrobert 
340*404b540aSrobert UDItype_x __fixunssfdi (float a1);
341*404b540aSrobert 
342*404b540aSrobert /* convert float to unsigned int */
343*404b540aSrobert UDItype_x
__fixunssfdi(float a1)344*404b540aSrobert __fixunssfdi (float a1)
345*404b540aSrobert {
346*404b540aSrobert     register union float_long fl1;
347*404b540aSrobert     register int exp;
348*404b540aSrobert     register UDItype_x l;
349*404b540aSrobert 
350*404b540aSrobert     fl1.f = a1;
351*404b540aSrobert 
352*404b540aSrobert     /* +/- 0, denormalized, negative */
353*404b540aSrobert 
354*404b540aSrobert     if (!EXP (fl1) || SIGN(fl1))
355*404b540aSrobert       return 0;
356*404b540aSrobert 
357*404b540aSrobert     exp = EXP (fl1) - EXCESS - 24;
358*404b540aSrobert 
359*404b540aSrobert     /* number < 1 */
360*404b540aSrobert 
361*404b540aSrobert     if (exp < -24)
362*404b540aSrobert       return 0;
363*404b540aSrobert 
364*404b540aSrobert     /* NaN */
365*404b540aSrobert 
366*404b540aSrobert     if ((EXP(fl1) == 0xff) && (FRAC(fl1) != 0)) /* NaN */
367*404b540aSrobert       return 0x0ULL;
368*404b540aSrobert 
369*404b540aSrobert     /* Number big number & + inf */
370*404b540aSrobert 
371*404b540aSrobert     if (exp >= 41) {
372*404b540aSrobert       return 0xFFFFFFFFFFFFFFFFULL;
373*404b540aSrobert     }
374*404b540aSrobert 
375*404b540aSrobert     l = MANT(fl1);
376*404b540aSrobert 
377*404b540aSrobert     if (exp > 0)
378*404b540aSrobert       l <<= exp;
379*404b540aSrobert     else
380*404b540aSrobert       l >>= -exp;
381*404b540aSrobert 
382*404b540aSrobert     return l;
383*404b540aSrobert }
384*404b540aSrobert #define __fixunssfdi ___fixunssfdi
385*404b540aSrobert #endif
386*404b540aSrobert #undef L_fixunssfdi
387*404b540aSrobert 
388*404b540aSrobert #ifdef L_fixsfdi
389*404b540aSrobert #define EXP(fp)         (((fp.l) >> 23) & 0xFF)
390*404b540aSrobert #define EXCESS          126
391*404b540aSrobert #define SIGNBIT         0x80000000
392*404b540aSrobert #define SIGN(fp)        ((fp.l) & SIGNBIT)
393*404b540aSrobert #define HIDDEN          (1 << 23)
394*404b540aSrobert #define MANT(fp)        (((fp.l) & 0x7FFFFF) | HIDDEN)
395*404b540aSrobert #define FRAC(fp)        ((fp.l) & 0x7FFFFF)
396*404b540aSrobert 
397*404b540aSrobert typedef int DItype_x __attribute__ ((mode (DI)));
398*404b540aSrobert typedef unsigned int UDItype_x __attribute__ ((mode (DI)));
399*404b540aSrobert typedef int SItype_x __attribute__ ((mode (SI)));
400*404b540aSrobert typedef unsigned int USItype_x __attribute__ ((mode (SI)));
401*404b540aSrobert 
402*404b540aSrobert union float_long
403*404b540aSrobert   {
404*404b540aSrobert     float f;
405*404b540aSrobert     USItype_x l;
406*404b540aSrobert   };
407*404b540aSrobert 
408*404b540aSrobert DItype_x __fixsfdi (float a1);
409*404b540aSrobert 
410*404b540aSrobert /* convert double to int */
411*404b540aSrobert DItype_x
__fixsfdi(float a1)412*404b540aSrobert __fixsfdi (float a1)
413*404b540aSrobert {
414*404b540aSrobert     register union float_long fl1;
415*404b540aSrobert     register int exp;
416*404b540aSrobert     register DItype_x l;
417*404b540aSrobert 
418*404b540aSrobert     fl1.f = a1;
419*404b540aSrobert 
420*404b540aSrobert     /* +/- 0, denormalized */
421*404b540aSrobert 
422*404b540aSrobert     if (!EXP (fl1))
423*404b540aSrobert       return 0;
424*404b540aSrobert 
425*404b540aSrobert     exp = EXP (fl1) - EXCESS - 24;
426*404b540aSrobert 
427*404b540aSrobert     /* number < 1 */
428*404b540aSrobert 
429*404b540aSrobert     if (exp < -24)
430*404b540aSrobert       return 0;
431*404b540aSrobert 
432*404b540aSrobert     /* NaN */
433*404b540aSrobert 
434*404b540aSrobert     if ((EXP(fl1) == 0xff) && (FRAC(fl1) != 0)) /* NaN */
435*404b540aSrobert       return 0x8000000000000000ULL;
436*404b540aSrobert 
437*404b540aSrobert     /* Number big number & +/- inf */
438*404b540aSrobert 
439*404b540aSrobert     if (exp >= 40) {
440*404b540aSrobert 	l = (long long)1<<63;
441*404b540aSrobert 	if (!SIGN(fl1))
442*404b540aSrobert 	    l--;
443*404b540aSrobert 	return l;
444*404b540aSrobert     }
445*404b540aSrobert 
446*404b540aSrobert     l = MANT(fl1);
447*404b540aSrobert 
448*404b540aSrobert     if (exp > 0)
449*404b540aSrobert       l <<= exp;
450*404b540aSrobert     else
451*404b540aSrobert       l >>= -exp;
452*404b540aSrobert 
453*404b540aSrobert     return (SIGN (fl1) ? -l : l);
454*404b540aSrobert }
455*404b540aSrobert #define __fixsfdi ___fixsfdi
456*404b540aSrobert #endif
457*404b540aSrobert #undef L_fixsfdi
458