Back to home page

OSCL-LXR

 
 

    


0001 /* Software floating-point emulation.
0002    Definitions for IEEE Double 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_DOUBLE_H__
0026 #define    __MATH_EMU_DOUBLE_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 #if _FP_W_TYPE_SIZE < 64
0033 #define _FP_FRACTBITS_D     (2 * _FP_W_TYPE_SIZE)
0034 #else
0035 #define _FP_FRACTBITS_D     _FP_W_TYPE_SIZE
0036 #endif
0037 
0038 #define _FP_FRACBITS_D      53
0039 #define _FP_FRACXBITS_D     (_FP_FRACTBITS_D - _FP_FRACBITS_D)
0040 #define _FP_WFRACBITS_D     (_FP_WORKBITS + _FP_FRACBITS_D)
0041 #define _FP_WFRACXBITS_D    (_FP_FRACTBITS_D - _FP_WFRACBITS_D)
0042 #define _FP_EXPBITS_D       11
0043 #define _FP_EXPBIAS_D       1023
0044 #define _FP_EXPMAX_D        2047
0045 
0046 #define _FP_QNANBIT_D       \
0047     ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-2) % _FP_W_TYPE_SIZE)
0048 #define _FP_IMPLBIT_D       \
0049     ((_FP_W_TYPE)1 << (_FP_FRACBITS_D-1) % _FP_W_TYPE_SIZE)
0050 #define _FP_OVERFLOW_D      \
0051     ((_FP_W_TYPE)1 << _FP_WFRACBITS_D % _FP_W_TYPE_SIZE)
0052 
0053 #if _FP_W_TYPE_SIZE < 64
0054 
0055 union _FP_UNION_D
0056 {
0057   double flt;
0058   struct {
0059 #if __BYTE_ORDER == __BIG_ENDIAN
0060     unsigned sign  : 1;
0061     unsigned exp   : _FP_EXPBITS_D;
0062     unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
0063     unsigned frac0 : _FP_W_TYPE_SIZE;
0064 #else
0065     unsigned frac0 : _FP_W_TYPE_SIZE;
0066     unsigned frac1 : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0) - _FP_W_TYPE_SIZE;
0067     unsigned exp   : _FP_EXPBITS_D;
0068     unsigned sign  : 1;
0069 #endif
0070   } bits __attribute__((packed));
0071 };
0072 
0073 #define FP_DECL_D(X)        _FP_DECL(2,X)
0074 #define FP_UNPACK_RAW_D(X,val)  _FP_UNPACK_RAW_2(D,X,val)
0075 #define FP_UNPACK_RAW_DP(X,val) _FP_UNPACK_RAW_2_P(D,X,val)
0076 #define FP_PACK_RAW_D(val,X)    _FP_PACK_RAW_2(D,val,X)
0077 #define FP_PACK_RAW_DP(val,X)       \
0078   do {                  \
0079     if (!FP_INHIBIT_RESULTS)        \
0080       _FP_PACK_RAW_2_P(D,val,X);    \
0081   } while (0)
0082 
0083 #define FP_UNPACK_D(X,val)      \
0084   do {                  \
0085     _FP_UNPACK_RAW_2(D,X,val);      \
0086     _FP_UNPACK_CANONICAL(D,2,X);    \
0087   } while (0)
0088 
0089 #define FP_UNPACK_DP(X,val)     \
0090   do {                  \
0091     _FP_UNPACK_RAW_2_P(D,X,val);    \
0092     _FP_UNPACK_CANONICAL(D,2,X);    \
0093   } while (0)
0094 
0095 #define FP_PACK_D(val,X)        \
0096   do {                  \
0097     _FP_PACK_CANONICAL(D,2,X);      \
0098     _FP_PACK_RAW_2(D,val,X);        \
0099   } while (0)
0100 
0101 #define FP_PACK_DP(val,X)       \
0102   do {                  \
0103     _FP_PACK_CANONICAL(D,2,X);      \
0104     if (!FP_INHIBIT_RESULTS)        \
0105       _FP_PACK_RAW_2_P(D,val,X);    \
0106   } while (0)
0107 
0108 #define FP_ISSIGNAN_D(X)        _FP_ISSIGNAN(D,2,X)
0109 #define FP_NEG_D(R,X)           _FP_NEG(D,2,R,X)
0110 #define FP_ADD_D(R,X,Y)         _FP_ADD(D,2,R,X,Y)
0111 #define FP_SUB_D(R,X,Y)         _FP_SUB(D,2,R,X,Y)
0112 #define FP_MUL_D(R,X,Y)         _FP_MUL(D,2,R,X,Y)
0113 #define FP_DIV_D(R,X,Y)         _FP_DIV(D,2,R,X,Y)
0114 #define FP_SQRT_D(R,X)          _FP_SQRT(D,2,R,X)
0115 #define _FP_SQRT_MEAT_D(R,S,T,X,Q)  _FP_SQRT_MEAT_2(R,S,T,X,Q)
0116 
0117 #define FP_CMP_D(r,X,Y,un)  _FP_CMP(D,2,r,X,Y,un)
0118 #define FP_CMP_EQ_D(r,X,Y)  _FP_CMP_EQ(D,2,r,X,Y)
0119 
0120 #define FP_TO_INT_D(r,X,rsz,rsg)    _FP_TO_INT(D,2,r,X,rsz,rsg)
0121 #define FP_TO_INT_ROUND_D(r,X,rsz,rsg)  _FP_TO_INT_ROUND(D,2,r,X,rsz,rsg)
0122 #define FP_FROM_INT_D(X,r,rs,rt)    _FP_FROM_INT(D,2,X,r,rs,rt)
0123 
0124 #define _FP_FRAC_HIGH_D(X)  _FP_FRAC_HIGH_2(X)
0125 #define _FP_FRAC_HIGH_RAW_D(X)  _FP_FRAC_HIGH_2(X)
0126 
0127 #else
0128 
0129 union _FP_UNION_D
0130 {
0131   double flt;
0132   struct {
0133 #if __BYTE_ORDER == __BIG_ENDIAN
0134     unsigned sign : 1;
0135     unsigned exp  : _FP_EXPBITS_D;
0136     unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
0137 #else
0138     unsigned long frac : _FP_FRACBITS_D - (_FP_IMPLBIT_D != 0);
0139     unsigned exp  : _FP_EXPBITS_D;
0140     unsigned sign : 1;
0141 #endif
0142   } bits __attribute__((packed));
0143 };
0144 
0145 #define FP_DECL_D(X)        _FP_DECL(1,X)
0146 #define FP_UNPACK_RAW_D(X,val)  _FP_UNPACK_RAW_1(D,X,val)
0147 #define FP_UNPACK_RAW_DP(X,val) _FP_UNPACK_RAW_1_P(D,X,val)
0148 #define FP_PACK_RAW_D(val,X)    _FP_PACK_RAW_1(D,val,X)
0149 #define FP_PACK_RAW_DP(val,X)       \
0150   do {                  \
0151     if (!FP_INHIBIT_RESULTS)        \
0152       _FP_PACK_RAW_1_P(D,val,X);    \
0153   } while (0)
0154 
0155 #define FP_UNPACK_D(X,val)      \
0156   do {                  \
0157     _FP_UNPACK_RAW_1(D,X,val);      \
0158     _FP_UNPACK_CANONICAL(D,1,X);    \
0159   } while (0)
0160 
0161 #define FP_UNPACK_DP(X,val)     \
0162   do {                  \
0163     _FP_UNPACK_RAW_1_P(D,X,val);    \
0164     _FP_UNPACK_CANONICAL(D,1,X);    \
0165   } while (0)
0166 
0167 #define FP_PACK_D(val,X)        \
0168   do {                  \
0169     _FP_PACK_CANONICAL(D,1,X);      \
0170     _FP_PACK_RAW_1(D,val,X);        \
0171   } while (0)
0172 
0173 #define FP_PACK_DP(val,X)       \
0174   do {                  \
0175     _FP_PACK_CANONICAL(D,1,X);      \
0176     if (!FP_INHIBIT_RESULTS)        \
0177       _FP_PACK_RAW_1_P(D,val,X);    \
0178   } while (0)
0179 
0180 #define FP_ISSIGNAN_D(X)        _FP_ISSIGNAN(D,1,X)
0181 #define FP_NEG_D(R,X)           _FP_NEG(D,1,R,X)
0182 #define FP_ADD_D(R,X,Y)         _FP_ADD(D,1,R,X,Y)
0183 #define FP_SUB_D(R,X,Y)         _FP_SUB(D,1,R,X,Y)
0184 #define FP_MUL_D(R,X,Y)         _FP_MUL(D,1,R,X,Y)
0185 #define FP_DIV_D(R,X,Y)         _FP_DIV(D,1,R,X,Y)
0186 #define FP_SQRT_D(R,X)          _FP_SQRT(D,1,R,X)
0187 #define _FP_SQRT_MEAT_D(R,S,T,X,Q)  _FP_SQRT_MEAT_1(R,S,T,X,Q)
0188 
0189 /* The implementation of _FP_MUL_D and _FP_DIV_D should be chosen by
0190    the target machine.  */
0191 
0192 #define FP_CMP_D(r,X,Y,un)  _FP_CMP(D,1,r,X,Y,un)
0193 #define FP_CMP_EQ_D(r,X,Y)  _FP_CMP_EQ(D,1,r,X,Y)
0194 
0195 #define FP_TO_INT_D(r,X,rsz,rsg)    _FP_TO_INT(D,1,r,X,rsz,rsg)
0196 #define FP_TO_INT_ROUND_D(r,X,rsz,rsg)  _FP_TO_INT_ROUND(D,1,r,X,rsz,rsg)
0197 #define FP_FROM_INT_D(X,r,rs,rt)    _FP_FROM_INT(D,1,X,r,rs,rt)
0198 
0199 #define _FP_FRAC_HIGH_D(X)  _FP_FRAC_HIGH_1(X)
0200 #define _FP_FRAC_HIGH_RAW_D(X)  _FP_FRAC_HIGH_1(X)
0201 
0202 #endif /* W_TYPE_SIZE < 64 */
0203 
0204 
0205 #endif /* __MATH_EMU_DOUBLE_H__ */