sfp-machine.h
上传用户:lgb322
上传日期:2013-02-24
资源大小:30529k
文件大小:5k
源码类别:

嵌入式Linux

开发平台:

Unix_Linux

  1. /* Machine-dependent software floating-point definitions.
  2.    S/390 kernel version.
  3.    Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
  4.    This file is part of the GNU C Library.
  5.    Contributed by Richard Henderson (rth@cygnus.com),
  6.   Jakub Jelinek (jj@ultra.linux.cz),
  7.   David S. Miller (davem@redhat.com) and
  8.   Peter Maydell (pmaydell@chiark.greenend.org.uk).
  9.    The GNU C Library is free software; you can redistribute it and/or
  10.    modify it under the terms of the GNU Library General Public License as
  11.    published by the Free Software Foundation; either version 2 of the
  12.    License, or (at your option) any later version.
  13.    The GNU C Library is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16.    Library General Public License for more details.
  17.    You should have received a copy of the GNU Library General Public
  18.    License along with the GNU C Library; see the file COPYING.LIB.  If
  19.    not, write to the Free Software Foundation, Inc.,
  20.    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  21. #ifndef _SFP_MACHINE_H
  22. #define _SFP_MACHINE_H
  23.    
  24. #include <linux/config.h>
  25. #define _FP_W_TYPE_SIZE 32
  26. #define _FP_W_TYPE unsigned long
  27. #define _FP_WS_TYPE signed long
  28. #define _FP_I_TYPE long
  29. #define _FP_MUL_MEAT_S(R,X,Y)
  30.   _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm)
  31. #define _FP_MUL_MEAT_D(R,X,Y)
  32.   _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
  33. #define _FP_MUL_MEAT_Q(R,X,Y)
  34.   _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
  35. #define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_udiv(S,R,X,Y)
  36. #define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y)
  37. #define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y)
  38. #define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1)
  39. #define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1
  40. #define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1
  41. #define _FP_NANSIGN_S 0
  42. #define _FP_NANSIGN_D 0
  43. #define _FP_NANSIGN_Q 0
  44. #define _FP_KEEPNANFRACP 1
  45. /*
  46.  * If one NaN is signaling and the other is not,
  47.  * we choose that one, otherwise we choose X.
  48.  */
  49. #define _FP_CHOOSENAN(fs, wc, R, X, Y, OP)                      
  50.   do {                                                          
  51.     if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs)          
  52.         && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs))     
  53.       {                                                         
  54.         R##_s = Y##_s;                                          
  55.         _FP_FRAC_COPY_##wc(R,Y);                                
  56.       }                                                         
  57.     else                                                        
  58.       {                                                         
  59.         R##_s = X##_s;                                          
  60.         _FP_FRAC_COPY_##wc(R,X);                                
  61.       }                                                         
  62.     R##_c = FP_CLS_NAN;                                         
  63.   } while (0)
  64. /* Some assembly to speed things up. */
  65. #define __FP_FRAC_ADD_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) ({
  66. unsigned int __r2 = (x2) + (y2);
  67. unsigned int __r1 = (x1);
  68. unsigned int __r0 = (x0);
  69. __asm__ ("   alr %2,%3n"
  70.  "   brc 12,0fn"
  71.  "   lhi 0,1n"
  72.  "   alr %1,0n"
  73.  "   brc 12,0fn"
  74.  "   alr %0,0n"
  75.  "0:"
  76.  : "+&d" (__r2), "+&d" (__r1), "+&d" (__r0)
  77.  : "d" (y0), "i" (1) : "cc", "0" );
  78. __asm__ ("   alr %1,%2n"
  79.  "   brc 12,0fn"
  80.  "   ahi %0,1n"
  81.  "0:"
  82.  : "+&d" (__r2), "+&d" (__r1)
  83.  : "d" (y1) : "cc" );
  84. (r2) = __r2;
  85. (r1) = __r1;
  86. (r0) = __r0;
  87. })
  88. #define __FP_FRAC_SUB_3(r2,r1,r0,x2,x1,x0,y2,y1,y0) ({
  89. unsigned int __r2 = (x2) - (y2);
  90. unsigned int __r1 = (x1);
  91. unsigned int __r0 = (x0);
  92. __asm__ ("   slr %2,%3n"
  93.  "   brc 3,0fn"
  94.  "   lhi 0,1n"
  95.  "   slr %1,0n"
  96.  "   brc 3,0fn"
  97.  "   slr %0,0n"
  98.  "0:"
  99.  : "+&d" (__r2), "+&d" (__r1), "+&d" (__r0)
  100.  : "d" (y0) : "cc", "0" );
  101. __asm__ ("   slr %1,%2n"
  102.  "   brc 3,0fn"
  103.  "   ahi %0,-1n"
  104.  "0:"
  105.  : "+&d" (__r2), "+&d" (__r1)
  106.  : "d" (y1) : "cc" );
  107. (r2) = __r2;
  108. (r1) = __r1;
  109. (r0) = __r0;
  110. })
  111. #define __FP_FRAC_DEC_3(x2,x1,x0,y2,y1,y0) __FP_FRAC_SUB_3(x2,x1,x0,x2,x1,x0,y2,y1,y0)
  112. /* Obtain the current rounding mode. */
  113. #define FP_ROUNDMODE mode
  114. /* Exception flags. */
  115. #define FP_EX_INVALID 0x800000
  116. #define FP_EX_DIVZERO 0x400000
  117. #define FP_EX_OVERFLOW 0x200000
  118. #define FP_EX_UNDERFLOW 0x100000
  119. #define FP_EX_INEXACT 0x080000
  120. /* We write the results always */
  121. #define FP_INHIBIT_RESULTS 0
  122. #endif