Back to index

glibc  2.9
sfp-machine.h
Go to the documentation of this file.
00001 /* Machine-dependent software floating-point definitions.
00002    Alpha userland IEEE 128-bit version.
00003    Copyright (C) 2004 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) and
00007                 David S. Miller (davem@redhat.com).
00008 
00009    The GNU C Library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Lesser General Public
00011    License as published by the Free Software Foundation; either
00012    version 2.1 of the License, or (at your option) any later version.
00013 
00014    The GNU C Library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Lesser General Public License for more details.
00018 
00019    You should have received a copy of the GNU Lesser General Public
00020    License along with the GNU C Library; if not, write to the Free
00021    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00022    02111-1307 USA.  */
00023 
00024 #include <fenv_libc.h>
00025 
00026 #define _FP_W_TYPE_SIZE            64
00027 #define _FP_W_TYPE          unsigned long
00028 #define _FP_WS_TYPE         signed long
00029 #define _FP_I_TYPE          long
00030 
00031 #define _FP_MUL_MEAT_S(R,X,Y)                                  \
00032   _FP_MUL_MEAT_1_imm(_FP_WFRACBITS_S,R,X,Y)
00033 #define _FP_MUL_MEAT_D(R,X,Y)                                  \
00034   _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
00035 #define _FP_MUL_MEAT_Q(R,X,Y)                                  \
00036   _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
00037 
00038 #define _FP_DIV_MEAT_S(R,X,Y)      _FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
00039 #define _FP_DIV_MEAT_D(R,X,Y)      _FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
00040 #define _FP_DIV_MEAT_Q(R,X,Y)      _FP_DIV_MEAT_2_udiv(Q,R,X,Y)
00041 
00042 #define _FP_NANFRAC_S              ((_FP_QNANBIT_S << 1) - 1)
00043 #define _FP_NANFRAC_D              ((_FP_QNANBIT_D << 1) - 1)
00044 #define _FP_NANFRAC_Q              ((_FP_QNANBIT_Q << 1) - 1), -1
00045 #define _FP_NANSIGN_S              0
00046 #define _FP_NANSIGN_D              0
00047 #define _FP_NANSIGN_Q              0
00048 
00049 #define _FP_KEEPNANFRACP 1
00050 
00051 /* Alpha Architecture Handbook, 4.7.10.4 sez that we should prefer any
00052    type of NaN in Fb, then Fa.  */
00053 #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)                      \
00054   do {                                                          \
00055     R##_s = Y##_s;                                              \
00056     _FP_FRAC_COPY_##wc(R,X);                                    \
00057     R##_c = FP_CLS_NAN;                                         \
00058   } while (0)
00059 
00060 /* Rounding mode settings.  */
00061 #define FP_RND_NEAREST             FE_TONEAREST
00062 #define FP_RND_ZERO         FE_TOWARDZERO
00063 #define FP_RND_PINF         FE_UPWARD
00064 #define FP_RND_MINF         FE_DOWNWARD
00065 
00066 /* Obtain the current rounding mode.  It's given as an argument to
00067    all the Ots functions, with 4 meaning "dynamic".  */
00068 #define FP_ROUNDMODE        _round
00069 
00070 /* Exception flags. */
00071 #define FP_EX_INVALID              FE_INVALID
00072 #define FP_EX_OVERFLOW             FE_OVERFLOW
00073 #define FP_EX_UNDERFLOW            FE_UNDERFLOW
00074 #define FP_EX_DIVZERO              FE_DIVBYZERO
00075 #define FP_EX_INEXACT              FE_INEXACT
00076 
00077 #define FP_INIT_ROUNDMODE                               \
00078 do {                                                    \
00079   if (__builtin_expect (_round == 4, 0))                \
00080     {                                                   \
00081       unsigned long t;                                         \
00082       __asm__ __volatile__("excb; mf_fpcr %0" : "=f"(t));      \
00083       _round = (t >> FPCR_ROUND_SHIFT) & 3;                    \
00084     }                                                   \
00085 } while (0)
00086 
00087 #define FP_HANDLE_EXCEPTIONS                                   \
00088 do {                                                    \
00089   if (__builtin_expect (_fex, 0))                       \
00090     {                                                   \
00091       unsigned long t = __ieee_get_fp_control ();              \
00092       __ieee_set_fp_control (t | _fex);                        \
00093     }                                                   \
00094 } while (0)