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

TOMOYO Linux Cross Reference
Linux/arch/x86/math-emu/poly_2xm1.c

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 /arch/x86/math-emu/poly_2xm1.c (Version linux-6.12-rc7) and /arch/i386/math-emu/poly_2xm1.c (Version ccs-tools-1.8.9)


** Warning: Cannot open xref database.

  1 // SPDX-License-Identifier: GPL-2.0                 1 
  2 /*--------------------------------------------    
  3  |  poly_2xm1.c                                   
  4  |                                                
  5  | Function to compute 2^x-1 by a polynomial a    
  6  |                                                
  7  | Copyright (C) 1992,1993,1994,1997              
  8  |                  W. Metzenthen, 22 Parker S    
  9  |                  E-mail   billm@suburbia.ne    
 10  |                                                
 11  |                                                
 12  +--------------------------------------------    
 13                                                   
 14 #include "exception.h"                            
 15 #include "reg_constant.h"                         
 16 #include "fpu_emu.h"                              
 17 #include "fpu_system.h"                           
 18 #include "control_w.h"                            
 19 #include "poly.h"                                 
 20                                                   
 21 #define HIPOWER 11                                
 22 static const unsigned long long lterms[HIPOWER    
 23         0x0000000000000000LL,   /* This term d    
 24         0xf5fdeffc162c7543LL,                     
 25         0x1c6b08d704a0bfa6LL,                     
 26         0x0276556df749cc21LL,                     
 27         0x002bb0ffcf14f6b8LL,                     
 28         0x0002861225ef751cLL,                     
 29         0x00001ffcbfcd5422LL,                     
 30         0x00000162c005d5f1LL,                     
 31         0x0000000da96ccb1bLL,                     
 32         0x0000000078d1b897LL,                     
 33         0x000000000422b029LL                      
 34 };                                                
 35                                                   
 36 static const Xsig hiterm = MK_XSIG(0xb17217f7,    
 37                                                   
 38 /* Four slices: 0.0 : 0.25 : 0.50 : 0.75 : 1.0    
 39    These numbers are 2^(1/4), 2^(1/2), and 2^(    
 40  */                                               
 41 static const Xsig shiftterm0 = MK_XSIG(0, 0, 0    
 42 static const Xsig shiftterm1 = MK_XSIG(0x9837f    
 43 static const Xsig shiftterm2 = MK_XSIG(0xb504f    
 44 static const Xsig shiftterm3 = MK_XSIG(0xd744f    
 45                                                   
 46 static const Xsig *shiftterm[] = { &shiftterm0    
 47         &shiftterm2, &shiftterm3                  
 48 };                                                
 49                                                   
 50 /*--- poly_2xm1() ----------------------------    
 51  | Requires st(0) which is TAG_Valid and < 1.     
 52  +--------------------------------------------    
 53 int poly_2xm1(u_char sign, FPU_REG *arg, FPU_R    
 54 {                                                 
 55         long int exponent, shift;                 
 56         unsigned long long Xll;                   
 57         Xsig accumulator, Denom, argSignif;       
 58         u_char tag;                               
 59                                                   
 60         exponent = exponent16(arg);               
 61                                                   
 62 #ifdef PARANOID                                   
 63         if (exponent >= 0) {    /* Don't want     
 64                 /* Number negative, too large,    
 65                 EXCEPTION(EX_INTERNAL | 0x127)    
 66                 return 1;                         
 67         }                                         
 68 #endif /* PARANOID */                             
 69                                                   
 70         argSignif.lsw = 0;                        
 71         XSIG_LL(argSignif) = Xll = significand    
 72                                                   
 73         if (exponent == -1) {                     
 74                 shift = (argSignif.msw & 0x400    
 75                 /* subtract 0.5 or 0.75 */        
 76                 exponent -= 2;                    
 77                 XSIG_LL(argSignif) <<= 2;         
 78                 Xll <<= 2;                        
 79         } else if (exponent == -2) {              
 80                 shift = 1;                        
 81                 /* subtract 0.25 */               
 82                 exponent--;                       
 83                 XSIG_LL(argSignif) <<= 1;         
 84                 Xll <<= 1;                        
 85         } else                                    
 86                 shift = 0;                        
 87                                                   
 88         if (exponent < -2) {                      
 89                 /* Shift the argument right by    
 90                 if (FPU_shrx(&Xll, -2 - expone    
 91                         Xll++;  /* round up */    
 92         }                                         
 93                                                   
 94         accumulator.lsw = accumulator.midw = a    
 95         polynomial_Xsig(&accumulator, &Xll, lt    
 96         mul_Xsig_Xsig(&accumulator, &argSignif    
 97         shr_Xsig(&accumulator, 3);                
 98                                                   
 99         mul_Xsig_Xsig(&argSignif, &hiterm);       
100         add_two_Xsig(&accumulator, &argSignif,    
101                                                   
102         if (shift) {                              
103                 /* The argument is large, use     
104                    f(x+a) = f(a) * (f(x) + 1)     
105                  */                               
106                 shr_Xsig(&accumulator, -expone    
107                 accumulator.msw |= 0x80000000;    
108                 mul_Xsig_Xsig(&accumulator, sh    
109                 accumulator.msw &= 0x3fffffff;    
110                 exponent = 1;                     
111         }                                         
112                                                   
113         if (sign != SIGN_POS) {                   
114                 /* The argument is negative, u    
115                    f(-x) = -f(x) / (1 + f(x))     
116                  */                               
117                 Denom.lsw = accumulator.lsw;      
118                 XSIG_LL(Denom) = XSIG_LL(accum    
119                 if (exponent < 0)                 
120                         shr_Xsig(&Denom, -expo    
121                 else if (exponent > 0) {          
122                         /* exponent must be 1     
123                         XSIG_LL(Denom) <<= 1;     
124                         if (Denom.lsw & 0x8000    
125                                 XSIG_LL(Denom)    
126                         (Denom.lsw) <<= 1;        
127                 }                                 
128                 Denom.msw |= 0x80000000;          
129                 div_Xsig(&accumulator, &Denom,    
130         }                                         
131                                                   
132         /* Convert to 64 bit signed-compatible    
133         exponent += round_Xsig(&accumulator);     
134                                                   
135         result = &st(0);                          
136         significand(result) = XSIG_LL(accumula    
137         setexponent16(result, exponent);          
138                                                   
139         tag = FPU_round(result, 1, 0, FULL_PRE    
140                                                   
141         setsign(result, sign);                    
142         FPU_settag0(tag);                         
143                                                   
144         return 0;                                 
145                                                   
146 }                                                 
147                                                   

~ [ 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