* sysdeps/unix/sysv/linux/sparc/sparc64/dl-procinfo.c: Moved to ...
[glibc.git] / soft-fp / single.h
blobffb31786af0398faefce2f71453e60824fb752cb
1 /* Software floating-point emulation.
2 Definitions for IEEE Single Precision.
3 Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
5 Contributed by Richard Henderson (rth@cygnus.com),
6 Jakub Jelinek (jj@ultra.linux.cz),
7 David S. Miller (davem@redhat.com) and
8 Peter Maydell (pmaydell@chiark.greenend.org.uk).
10 The GNU C Library is free software; you can redistribute it and/or
11 modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
15 The GNU C Library is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 Lesser General Public License for more details.
20 You should have received a copy of the GNU Lesser General Public
21 License along with the GNU C Library; if not, write to the Free
22 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 02111-1307 USA. */
25 #if _FP_W_TYPE_SIZE < 32
26 #error "Here's a nickel kid. Go buy yourself a real computer."
27 #endif
29 #define _FP_FRACTBITS_S _FP_W_TYPE_SIZE
31 #define _FP_FRACBITS_S 24
32 #define _FP_FRACXBITS_S (_FP_FRACTBITS_S - _FP_FRACBITS_S)
33 #define _FP_WFRACBITS_S (_FP_WORKBITS + _FP_FRACBITS_S)
34 #define _FP_WFRACXBITS_S (_FP_FRACTBITS_S - _FP_WFRACBITS_S)
35 #define _FP_EXPBITS_S 8
36 #define _FP_EXPBIAS_S 127
37 #define _FP_EXPMAX_S 255
38 #define _FP_QNANBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
39 #define _FP_QNANBIT_SH_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2+_FP_WORKBITS))
40 #define _FP_IMPLBIT_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
41 #define _FP_IMPLBIT_SH_S ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1+_FP_WORKBITS))
42 #define _FP_OVERFLOW_S ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
44 /* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be
45 chosen by the target machine. */
47 typedef float SFtype __attribute__((mode(SF)));
49 union _FP_UNION_S
51 SFtype flt;
52 struct {
53 #if __BYTE_ORDER == __BIG_ENDIAN
54 unsigned sign : 1;
55 unsigned exp : _FP_EXPBITS_S;
56 unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
57 #else
58 unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
59 unsigned exp : _FP_EXPBITS_S;
60 unsigned sign : 1;
61 #endif
62 } bits __attribute__((packed));
65 #define FP_DECL_S(X) _FP_DECL(1,X)
66 #define FP_UNPACK_RAW_S(X,val) _FP_UNPACK_RAW_1(S,X,val)
67 #define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val)
68 #define FP_PACK_RAW_S(val,X) _FP_PACK_RAW_1(S,val,X)
69 #define FP_PACK_RAW_SP(val,X) \
70 do { \
71 if (!FP_INHIBIT_RESULTS) \
72 _FP_PACK_RAW_1_P(S,val,X); \
73 } while (0)
75 #define FP_UNPACK_S(X,val) \
76 do { \
77 _FP_UNPACK_RAW_1(S,X,val); \
78 _FP_UNPACK_CANONICAL(S,1,X); \
79 } while (0)
81 #define FP_UNPACK_SP(X,val) \
82 do { \
83 _FP_UNPACK_RAW_1_P(S,X,val); \
84 _FP_UNPACK_CANONICAL(S,1,X); \
85 } while (0)
87 #define FP_UNPACK_SEMIRAW_S(X,val) \
88 do { \
89 _FP_UNPACK_RAW_1(S,X,val); \
90 _FP_UNPACK_SEMIRAW(S,1,X); \
91 } while (0)
93 #define FP_UNPACK_SEMIRAW_SP(X,val) \
94 do { \
95 _FP_UNPACK_RAW_1_P(S,X,val); \
96 _FP_UNPACK_SEMIRAW(S,1,X); \
97 } while (0)
99 #define FP_PACK_S(val,X) \
100 do { \
101 _FP_PACK_CANONICAL(S,1,X); \
102 _FP_PACK_RAW_1(S,val,X); \
103 } while (0)
105 #define FP_PACK_SP(val,X) \
106 do { \
107 _FP_PACK_CANONICAL(S,1,X); \
108 if (!FP_INHIBIT_RESULTS) \
109 _FP_PACK_RAW_1_P(S,val,X); \
110 } while (0)
112 #define FP_PACK_SEMIRAW_S(val,X) \
113 do { \
114 _FP_PACK_SEMIRAW(S,1,X); \
115 _FP_PACK_RAW_1(S,val,X); \
116 } while (0)
118 #define FP_PACK_SEMIRAW_SP(val,X) \
119 do { \
120 _FP_PACK_SEMIRAW(S,1,X); \
121 if (!FP_INHIBIT_RESULTS) \
122 _FP_PACK_RAW_1_P(S,val,X); \
123 } while (0)
125 #define FP_ISSIGNAN_S(X) _FP_ISSIGNAN(S,1,X)
126 #define FP_NEG_S(R,X) _FP_NEG(S,1,R,X)
127 #define FP_ADD_S(R,X,Y) _FP_ADD(S,1,R,X,Y)
128 #define FP_SUB_S(R,X,Y) _FP_SUB(S,1,R,X,Y)
129 #define FP_MUL_S(R,X,Y) _FP_MUL(S,1,R,X,Y)
130 #define FP_DIV_S(R,X,Y) _FP_DIV(S,1,R,X,Y)
131 #define FP_SQRT_S(R,X) _FP_SQRT(S,1,R,X)
132 #define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
134 #define FP_CMP_S(r,X,Y,un) _FP_CMP(S,1,r,X,Y,un)
135 #define FP_CMP_EQ_S(r,X,Y) _FP_CMP_EQ(S,1,r,X,Y)
136 #define FP_CMP_UNORD_S(r,X,Y) _FP_CMP_UNORD(S,1,r,X,Y)
138 #define FP_TO_INT_S(r,X,rsz,rsg) _FP_TO_INT(S,1,r,X,rsz,rsg)
139 #define FP_FROM_INT_S(X,r,rs,rt) _FP_FROM_INT(S,1,X,r,rs,rt)
141 #define _FP_FRAC_HIGH_S(X) _FP_FRAC_HIGH_1(X)
142 #define _FP_FRAC_HIGH_RAW_S(X) _FP_FRAC_HIGH_1(X)