Back to home page

OSCL-LXR

 
 

    


0001 /* Software floating-point emulation.
0002    Definitions for IEEE Single Precision.
0003    Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
0004    This file is part of the GNU C Library.
0005    Contributed by Richard Henderson (rth@cygnus.com),
0006           Jakub Jelinek (jj@ultra.linux.cz),
0007           David S. Miller (davem@redhat.com) and
0008           Peter Maydell (pmaydell@chiark.greenend.org.uk).
0009 
0010    The GNU C Library is free software; you can redistribute it and/or
0011    modify it under the terms of the GNU Library General Public License as
0012    published by the Free Software Foundation; either version 2 of the
0013    License, or (at your option) any later version.
0014 
0015    The GNU C Library is distributed in the hope that it will be useful,
0016    but WITHOUT ANY WARRANTY; without even the implied warranty of
0017    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0018    Library General Public License for more details.
0019 
0020    You should have received a copy of the GNU Library General Public
0021    License along with the GNU C Library; see the file COPYING.LIB.  If
0022    not, write to the Free Software Foundation, Inc.,
0023    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
0024 
0025 #ifndef    __MATH_EMU_SINGLE_H__
0026 #define    __MATH_EMU_SINGLE_H__
0027 
0028 #if _FP_W_TYPE_SIZE < 32
0029 #error "Here's a nickel kid.  Go buy yourself a real computer."
0030 #endif
0031 
0032 #define _FP_FRACBITS_S      24
0033 #define _FP_FRACXBITS_S     (_FP_W_TYPE_SIZE - _FP_FRACBITS_S)
0034 #define _FP_WFRACBITS_S     (_FP_WORKBITS + _FP_FRACBITS_S)
0035 #define _FP_WFRACXBITS_S    (_FP_W_TYPE_SIZE - _FP_WFRACBITS_S)
0036 #define _FP_EXPBITS_S       8
0037 #define _FP_EXPBIAS_S       127
0038 #define _FP_EXPMAX_S        255
0039 #define _FP_QNANBIT_S       ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-2))
0040 #define _FP_IMPLBIT_S       ((_FP_W_TYPE)1 << (_FP_FRACBITS_S-1))
0041 #define _FP_OVERFLOW_S      ((_FP_W_TYPE)1 << (_FP_WFRACBITS_S))
0042 
0043 /* The implementation of _FP_MUL_MEAT_S and _FP_DIV_MEAT_S should be
0044    chosen by the target machine.  */
0045 
0046 union _FP_UNION_S
0047 {
0048   float flt;
0049   struct {
0050 #if __BYTE_ORDER == __BIG_ENDIAN
0051     unsigned sign : 1;
0052     unsigned exp  : _FP_EXPBITS_S;
0053     unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
0054 #else
0055     unsigned frac : _FP_FRACBITS_S - (_FP_IMPLBIT_S != 0);
0056     unsigned exp  : _FP_EXPBITS_S;
0057     unsigned sign : 1;
0058 #endif
0059   } bits __attribute__((packed));
0060 };
0061 
0062 #define FP_DECL_S(X)        _FP_DECL(1,X)
0063 #define FP_UNPACK_RAW_S(X,val)  _FP_UNPACK_RAW_1(S,X,val)
0064 #define FP_UNPACK_RAW_SP(X,val) _FP_UNPACK_RAW_1_P(S,X,val)
0065 #define FP_PACK_RAW_S(val,X)    _FP_PACK_RAW_1(S,val,X)
0066 #define FP_PACK_RAW_SP(val,X)       \
0067   do {                  \
0068     if (!FP_INHIBIT_RESULTS)        \
0069       _FP_PACK_RAW_1_P(S,val,X);    \
0070   } while (0)
0071 
0072 #define FP_UNPACK_S(X,val)      \
0073   do {                  \
0074     _FP_UNPACK_RAW_1(S,X,val);      \
0075     _FP_UNPACK_CANONICAL(S,1,X);    \
0076   } while (0)
0077 
0078 #define FP_UNPACK_SP(X,val)     \
0079   do {                  \
0080     _FP_UNPACK_RAW_1_P(S,X,val);    \
0081     _FP_UNPACK_CANONICAL(S,1,X);    \
0082   } while (0)
0083 
0084 #define FP_PACK_S(val,X)        \
0085   do {                  \
0086     _FP_PACK_CANONICAL(S,1,X);      \
0087     _FP_PACK_RAW_1(S,val,X);        \
0088   } while (0)
0089 
0090 #define FP_PACK_SP(val,X)       \
0091   do {                  \
0092     _FP_PACK_CANONICAL(S,1,X);      \
0093     if (!FP_INHIBIT_RESULTS)        \
0094       _FP_PACK_RAW_1_P(S,val,X);    \
0095   } while (0)
0096 
0097 #define FP_ISSIGNAN_S(X)        _FP_ISSIGNAN(S,1,X)
0098 #define FP_NEG_S(R,X)           _FP_NEG(S,1,R,X)
0099 #define FP_ADD_S(R,X,Y)         _FP_ADD(S,1,R,X,Y)
0100 #define FP_SUB_S(R,X,Y)         _FP_SUB(S,1,R,X,Y)
0101 #define FP_MUL_S(R,X,Y)         _FP_MUL(S,1,R,X,Y)
0102 #define FP_DIV_S(R,X,Y)         _FP_DIV(S,1,R,X,Y)
0103 #define FP_SQRT_S(R,X)          _FP_SQRT(S,1,R,X)
0104 #define _FP_SQRT_MEAT_S(R,S,T,X,Q)  _FP_SQRT_MEAT_1(R,S,T,X,Q)
0105 
0106 #define FP_CMP_S(r,X,Y,un)  _FP_CMP(S,1,r,X,Y,un)
0107 #define FP_CMP_EQ_S(r,X,Y)  _FP_CMP_EQ(S,1,r,X,Y)
0108 
0109 #define FP_TO_INT_S(r,X,rsz,rsg)    _FP_TO_INT(S,1,r,X,rsz,rsg)
0110 #define FP_TO_INT_ROUND_S(r,X,rsz,rsg)  _FP_TO_INT_ROUND(S,1,r,X,rsz,rsg)
0111 #define FP_FROM_INT_S(X,r,rs,rt)    _FP_FROM_INT(S,1,X,r,rs,rt)
0112 
0113 #define _FP_FRAC_HIGH_S(X)  _FP_FRAC_HIGH_1(X)
0114 #define _FP_FRAC_HIGH_RAW_S(X)  _FP_FRAC_HIGH_1(X)
0115 
0116 #endif /* __MATH_EMU_SINGLE_H__ */