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

TOMOYO Linux Cross Reference
Linux/arch/parisc/math-emu/fcnvuf.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ 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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/parisc/math-emu/fcnvuf.c (Version linux-6.11.5) and /arch/m68k/math-emu/fcnvuf.c (Version linux-4.20.17)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 
  2 /*                                                
  3  * Linux/PA-RISC Project (http://www.parisc-li    
  4  *                                                
  5  * Floating-point emulation code                  
  6  *  Copyright (C) 2001 Hewlett-Packard (Paul B    
  7  */                                               
  8 /*                                                
  9  * BEGIN_DESC                                     
 10  *                                                
 11  *  File:                                         
 12  *      @(#)    pa/spmath/fcnvuf.c                
 13  *                                                
 14  *  Purpose:                                      
 15  *      Fixed point to Floating-point Converts    
 16  *                                                
 17  *  External Interfaces:                          
 18  *      dbl_to_dbl_fcnvuf(srcptr,_nullptr,dstp    
 19  *      dbl_to_sgl_fcnvuf(srcptr,_nullptr,dstp    
 20  *      sgl_to_dbl_fcnvuf(srcptr,_nullptr,dstp    
 21  *      sgl_to_sgl_fcnvuf(srcptr,_nullptr,dstp    
 22  *                                                
 23  *  Internal Interfaces:                          
 24  *                                                
 25  *  Theory:                                       
 26  *      <<please update with a overview of the    
 27  *                                                
 28  * END_DESC                                       
 29 */                                                
 30                                                   
 31                                                   
 32 #include "float.h"                                
 33 #include "sgl_float.h"                            
 34 #include "dbl_float.h"                            
 35 #include "cnv_float.h"                            
 36                                                   
 37 /*********************************************    
 38  *  Fixed point to Floating-point Converts        
 39  *********************************************    
 40                                                   
 41 /*                                                
 42  *  Convert Single Unsigned Fixed to Single Fl    
 43  */                                               
 44                                                   
 45 int                                               
 46 sgl_to_sgl_fcnvuf(                                
 47                         unsigned int *srcptr,     
 48                         unsigned int *_nullptr    
 49                         sgl_floating_point *ds    
 50                         unsigned int *status)     
 51 {                                                 
 52         register unsigned int src, result = 0;    
 53         register int dst_exponent;                
 54                                                   
 55         src = *srcptr;                            
 56                                                   
 57         /* Check for zero */                      
 58         if (src == 0) {                           
 59                 Sgl_setzero(result);              
 60                 *dstptr = result;                 
 61                 return(NOEXCEPTION);              
 62         }                                         
 63         /*                                        
 64          * Generate exponent and normalized ma    
 65          */                                       
 66         dst_exponent = 16;    /* initialize fo    
 67         /*                                        
 68          * Check word for most significant bit    
 69          * a value in dst_exponent indicating     
 70          * between -1 and 30.                     
 71          */                                       
 72         Find_ms_one_bit(src,dst_exponent);        
 73         /*  left justify source, with msb at b    
 74         src <<= dst_exponent+1;                   
 75         Sgl_set_mantissa(result, src >> SGL_EX    
 76         Sgl_set_exponent(result, 30+SGL_BIAS -    
 77                                                   
 78         /* check for inexact */                   
 79         if (Suint_isinexact_to_sgl(src)) {        
 80                 switch (Rounding_mode()) {        
 81                         case ROUNDPLUS:           
 82                                 Sgl_increment(    
 83                                 break;            
 84                         case ROUNDMINUS: /* ne    
 85                                 break;            
 86                         case ROUNDNEAREST:        
 87                                 Sgl_roundneare    
 88                                 break;            
 89                 }                                 
 90                 if (Is_inexacttrap_enabled())     
 91                         *dstptr = result;         
 92                         return(INEXACTEXCEPTIO    
 93                 }                                 
 94                 else Set_inexactflag();           
 95         }                                         
 96         *dstptr = result;                         
 97         return(NOEXCEPTION);                      
 98 }                                                 
 99                                                   
100 /*                                                
101  *  Single Unsigned Fixed to Double Floating-p    
102  */                                               
103                                                   
104 int                                               
105 sgl_to_dbl_fcnvuf(                                
106                         unsigned int *srcptr,     
107                         unsigned int *_nullptr    
108                         dbl_floating_point *ds    
109                         unsigned int *status)     
110 {                                                 
111         register int dst_exponent;                
112         register unsigned int src, resultp1 =     
113                                                   
114         src = *srcptr;                            
115                                                   
116         /* Check for zero */                      
117         if (src == 0) {                           
118                 Dbl_setzero(resultp1,resultp2)    
119                 Dbl_copytoptr(resultp1,resultp    
120                 return(NOEXCEPTION);              
121         }                                         
122         /*                                        
123          * Generate exponent and normalized ma    
124          */                                       
125         dst_exponent = 16;    /* initialize fo    
126         /*                                        
127          * Check word for most significant bit    
128          * a value in dst_exponent indicating     
129          * between -1 and 30.                     
130          */                                       
131         Find_ms_one_bit(src,dst_exponent);        
132         /*  left justify source, with msb at b    
133         src <<= dst_exponent+1;                   
134         Dbl_set_mantissap1(resultp1, src >> DB    
135         Dbl_set_mantissap2(resultp2, src << (3    
136         Dbl_set_exponent(resultp1, (30+DBL_BIA    
137         Dbl_copytoptr(resultp1,resultp2,dstptr    
138         return(NOEXCEPTION);                      
139 }                                                 
140                                                   
141 /*                                                
142  *  Double Unsigned Fixed to Single Floating-p    
143  */                                               
144                                                   
145 int                                               
146 dbl_to_sgl_fcnvuf(                                
147                         dbl_unsigned *srcptr,     
148                         unsigned int *_nullptr    
149                         sgl_floating_point *ds    
150                         unsigned int *status)     
151 {                                                 
152         int dst_exponent;                         
153         unsigned int srcp1, srcp2, result = 0;    
154                                                   
155         Duint_copyfromptr(srcptr,srcp1,srcp2);    
156                                                   
157         /* Check for zero */                      
158         if (srcp1 == 0 && srcp2 == 0) {           
159                 Sgl_setzero(result);              
160                 *dstptr = result;                 
161                 return(NOEXCEPTION);              
162         }                                         
163         /*                                        
164          * Generate exponent and normalized ma    
165          */                                       
166         dst_exponent = 16;    /* initialize fo    
167         if (srcp1 == 0) {                         
168                 /*                                
169                  * Check word for most signifi    
170                  * a value in dst_exponent ind    
171                  * between -1 and 30.             
172                  */                               
173                 Find_ms_one_bit(srcp2,dst_expo    
174                 /*  left justify source, with     
175                 srcp1 = srcp2 << dst_exponent+    
176                 srcp2 = 0;                        
177                 /*                                
178                  *  since msb set is in second    
179                  *  adjust bit position count     
180                  */                               
181                 dst_exponent += 32;               
182         }                                         
183         else {                                    
184                 /*                                
185                  * Check word for most signifi    
186                  * a value in dst_exponent ind    
187                  * between -1 and 30.             
188                  *                                
189                  */                               
190                 Find_ms_one_bit(srcp1,dst_expo    
191                 /*  left justify source, with     
192                 if (dst_exponent >= 0) {          
193                         Variable_shift_double(    
194                          srcp1);                  
195                         srcp2 <<= dst_exponent    
196                 }                                 
197         }                                         
198         Sgl_set_mantissa(result, srcp1 >> SGL_    
199         Sgl_set_exponent(result, (62+SGL_BIAS)    
200                                                   
201         /* check for inexact */                   
202         if (Duint_isinexact_to_sgl(srcp1,srcp2    
203                 switch (Rounding_mode()) {        
204                         case ROUNDPLUS:           
205                                 Sgl_increment(    
206                                 break;            
207                         case ROUNDMINUS: /* ne    
208                                 break;            
209                         case ROUNDNEAREST:        
210                                 Sgl_roundneare    
211                                 break;            
212                 }                                 
213                 if (Is_inexacttrap_enabled())     
214                         *dstptr = result;         
215                         return(INEXACTEXCEPTIO    
216                 }                                 
217                 else Set_inexactflag();           
218         }                                         
219         *dstptr = result;                         
220         return(NOEXCEPTION);                      
221 }                                                 
222                                                   
223 /*                                                
224  *  Double Unsigned Fixed to Double Floating-p    
225  */                                               
226                                                   
227 int                                               
228 dbl_to_dbl_fcnvuf(                                
229                     dbl_unsigned *srcptr,         
230                     unsigned int *_nullptr,       
231                     dbl_floating_point *dstptr    
232                     unsigned int *status)         
233 {                                                 
234         register int dst_exponent;                
235         register unsigned int srcp1, srcp2, re    
236                                                   
237         Duint_copyfromptr(srcptr,srcp1,srcp2);    
238                                                   
239         /* Check for zero */                      
240         if (srcp1 == 0 && srcp2 ==0) {            
241                 Dbl_setzero(resultp1,resultp2)    
242                 Dbl_copytoptr(resultp1,resultp    
243                 return(NOEXCEPTION);              
244         }                                         
245         /*                                        
246          * Generate exponent and normalized ma    
247          */                                       
248         dst_exponent = 16;    /* initialize fo    
249         if (srcp1 == 0) {                         
250                 /*                                
251                  * Check word for most signifi    
252                  * a value in dst_exponent ind    
253                  * between -1 and 30.             
254                  */                               
255                 Find_ms_one_bit(srcp2,dst_expo    
256                 /*  left justify source, with     
257                 srcp1 = srcp2 << dst_exponent+    
258                 srcp2 = 0;                        
259                 /*                                
260                  *  since msb set is in second    
261                  *  adjust bit position count     
262                  */                               
263                 dst_exponent += 32;               
264         }                                         
265         else {                                    
266                 /*                                
267                  * Check word for most signifi    
268                  * a value in dst_exponent ind    
269                  * between -1 and 30.             
270                  */                               
271                 Find_ms_one_bit(srcp1,dst_expo    
272                 /*  left justify source, with     
273                 if (dst_exponent >= 0) {          
274                         Variable_shift_double(    
275                          srcp1);                  
276                         srcp2 <<= dst_exponent    
277                 }                                 
278         }                                         
279         Dbl_set_mantissap1(resultp1, srcp1 >>     
280         Shiftdouble(srcp1,srcp2,DBL_EXP_LENGTH    
281         Dbl_set_exponent(resultp1, (62+DBL_BIA    
282                                                   
283         /* check for inexact */                   
284         if (Duint_isinexact_to_dbl(srcp2)) {      
285                 switch (Rounding_mode()) {        
286                         case ROUNDPLUS:           
287                                 Dbl_increment(    
288                                 break;            
289                         case ROUNDMINUS: /* ne    
290                                 break;            
291                         case ROUNDNEAREST:        
292                                 Dbl_roundneare    
293                                 resultp2);        
294                                 break;            
295                 }                                 
296                 if (Is_inexacttrap_enabled())     
297                         Dbl_copytoptr(resultp1    
298                         return(INEXACTEXCEPTIO    
299                 }                                 
300                 else Set_inexactflag();           
301         }                                         
302         Dbl_copytoptr(resultp1,resultp2,dstptr    
303         return(NOEXCEPTION);                      
304 }                                                 
305                                                   
306                                                   

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