Back to index

glibc  2.9
single.h
Go to the documentation of this file.
00001 /* Software floating-point emulation.
00002    Definitions for IEEE Single Precision.
00003    Copyright (C) 1997,1998,1999,2006 Free Software Foundation, Inc.
00004    This file is part of the GNU C Library.
00005    Contributed by Richard Henderson (rth@cygnus.com),
00006                 Jakub Jelinek (jj@ultra.linux.cz),
00007                 David S. Miller (davem@redhat.com) and
00008                 Peter Maydell (pmaydell@chiark.greenend.org.uk).
00009 
00010    The GNU C Library is free software; you can redistribute it and/or
00011    modify it under the terms of the GNU Lesser General Public
00012    License as published by the Free Software Foundation; either
00013    version 2.1 of the License, or (at your option) any later version.
00014 
00015    In addition to the permissions in the GNU Lesser General Public
00016    License, the Free Software Foundation gives you unlimited
00017    permission to link the compiled version of this file into
00018    combinations with other programs, and to distribute those
00019    combinations without any restriction coming from the use of this
00020    file.  (The Lesser General Public License restrictions do apply in
00021    other respects; for example, they cover modification of the file,
00022    and distribution when not linked into a combine executable.)
00023 
00024    The GNU C Library is distributed in the hope that it will be useful,
00025    but WITHOUT ANY WARRANTY; without even the implied warranty of
00026    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00027    Lesser General Public License for more details.
00028 
00029    You should have received a copy of the GNU Lesser General Public
00030    License along with the GNU C Library; if not, write to the Free
00031    Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
00032    MA 02110-1301, USA.  */
00033 
00034 #if _FP_W_TYPE_SIZE < 32
00035 #error "Here's a nickel kid.  Go buy yourself a real computer."
00036 #endif
00037 
00038 #define _FP_FRACTBITS_S            _FP_W_TYPE_SIZE
00039 
00040 #define _FP_FRACBITS_S             24
00041 #define _FP_FRACXBITS_S            (_FP_FRACTBITS_S - _FP_FRACBITS_S)
00042 #define _FP_WFRACBITS_S            (_FP_WORKBITS + _FP_FRACBITS_S)
00043 #define _FP_WFRACXBITS_S    (_FP_FRACTBITS_S - _FP_WFRACBITS_S)
00044 #define _FP_EXPBITS_S              8
00045 #define _FP_EXPBIAS_S              127
00046 #define _FP_EXPMAX_S        255
00047 #define _FP_QNANBIT_S              ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
00048 #define _FP_QNANBIT_SH_S    ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2+_FP_WORKBITS))
00049 #define _FP_IMPLBIT_S              ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
00050 #define _FP_IMPLBIT_SH_S    ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1+_FP_WORKBITS))
00051 #define _FP_OVERFLOW_S             ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
00052 
00053 /* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be
00054    chosen by the target machine.  */
00055 
00056 typedef float SFtype __attribute__((mode(SF)));
00057 
00058 union _FP_UNION_S
00059 {
00060   SFtype flt;
00061   struct {
00062 #if __BYTE_ORDER == __BIG_ENDIAN
00063     unsigned sign : 1;
00064     unsigned exp  : _FP_EXPBITS_S;
00065     unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
00066 #else
00067     unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
00068     unsigned exp  : _FP_EXPBITS_S;
00069     unsigned sign : 1;
00070 #endif
00071   } bits __attribute__((packed));
00072 };
00073 
00074 #define FP_DECL_S(X)        _FP_DECL(1,X)
00075 #define FP_UNPACK_RAW_S(X,val)     _FP_UNPACK_RAW_1(S,X,val)
00076 #define FP_UNPACK_RAW_SP(X,val)    _FP_UNPACK_RAW_1_P(S,X,val)
00077 #define FP_PACK_RAW_S(val,X)       _FP_PACK_RAW_1(S,val,X)
00078 #define FP_PACK_RAW_SP(val,X)             \
00079   do {                             \
00080     if (!FP_INHIBIT_RESULTS)              \
00081       _FP_PACK_RAW_1_P(S,val,X);   \
00082   } while (0)
00083 
00084 #define FP_UNPACK_S(X,val)         \
00085   do {                             \
00086     _FP_UNPACK_RAW_1(S,X,val);            \
00087     _FP_UNPACK_CANONICAL(S,1,X);   \
00088   } while (0)
00089 
00090 #define FP_UNPACK_SP(X,val)        \
00091   do {                             \
00092     _FP_UNPACK_RAW_1_P(S,X,val);   \
00093     _FP_UNPACK_CANONICAL(S,1,X);   \
00094   } while (0)
00095 
00096 #define FP_UNPACK_SEMIRAW_S(X,val) \
00097   do {                             \
00098     _FP_UNPACK_RAW_1(S,X,val);            \
00099     _FP_UNPACK_SEMIRAW(S,1,X);            \
00100   } while (0)
00101 
00102 #define FP_UNPACK_SEMIRAW_SP(X,val)       \
00103   do {                             \
00104     _FP_UNPACK_RAW_1_P(S,X,val);   \
00105     _FP_UNPACK_SEMIRAW(S,1,X);            \
00106   } while (0)
00107 
00108 #define FP_PACK_S(val,X)           \
00109   do {                             \
00110     _FP_PACK_CANONICAL(S,1,X);            \
00111     _FP_PACK_RAW_1(S,val,X);              \
00112   } while (0)
00113 
00114 #define FP_PACK_SP(val,X)          \
00115   do {                             \
00116     _FP_PACK_CANONICAL(S,1,X);            \
00117     if (!FP_INHIBIT_RESULTS)              \
00118       _FP_PACK_RAW_1_P(S,val,X);   \
00119   } while (0)
00120 
00121 #define FP_PACK_SEMIRAW_S(val,X)   \
00122   do {                             \
00123     _FP_PACK_SEMIRAW(S,1,X);              \
00124     _FP_PACK_RAW_1(S,val,X);              \
00125   } while (0)
00126 
00127 #define FP_PACK_SEMIRAW_SP(val,X)  \
00128   do {                             \
00129     _FP_PACK_SEMIRAW(S,1,X);              \
00130     if (!FP_INHIBIT_RESULTS)              \
00131       _FP_PACK_RAW_1_P(S,val,X);   \
00132   } while (0)
00133 
00134 #define FP_ISSIGNAN_S(X)           _FP_ISSIGNAN(S,1,X)
00135 #define FP_NEG_S(R,X)                     _FP_NEG(S,1,R,X)
00136 #define FP_ADD_S(R,X,Y)                   _FP_ADD(S,1,R,X,Y)
00137 #define FP_SUB_S(R,X,Y)                   _FP_SUB(S,1,R,X,Y)
00138 #define FP_MUL_S(R,X,Y)                   _FP_MUL(S,1,R,X,Y)
00139 #define FP_DIV_S(R,X,Y)                   _FP_DIV(S,1,R,X,Y)
00140 #define FP_SQRT_S(R,X)                    _FP_SQRT(S,1,R,X)
00141 #define _FP_SQRT_MEAT_S(R,S,T,X,Q) _FP_SQRT_MEAT_1(R,S,T,X,Q)
00142 
00143 #define FP_CMP_S(r,X,Y,un)  _FP_CMP(S,1,r,X,Y,un)
00144 #define FP_CMP_EQ_S(r,X,Y)  _FP_CMP_EQ(S,1,r,X,Y)
00145 #define FP_CMP_UNORD_S(r,X,Y)      _FP_CMP_UNORD(S,1,r,X,Y)
00146 
00147 #define FP_TO_INT_S(r,X,rsz,rsg)   _FP_TO_INT(S,1,r,X,rsz,rsg)
00148 #define FP_FROM_INT_S(X,r,rs,rt)   _FP_FROM_INT(S,1,X,r,rs,rt)
00149 
00150 #define _FP_FRAC_HIGH_S(X)  _FP_FRAC_HIGH_1(X)
00151 #define _FP_FRAC_HIGH_RAW_S(X)     _FP_FRAC_HIGH_1(X)