~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/math-emu/op-1.h

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/math-emu/op-1.h (Version linux-6.12-rc7) and /include/math-emu/op-1.h (Version linux-5.18.19)


  1 /* Software floating-point emulation.               1 /* Software floating-point emulation.
  2    Basic one-word fraction declaration and man      2    Basic one-word fraction declaration and manipulation.
  3    Copyright (C) 1997,1998,1999 Free Software       3    Copyright (C) 1997,1998,1999 Free Software Foundation, Inc.
  4    This file is part of the GNU C Library.          4    This file is part of the GNU C Library.
  5    Contributed by Richard Henderson (rth@cygnu      5    Contributed by Richard Henderson (rth@cygnus.com),
  6                   Jakub Jelinek (jj@ultra.linu      6                   Jakub Jelinek (jj@ultra.linux.cz),
  7                   David S. Miller (davem@redha      7                   David S. Miller (davem@redhat.com) and
  8                   Peter Maydell (pmaydell@chia      8                   Peter Maydell (pmaydell@chiark.greenend.org.uk).
  9                                                     9 
 10    The GNU C Library is free software; you can     10    The GNU C Library is free software; you can redistribute it and/or
 11    modify it under the terms of the GNU Librar     11    modify it under the terms of the GNU Library General Public License as
 12    published by the Free Software Foundation;      12    published by the Free Software Foundation; either version 2 of the
 13    License, or (at your option) any later vers     13    License, or (at your option) any later version.
 14                                                    14 
 15    The GNU C Library is distributed in the hop     15    The GNU C Library is distributed in the hope that it will be useful,
 16    but WITHOUT ANY WARRANTY; without even the      16    but WITHOUT ANY WARRANTY; without even the implied warranty of
 17    MERCHANTABILITY or FITNESS FOR A PARTICULAR     17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 18    Library General Public License for more det     18    Library General Public License for more details.
 19                                                    19 
 20    You should have received a copy of the GNU      20    You should have received a copy of the GNU Library General Public
 21    License along with the GNU C Library; see t     21    License along with the GNU C Library; see the file COPYING.LIB.  If
 22    not, write to the Free Software Foundation,     22    not, write to the Free Software Foundation, Inc.,
 23    59 Temple Place - Suite 330, Boston, MA 021     23    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 24                                                    24 
 25 #ifndef    __MATH_EMU_OP_1_H__                     25 #ifndef    __MATH_EMU_OP_1_H__
 26 #define    __MATH_EMU_OP_1_H__                     26 #define    __MATH_EMU_OP_1_H__
 27                                                    27 
 28 #define _FP_FRAC_DECL_1(X)      _FP_W_TYPE X##     28 #define _FP_FRAC_DECL_1(X)      _FP_W_TYPE X##_f=0
 29 #define _FP_FRAC_COPY_1(D,S)    (D##_f = S##_f     29 #define _FP_FRAC_COPY_1(D,S)    (D##_f = S##_f)
 30 #define _FP_FRAC_SET_1(X,I)     (X##_f = I)        30 #define _FP_FRAC_SET_1(X,I)     (X##_f = I)
 31 #define _FP_FRAC_HIGH_1(X)      (X##_f)            31 #define _FP_FRAC_HIGH_1(X)      (X##_f)
 32 #define _FP_FRAC_LOW_1(X)       (X##_f)            32 #define _FP_FRAC_LOW_1(X)       (X##_f)
 33 #define _FP_FRAC_WORD_1(X,w)    (X##_f)            33 #define _FP_FRAC_WORD_1(X,w)    (X##_f)
 34                                                    34 
 35 #define _FP_FRAC_ADDI_1(X,I)    (X##_f += I)       35 #define _FP_FRAC_ADDI_1(X,I)    (X##_f += I)
 36 #define _FP_FRAC_SLL_1(X,N)                        36 #define _FP_FRAC_SLL_1(X,N)                     \
 37   do {                                             37   do {                                          \
 38     if (__builtin_constant_p(N) && (N) == 1)       38     if (__builtin_constant_p(N) && (N) == 1)    \
 39       X##_f += X##_f;                              39       X##_f += X##_f;                           \
 40     else                                           40     else                                        \
 41       X##_f <<= (N);                               41       X##_f <<= (N);                            \
 42   } while (0)                                      42   } while (0)
 43 #define _FP_FRAC_SRL_1(X,N)     (X##_f >>= N)      43 #define _FP_FRAC_SRL_1(X,N)     (X##_f >>= N)
 44                                                    44 
 45 /* Right shift with sticky-lsb.  */                45 /* Right shift with sticky-lsb.  */
 46 #define _FP_FRAC_SRS_1(X,N,sz)  __FP_FRAC_SRS_     46 #define _FP_FRAC_SRS_1(X,N,sz)  __FP_FRAC_SRS_1(X##_f, N, sz)
 47                                                    47 
 48 #define __FP_FRAC_SRS_1(X,N,sz)                    48 #define __FP_FRAC_SRS_1(X,N,sz)                                         \
 49    (X = (X >> (N) | (__builtin_constant_p(N) &     49    (X = (X >> (N) | (__builtin_constant_p(N) && (N) == 1                \
 50                      ? X & 1 : (X << (_FP_W_TY     50                      ? X & 1 : (X << (_FP_W_TYPE_SIZE - (N))) != 0)))
 51                                                    51 
 52 #define _FP_FRAC_ADD_1(R,X,Y)   (R##_f = X##_f     52 #define _FP_FRAC_ADD_1(R,X,Y)   (R##_f = X##_f + Y##_f)
 53 #define _FP_FRAC_SUB_1(R,X,Y)   (R##_f = X##_f     53 #define _FP_FRAC_SUB_1(R,X,Y)   (R##_f = X##_f - Y##_f)
 54 #define _FP_FRAC_DEC_1(X,Y)     (X##_f -= Y##_     54 #define _FP_FRAC_DEC_1(X,Y)     (X##_f -= Y##_f)
 55 #define _FP_FRAC_CLZ_1(z, X)    __FP_CLZ(z, X#     55 #define _FP_FRAC_CLZ_1(z, X)    __FP_CLZ(z, X##_f)
 56                                                    56 
 57 /* Predicates */                                   57 /* Predicates */
 58 #define _FP_FRAC_NEGP_1(X)      ((_FP_WS_TYPE)     58 #define _FP_FRAC_NEGP_1(X)      ((_FP_WS_TYPE)X##_f < 0)
 59 #define _FP_FRAC_ZEROP_1(X)     (X##_f == 0)       59 #define _FP_FRAC_ZEROP_1(X)     (X##_f == 0)
 60 #define _FP_FRAC_OVERP_1(fs,X)  (X##_f & _FP_O     60 #define _FP_FRAC_OVERP_1(fs,X)  (X##_f & _FP_OVERFLOW_##fs)
 61 #define _FP_FRAC_CLEAR_OVERP_1(fs,X)    (X##_f     61 #define _FP_FRAC_CLEAR_OVERP_1(fs,X)    (X##_f &= ~_FP_OVERFLOW_##fs)
 62 #define _FP_FRAC_EQ_1(X, Y)     (X##_f == Y##_     62 #define _FP_FRAC_EQ_1(X, Y)     (X##_f == Y##_f)
 63 #define _FP_FRAC_GE_1(X, Y)     (X##_f >= Y##_     63 #define _FP_FRAC_GE_1(X, Y)     (X##_f >= Y##_f)
 64 #define _FP_FRAC_GT_1(X, Y)     (X##_f > Y##_f     64 #define _FP_FRAC_GT_1(X, Y)     (X##_f > Y##_f)
 65                                                    65 
 66 #define _FP_ZEROFRAC_1          0                  66 #define _FP_ZEROFRAC_1          0
 67 #define _FP_MINFRAC_1           1                  67 #define _FP_MINFRAC_1           1
 68 #define _FP_MAXFRAC_1           (~(_FP_WS_TYPE     68 #define _FP_MAXFRAC_1           (~(_FP_WS_TYPE)0)
 69                                                    69 
 70 /*                                                 70 /*
 71  * Unpack the raw bits of a native fp value.       71  * Unpack the raw bits of a native fp value.  Do not classify or
 72  * normalize the data.                             72  * normalize the data.
 73  */                                                73  */
 74                                                    74 
 75 #define _FP_UNPACK_RAW_1(fs, X, val)               75 #define _FP_UNPACK_RAW_1(fs, X, val)                            \
 76   do {                                             76   do {                                                          \
 77     union _FP_UNION_##fs _flo; _flo.flt = (val     77     union _FP_UNION_##fs _flo; _flo.flt = (val);                \
 78                                                    78                                                                 \
 79     X##_f = _flo.bits.frac;                        79     X##_f = _flo.bits.frac;                                     \
 80     X##_e = _flo.bits.exp;                         80     X##_e = _flo.bits.exp;                                      \
 81     X##_s = _flo.bits.sign;                        81     X##_s = _flo.bits.sign;                                     \
 82   } while (0)                                      82   } while (0)
 83                                                    83 
 84 #define _FP_UNPACK_RAW_1_P(fs, X, val)             84 #define _FP_UNPACK_RAW_1_P(fs, X, val)                          \
 85   do {                                             85   do {                                                          \
 86     union _FP_UNION_##fs *_flo =                   86     union _FP_UNION_##fs *_flo =                                \
 87       (union _FP_UNION_##fs *)(val);               87       (union _FP_UNION_##fs *)(val);                            \
 88                                                    88                                                                 \
 89     X##_f = _flo->bits.frac;                       89     X##_f = _flo->bits.frac;                                    \
 90     X##_e = _flo->bits.exp;                        90     X##_e = _flo->bits.exp;                                     \
 91     X##_s = _flo->bits.sign;                       91     X##_s = _flo->bits.sign;                                    \
 92   } while (0)                                      92   } while (0)
 93                                                    93 
 94 /*                                                 94 /*
 95  * Repack the raw bits of a native fp value.       95  * Repack the raw bits of a native fp value.
 96  */                                                96  */
 97                                                    97 
 98 #define _FP_PACK_RAW_1(fs, val, X)                 98 #define _FP_PACK_RAW_1(fs, val, X)                              \
 99   do {                                             99   do {                                                          \
100     union _FP_UNION_##fs _flo;                    100     union _FP_UNION_##fs _flo;                                  \
101                                                   101                                                                 \
102     _flo.bits.frac = X##_f;                       102     _flo.bits.frac = X##_f;                                     \
103     _flo.bits.exp  = X##_e;                       103     _flo.bits.exp  = X##_e;                                     \
104     _flo.bits.sign = X##_s;                       104     _flo.bits.sign = X##_s;                                     \
105                                                   105                                                                 \
106     (val) = _flo.flt;                             106     (val) = _flo.flt;                                           \
107   } while (0)                                     107   } while (0)
108                                                   108 
109 #define _FP_PACK_RAW_1_P(fs, val, X)              109 #define _FP_PACK_RAW_1_P(fs, val, X)                            \
110   do {                                            110   do {                                                          \
111     union _FP_UNION_##fs *_flo =                  111     union _FP_UNION_##fs *_flo =                                \
112       (union _FP_UNION_##fs *)(val);              112       (union _FP_UNION_##fs *)(val);                            \
113                                                   113                                                                 \
114     _flo->bits.frac = X##_f;                      114     _flo->bits.frac = X##_f;                                    \
115     _flo->bits.exp  = X##_e;                      115     _flo->bits.exp  = X##_e;                                    \
116     _flo->bits.sign = X##_s;                      116     _flo->bits.sign = X##_s;                                    \
117   } while (0)                                     117   } while (0)
118                                                   118 
119                                                   119 
120 /*                                                120 /*
121  * Multiplication algorithms:                     121  * Multiplication algorithms:
122  */                                               122  */
123                                                   123 
124 /* Basic.  Assuming the host word size is >= 2    124 /* Basic.  Assuming the host word size is >= 2*FRACBITS, we can do the
125    multiplication immediately.  */                125    multiplication immediately.  */
126                                                   126 
127 #define _FP_MUL_MEAT_1_imm(wfracbits, R, X, Y)    127 #define _FP_MUL_MEAT_1_imm(wfracbits, R, X, Y)                          \
128   do {                                            128   do {                                                                  \
129     R##_f = X##_f * Y##_f;                        129     R##_f = X##_f * Y##_f;                                              \
130     /* Normalize since we know where the msb o    130     /* Normalize since we know where the msb of the multiplicands       \
131        were (bit B), we know that the msb of t    131        were (bit B), we know that the msb of the of the product is      \
132        at either 2B or 2B-1.  */                  132        at either 2B or 2B-1.  */                                        \
133     _FP_FRAC_SRS_1(R, wfracbits-1, 2*wfracbits    133     _FP_FRAC_SRS_1(R, wfracbits-1, 2*wfracbits);                        \
134   } while (0)                                     134   } while (0)
135                                                   135 
136 /* Given a 1W * 1W => 2W primitive, do the ext    136 /* Given a 1W * 1W => 2W primitive, do the extended multiplication.  */
137                                                   137 
138 #define _FP_MUL_MEAT_1_wide(wfracbits, R, X, Y    138 #define _FP_MUL_MEAT_1_wide(wfracbits, R, X, Y, doit)                   \
139   do {                                            139   do {                                                                  \
140     _FP_W_TYPE _Z_f0, _Z_f1;                      140     _FP_W_TYPE _Z_f0, _Z_f1;                                            \
141     doit(_Z_f1, _Z_f0, X##_f, Y##_f);             141     doit(_Z_f1, _Z_f0, X##_f, Y##_f);                                   \
142     /* Normalize since we know where the msb o    142     /* Normalize since we know where the msb of the multiplicands       \
143        were (bit B), we know that the msb of t    143        were (bit B), we know that the msb of the of the product is      \
144        at either 2B or 2B-1.  */                  144        at either 2B or 2B-1.  */                                        \
145     _FP_FRAC_SRS_2(_Z, wfracbits-1, 2*wfracbit    145     _FP_FRAC_SRS_2(_Z, wfracbits-1, 2*wfracbits);                       \
146     R##_f = _Z_f0;                                146     R##_f = _Z_f0;                                                      \
147   } while (0)                                     147   } while (0)
148                                                   148 
149 /* Finally, a simple widening multiply algorit    149 /* Finally, a simple widening multiply algorithm.  What fun!  */
150                                                   150 
151 #define _FP_MUL_MEAT_1_hard(wfracbits, R, X, Y    151 #define _FP_MUL_MEAT_1_hard(wfracbits, R, X, Y)                         \
152   do {                                            152   do {                                                                  \
153     _FP_W_TYPE _xh, _xl, _yh, _yl, _z_f0, _z_f    153     _FP_W_TYPE _xh, _xl, _yh, _yl, _z_f0, _z_f1, _a_f0, _a_f1;          \
154                                                   154                                                                         \
155     /* split the words in half */                 155     /* split the words in half */                                       \
156     _xh = X##_f >> (_FP_W_TYPE_SIZE/2);           156     _xh = X##_f >> (_FP_W_TYPE_SIZE/2);                                 \
157     _xl = X##_f & (((_FP_W_TYPE)1 << (_FP_W_TY    157     _xl = X##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1);         \
158     _yh = Y##_f >> (_FP_W_TYPE_SIZE/2);           158     _yh = Y##_f >> (_FP_W_TYPE_SIZE/2);                                 \
159     _yl = Y##_f & (((_FP_W_TYPE)1 << (_FP_W_TY    159     _yl = Y##_f & (((_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2)) - 1);         \
160                                                   160                                                                         \
161     /* multiply the pieces */                     161     /* multiply the pieces */                                           \
162     _z_f0 = _xl * _yl;                            162     _z_f0 = _xl * _yl;                                                  \
163     _a_f0 = _xh * _yl;                            163     _a_f0 = _xh * _yl;                                                  \
164     _a_f1 = _xl * _yh;                            164     _a_f1 = _xl * _yh;                                                  \
165     _z_f1 = _xh * _yh;                            165     _z_f1 = _xh * _yh;                                                  \
166                                                   166                                                                         \
167     /* reassemble into two full words */          167     /* reassemble into two full words */                                \
168     if ((_a_f0 += _a_f1) < _a_f1)                 168     if ((_a_f0 += _a_f1) < _a_f1)                                       \
169       _z_f1 += (_FP_W_TYPE)1 << (_FP_W_TYPE_SI    169       _z_f1 += (_FP_W_TYPE)1 << (_FP_W_TYPE_SIZE/2);                    \
170     _a_f1 = _a_f0 >> (_FP_W_TYPE_SIZE/2);         170     _a_f1 = _a_f0 >> (_FP_W_TYPE_SIZE/2);                               \
171     _a_f0 = _a_f0 << (_FP_W_TYPE_SIZE/2);         171     _a_f0 = _a_f0 << (_FP_W_TYPE_SIZE/2);                               \
172     _FP_FRAC_ADD_2(_z, _z, _a);                   172     _FP_FRAC_ADD_2(_z, _z, _a);                                         \
173                                                   173                                                                         \
174     /* normalize */                               174     /* normalize */                                                     \
175     _FP_FRAC_SRS_2(_z, wfracbits - 1, 2*wfracb    175     _FP_FRAC_SRS_2(_z, wfracbits - 1, 2*wfracbits);                     \
176     R##_f = _z_f0;                                176     R##_f = _z_f0;                                                      \
177   } while (0)                                     177   } while (0)
178                                                   178 
179                                                   179 
180 /*                                                180 /*
181  * Division algorithms:                           181  * Division algorithms:
182  */                                               182  */
183                                                   183 
184 /* Basic.  Assuming the host word size is >= 2    184 /* Basic.  Assuming the host word size is >= 2*FRACBITS, we can do the
185    division immediately.  Give this macro eith    185    division immediately.  Give this macro either _FP_DIV_HELP_imm for
186    C primitives or _FP_DIV_HELP_ldiv for the I    186    C primitives or _FP_DIV_HELP_ldiv for the ISO function.  Which you
187    choose will depend on what the compiler doe    187    choose will depend on what the compiler does with divrem4.  */
188                                                   188 
189 #define _FP_DIV_MEAT_1_imm(fs, R, X, Y, doit)     189 #define _FP_DIV_MEAT_1_imm(fs, R, X, Y, doit)           \
190   do {                                            190   do {                                                  \
191     _FP_W_TYPE _q, _r;                            191     _FP_W_TYPE _q, _r;                                  \
192     X##_f <<= (X##_f < Y##_f                      192     X##_f <<= (X##_f < Y##_f                            \
193                ? R##_e--, _FP_WFRACBITS_##fs      193                ? R##_e--, _FP_WFRACBITS_##fs            \
194                : _FP_WFRACBITS_##fs - 1);         194                : _FP_WFRACBITS_##fs - 1);               \
195     doit(_q, _r, X##_f, Y##_f);                   195     doit(_q, _r, X##_f, Y##_f);                         \
196     R##_f = _q | (_r != 0);                       196     R##_f = _q | (_r != 0);                             \
197   } while (0)                                     197   } while (0)
198                                                   198 
199 /* GCC's longlong.h defines a 2W / 1W => (1W,1    199 /* GCC's longlong.h defines a 2W / 1W => (1W,1W) primitive udiv_qrnnd
200    that may be useful in this situation.  This    200    that may be useful in this situation.  This first is for a primitive
201    that requires normalization, the second for    201    that requires normalization, the second for one that does not.  Look
202    for UDIV_NEEDS_NORMALIZATION to tell which     202    for UDIV_NEEDS_NORMALIZATION to tell which your machine needs.  */
203                                                   203 
204 #define _FP_DIV_MEAT_1_udiv_norm(fs, R, X, Y)     204 #define _FP_DIV_MEAT_1_udiv_norm(fs, R, X, Y)                           \
205   do {                                            205   do {                                                                  \
206     _FP_W_TYPE _nh, _nl, _q, _r, _y;              206     _FP_W_TYPE _nh, _nl, _q, _r, _y;                                    \
207                                                   207                                                                         \
208     /* Normalize Y -- i.e. make the most signi    208     /* Normalize Y -- i.e. make the most significant bit set.  */       \
209     _y = Y##_f << _FP_WFRACXBITS_##fs;            209     _y = Y##_f << _FP_WFRACXBITS_##fs;                                  \
210                                                   210                                                                         \
211     /* Shift X op correspondingly high, that i    211     /* Shift X op correspondingly high, that is, up one full word.  */  \
212     if (X##_f < Y##_f)                            212     if (X##_f < Y##_f)                                                  \
213       {                                           213       {                                                                 \
214         R##_e--;                                  214         R##_e--;                                                        \
215         _nl = 0;                                  215         _nl = 0;                                                        \
216         _nh = X##_f;                              216         _nh = X##_f;                                                    \
217       }                                           217       }                                                                 \
218     else                                          218     else                                                                \
219       {                                           219       {                                                                 \
220         _nl = X##_f << (_FP_W_TYPE_SIZE - 1);     220         _nl = X##_f << (_FP_W_TYPE_SIZE - 1);                           \
221         _nh = X##_f >> 1;                         221         _nh = X##_f >> 1;                                               \
222       }                                           222       }                                                                 \
223                                                   223                                                                         \
224     udiv_qrnnd(_q, _r, _nh, _nl, _y);             224     udiv_qrnnd(_q, _r, _nh, _nl, _y);                                   \
225     R##_f = _q | (_r != 0);                       225     R##_f = _q | (_r != 0);                                             \
226   } while (0)                                     226   } while (0)
227                                                   227 
228 #define _FP_DIV_MEAT_1_udiv(fs, R, X, Y)          228 #define _FP_DIV_MEAT_1_udiv(fs, R, X, Y)                \
229   do {                                            229   do {                                                  \
230     _FP_W_TYPE _nh, _nl, _q, _r;                  230     _FP_W_TYPE _nh, _nl, _q, _r;                        \
231     if (X##_f < Y##_f)                            231     if (X##_f < Y##_f)                                  \
232       {                                           232       {                                                 \
233         R##_e--;                                  233         R##_e--;                                        \
234         _nl = X##_f << _FP_WFRACBITS_##fs;        234         _nl = X##_f << _FP_WFRACBITS_##fs;              \
235         _nh = X##_f >> _FP_WFRACXBITS_##fs;       235         _nh = X##_f >> _FP_WFRACXBITS_##fs;             \
236       }                                           236       }                                                 \
237     else                                          237     else                                                \
238       {                                           238       {                                                 \
239         _nl = X##_f << (_FP_WFRACBITS_##fs - 1    239         _nl = X##_f << (_FP_WFRACBITS_##fs - 1);        \
240         _nh = X##_f >> (_FP_WFRACXBITS_##fs +     240         _nh = X##_f >> (_FP_WFRACXBITS_##fs + 1);       \
241       }                                           241       }                                                 \
242     udiv_qrnnd(_q, _r, _nh, _nl, Y##_f);          242     udiv_qrnnd(_q, _r, _nh, _nl, Y##_f);                \
243     R##_f = _q | (_r != 0);                       243     R##_f = _q | (_r != 0);                             \
244   } while (0)                                     244   } while (0)
245                                                   245   
246                                                   246   
247 /*                                                247 /*
248  * Square root algorithms:                        248  * Square root algorithms:
249  * We have just one right now, maybe Newton ap    249  * We have just one right now, maybe Newton approximation
250  * should be added for those machines where di    250  * should be added for those machines where division is fast.
251  */                                               251  */
252                                                   252  
253 #define _FP_SQRT_MEAT_1(R, S, T, X, q)            253 #define _FP_SQRT_MEAT_1(R, S, T, X, q)                  \
254   do {                                            254   do {                                                  \
255     while (q != _FP_WORK_ROUND)                   255     while (q != _FP_WORK_ROUND)                         \
256       {                                           256       {                                                 \
257         T##_f = S##_f + q;                        257         T##_f = S##_f + q;                              \
258         if (T##_f <= X##_f)                       258         if (T##_f <= X##_f)                             \
259           {                                       259           {                                             \
260             S##_f = T##_f + q;                    260             S##_f = T##_f + q;                          \
261             X##_f -= T##_f;                       261             X##_f -= T##_f;                             \
262             R##_f += q;                           262             R##_f += q;                                 \
263           }                                       263           }                                             \
264         _FP_FRAC_SLL_1(X, 1);                     264         _FP_FRAC_SLL_1(X, 1);                           \
265         q >>= 1;                                  265         q >>= 1;                                        \
266       }                                           266       }                                                 \
267     if (X##_f)                                    267     if (X##_f)                                          \
268       {                                           268       {                                                 \
269         if (S##_f < X##_f)                        269         if (S##_f < X##_f)                              \
270           R##_f |= _FP_WORK_ROUND;                270           R##_f |= _FP_WORK_ROUND;                      \
271         R##_f |= _FP_WORK_STICKY;                 271         R##_f |= _FP_WORK_STICKY;                       \
272       }                                           272       }                                                 \
273   } while (0)                                     273   } while (0)
274                                                   274 
275 /*                                                275 /*
276  * Assembly/disassembly for converting to/from    276  * Assembly/disassembly for converting to/from integral types.  
277  * No shifting or overflow handled here.          277  * No shifting or overflow handled here.
278  */                                               278  */
279                                                   279 
280 #define _FP_FRAC_ASSEMBLE_1(r, X, rsize)          280 #define _FP_FRAC_ASSEMBLE_1(r, X, rsize)        (r = X##_f)
281 #define _FP_FRAC_DISASSEMBLE_1(X, r, rsize)       281 #define _FP_FRAC_DISASSEMBLE_1(X, r, rsize)     (X##_f = r)
282                                                   282 
283                                                   283 
284 /*                                                284 /*
285  * Convert FP values between word sizes           285  * Convert FP values between word sizes
286  */                                               286  */
287                                                   287 
288 #define _FP_FRAC_CONV_1_1(dfs, sfs, D, S)         288 #define _FP_FRAC_CONV_1_1(dfs, sfs, D, S)                               \
289   do {                                            289   do {                                                                  \
290     D##_f = S##_f;                                290     D##_f = S##_f;                                                      \
291     if (_FP_WFRACBITS_##sfs > _FP_WFRACBITS_##    291     if (_FP_WFRACBITS_##sfs > _FP_WFRACBITS_##dfs)                      \
292       {                                           292       {                                                                 \
293         if (S##_c != FP_CLS_NAN)                  293         if (S##_c != FP_CLS_NAN)                                        \
294           _FP_FRAC_SRS_1(D, (_FP_WFRACBITS_##s    294           _FP_FRAC_SRS_1(D, (_FP_WFRACBITS_##sfs-_FP_WFRACBITS_##dfs),  \
295                          _FP_WFRACBITS_##sfs);    295                          _FP_WFRACBITS_##sfs);                          \
296         else                                      296         else                                                            \
297           _FP_FRAC_SRL_1(D, (_FP_WFRACBITS_##s    297           _FP_FRAC_SRL_1(D, (_FP_WFRACBITS_##sfs-_FP_WFRACBITS_##dfs)); \
298       }                                           298       }                                                                 \
299     else                                          299     else                                                                \
300       D##_f <<= _FP_WFRACBITS_##dfs - _FP_WFRA    300       D##_f <<= _FP_WFRACBITS_##dfs - _FP_WFRACBITS_##sfs;              \
301   } while (0)                                     301   } while (0)
302                                                   302 
303 #endif /* __MATH_EMU_OP_1_H__ */                  303 #endif /* __MATH_EMU_OP_1_H__ */
304                                                   304 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php