Back to home page

OSCL-LXR

 
 

    


0001 /* Software floating-point emulation.
0002    Definitions for IEEE Quad 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_QUAD_H__
0026 #define  __MATH_EMU_QUAD_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_Q         (4*_FP_W_TYPE_SIZE)
0034 #else
0035 #define _FP_FRACTBITS_Q     (2*_FP_W_TYPE_SIZE)
0036 #endif
0037 
0038 #define _FP_FRACBITS_Q      113
0039 #define _FP_FRACXBITS_Q     (_FP_FRACTBITS_Q - _FP_FRACBITS_Q)
0040 #define _FP_WFRACBITS_Q     (_FP_WORKBITS + _FP_FRACBITS_Q)
0041 #define _FP_WFRACXBITS_Q    (_FP_FRACTBITS_Q - _FP_WFRACBITS_Q)
0042 #define _FP_EXPBITS_Q       15
0043 #define _FP_EXPBIAS_Q       16383
0044 #define _FP_EXPMAX_Q        32767
0045 
0046 #define _FP_QNANBIT_Q       \
0047     ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-2) % _FP_W_TYPE_SIZE)
0048 #define _FP_IMPLBIT_Q       \
0049     ((_FP_W_TYPE)1 << (_FP_FRACBITS_Q-1) % _FP_W_TYPE_SIZE)
0050 #define _FP_OVERFLOW_Q      \
0051     ((_FP_W_TYPE)1 << (_FP_WFRACBITS_Q % _FP_W_TYPE_SIZE))
0052 
0053 #if _FP_W_TYPE_SIZE < 64
0054 
0055 union _FP_UNION_Q
0056 {
0057    long double flt;
0058    struct 
0059    {
0060 #if __BYTE_ORDER == __BIG_ENDIAN
0061       unsigned sign : 1;
0062       unsigned exp : _FP_EXPBITS_Q;
0063       unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
0064       unsigned long frac2 : _FP_W_TYPE_SIZE;
0065       unsigned long frac1 : _FP_W_TYPE_SIZE;
0066       unsigned long frac0 : _FP_W_TYPE_SIZE;
0067 #else
0068       unsigned long frac0 : _FP_W_TYPE_SIZE;
0069       unsigned long frac1 : _FP_W_TYPE_SIZE;
0070       unsigned long frac2 : _FP_W_TYPE_SIZE;
0071       unsigned long frac3 : _FP_FRACBITS_Q - (_FP_IMPLBIT_Q != 0)-(_FP_W_TYPE_SIZE * 3);
0072       unsigned exp : _FP_EXPBITS_Q;
0073       unsigned sign : 1;
0074 #endif /* not bigendian */
0075    } bits __attribute__((packed));
0076 };
0077 
0078 
0079 #define FP_DECL_Q(X)        _FP_DECL(4,X)
0080 #define FP_UNPACK_RAW_Q(X,val)  _FP_UNPACK_RAW_4(Q,X,val)
0081 #define FP_UNPACK_RAW_QP(X,val) _FP_UNPACK_RAW_4_P(Q,X,val)
0082 #define FP_PACK_RAW_Q(val,X)    _FP_PACK_RAW_4(Q,val,X)
0083 #define FP_PACK_RAW_QP(val,X)       \
0084   do {                  \
0085     if (!FP_INHIBIT_RESULTS)        \
0086       _FP_PACK_RAW_4_P(Q,val,X);    \
0087   } while (0)
0088 
0089 #define FP_UNPACK_Q(X,val)      \
0090   do {                  \
0091     _FP_UNPACK_RAW_4(Q,X,val);      \
0092     _FP_UNPACK_CANONICAL(Q,4,X);    \
0093   } while (0)
0094 
0095 #define FP_UNPACK_QP(X,val)     \
0096   do {                  \
0097     _FP_UNPACK_RAW_4_P(Q,X,val);    \
0098     _FP_UNPACK_CANONICAL(Q,4,X);    \
0099   } while (0)
0100 
0101 #define FP_PACK_Q(val,X)        \
0102   do {                  \
0103     _FP_PACK_CANONICAL(Q,4,X);      \
0104     _FP_PACK_RAW_4(Q,val,X);        \
0105   } while (0)
0106 
0107 #define FP_PACK_QP(val,X)       \
0108   do {                  \
0109     _FP_PACK_CANONICAL(Q,4,X);      \
0110     if (!FP_INHIBIT_RESULTS)        \
0111       _FP_PACK_RAW_4_P(Q,val,X);    \
0112   } while (0)
0113 
0114 #define FP_ISSIGNAN_Q(X)        _FP_ISSIGNAN(Q,4,X)
0115 #define FP_NEG_Q(R,X)           _FP_NEG(Q,4,R,X)
0116 #define FP_ADD_Q(R,X,Y)         _FP_ADD(Q,4,R,X,Y)
0117 #define FP_SUB_Q(R,X,Y)         _FP_SUB(Q,4,R,X,Y)
0118 #define FP_MUL_Q(R,X,Y)         _FP_MUL(Q,4,R,X,Y)
0119 #define FP_DIV_Q(R,X,Y)         _FP_DIV(Q,4,R,X,Y)
0120 #define FP_SQRT_Q(R,X)          _FP_SQRT(Q,4,R,X)
0121 #define _FP_SQRT_MEAT_Q(R,S,T,X,Q)  _FP_SQRT_MEAT_4(R,S,T,X,Q)
0122 
0123 #define FP_CMP_Q(r,X,Y,un)  _FP_CMP(Q,4,r,X,Y,un)
0124 #define FP_CMP_EQ_Q(r,X,Y)  _FP_CMP_EQ(Q,4,r,X,Y)
0125 
0126 #define FP_TO_INT_Q(r,X,rsz,rsg)    _FP_TO_INT(Q,4,r,X,rsz,rsg)
0127 #define FP_TO_INT_ROUND_Q(r,X,rsz,rsg)  _FP_TO_INT_ROUND(Q,4,r,X,rsz,rsg)
0128 #define FP_FROM_INT_Q(X,r,rs,rt)    _FP_FROM_INT(Q,4,X,r,rs,rt)
0129 
0130 #define _FP_FRAC_HIGH_Q(X)  _FP_FRAC_HIGH_4(X)
0131 #define _FP_FRAC_HIGH_RAW_Q(X)  _FP_FRAC_HIGH_4(X)
0132 
0133 #else   /* not _FP_W_TYPE_SIZE < 64 */
0134 union _FP_UNION_Q
0135 {
0136   long double flt /* __attribute__((mode(TF))) */ ;
0137   struct {
0138 #if __BYTE_ORDER == __BIG_ENDIAN
0139     unsigned sign  : 1;
0140     unsigned exp   : _FP_EXPBITS_Q;
0141     unsigned long frac1 : _FP_FRACBITS_Q-(_FP_IMPLBIT_Q != 0)-_FP_W_TYPE_SIZE;
0142     unsigned long frac0 : _FP_W_TYPE_SIZE;
0143 #else
0144     unsigned long frac0 : _FP_W_TYPE_SIZE;
0145     unsigned long frac1 : _FP_FRACBITS_Q-(_FP_IMPLBIT_Q != 0)-_FP_W_TYPE_SIZE;
0146     unsigned exp   : _FP_EXPBITS_Q;
0147     unsigned sign  : 1;
0148 #endif
0149   } bits;
0150 };
0151 
0152 #define FP_DECL_Q(X)        _FP_DECL(2,X)
0153 #define FP_UNPACK_RAW_Q(X,val)  _FP_UNPACK_RAW_2(Q,X,val)
0154 #define FP_UNPACK_RAW_QP(X,val) _FP_UNPACK_RAW_2_P(Q,X,val)
0155 #define FP_PACK_RAW_Q(val,X)    _FP_PACK_RAW_2(Q,val,X)
0156 #define FP_PACK_RAW_QP(val,X)       \
0157   do {                  \
0158     if (!FP_INHIBIT_RESULTS)        \
0159       _FP_PACK_RAW_2_P(Q,val,X);    \
0160   } while (0)
0161 
0162 #define FP_UNPACK_Q(X,val)      \
0163   do {                  \
0164     _FP_UNPACK_RAW_2(Q,X,val);      \
0165     _FP_UNPACK_CANONICAL(Q,2,X);    \
0166   } while (0)
0167 
0168 #define FP_UNPACK_QP(X,val)     \
0169   do {                  \
0170     _FP_UNPACK_RAW_2_P(Q,X,val);    \
0171     _FP_UNPACK_CANONICAL(Q,2,X);    \
0172   } while (0)
0173 
0174 #define FP_PACK_Q(val,X)        \
0175   do {                  \
0176     _FP_PACK_CANONICAL(Q,2,X);      \
0177     _FP_PACK_RAW_2(Q,val,X);        \
0178   } while (0)
0179 
0180 #define FP_PACK_QP(val,X)       \
0181   do {                  \
0182     _FP_PACK_CANONICAL(Q,2,X);      \
0183     if (!FP_INHIBIT_RESULTS)        \
0184       _FP_PACK_RAW_2_P(Q,val,X);    \
0185   } while (0)
0186 
0187 #define FP_ISSIGNAN_Q(X)        _FP_ISSIGNAN(Q,2,X)
0188 #define FP_NEG_Q(R,X)           _FP_NEG(Q,2,R,X)
0189 #define FP_ADD_Q(R,X,Y)         _FP_ADD(Q,2,R,X,Y)
0190 #define FP_SUB_Q(R,X,Y)         _FP_SUB(Q,2,R,X,Y)
0191 #define FP_MUL_Q(R,X,Y)         _FP_MUL(Q,2,R,X,Y)
0192 #define FP_DIV_Q(R,X,Y)         _FP_DIV(Q,2,R,X,Y)
0193 #define FP_SQRT_Q(R,X)          _FP_SQRT(Q,2,R,X)
0194 #define _FP_SQRT_MEAT_Q(R,S,T,X,Q)  _FP_SQRT_MEAT_2(R,S,T,X,Q)
0195 
0196 #define FP_CMP_Q(r,X,Y,un)  _FP_CMP(Q,2,r,X,Y,un)
0197 #define FP_CMP_EQ_Q(r,X,Y)  _FP_CMP_EQ(Q,2,r,X,Y)
0198 
0199 #define FP_TO_INT_Q(r,X,rsz,rsg)    _FP_TO_INT(Q,2,r,X,rsz,rsg)
0200 #define FP_TO_INT_ROUND_Q(r,X,rsz,rsg)  _FP_TO_INT_ROUND(Q,2,r,X,rsz,rsg)
0201 #define FP_FROM_INT_Q(X,r,rs,rt)    _FP_FROM_INT(Q,2,X,r,rs,rt)
0202 
0203 #define _FP_FRAC_HIGH_Q(X)  _FP_FRAC_HIGH_2(X)
0204 #define _FP_FRAC_HIGH_RAW_Q(X)  _FP_FRAC_HIGH_2(X)
0205 
0206 #endif /* not _FP_W_TYPE_SIZE < 64 */
0207 
0208 #endif /* __MATH_EMU_QUAD_H__ */