fixed a warning outside the -mds390 environment
[fw/sdcc] / device / lib / _ulong2fs.c
1 /*
2 ** libgcc support for software floating point.
3 ** Copyright (C) 1991 by Pipeline Associates, Inc.  All rights reserved.
4 ** Permission is granted to do *anything* you want with this file,
5 ** commercial or otherwise, provided this message remains intact.  So there!
6 ** I would appreciate receiving any updates/patches/changes that anyone
7 ** makes, and am willing to be the repository for said changes (am I
8 ** making a big mistake?).
9 **
10 ** Pat Wood
11 ** Pipeline Associates, Inc.
12 ** pipeline!phw@motown.com or
13 ** sun!pipeline!phw or
14 ** uunet!motown!pipeline!phw
15 */
16
17 /* (c)2000: hacked a little by johan.knol@iduna.nl for sdcc */
18
19 #include <_float.h>
20
21 /* the following deal with IEEE single-precision numbers */
22 #define EXCESS          126
23 #define SIGNBIT         ((unsigned long)0x80000000)
24 #define HIDDEN          (unsigned long)(1 << 23)
25 #define SIGN(fp)        ((fp) & SIGNBIT)
26 #define EXP(fp)         (((fp) >> 23) & (unsigned int) 0x00FF)
27 #define MANT(fp)        (((fp) & (unsigned long)0x007FFFFF) | HIDDEN)
28 #define PACK(s,e,m)     ((s) | ((e) << 23) | (m))
29
30 union float_long
31   {
32     float f;
33     long l;
34   };
35
36 float 
37 __ulong2fs (unsigned long a )
38 {
39   int exp = 24 + EXCESS;
40   volatile union float_long fl;
41
42   if (!a)
43     {
44       return 0.0;
45     }
46
47   while (a < HIDDEN)
48     {
49       a <<= 1;
50       exp--;
51     }
52
53    a &= ~HIDDEN ;
54   /* pack up and go home */
55   fl.l = PACK(0,(unsigned long)exp, a);
56
57   return (fl.f);
58 }