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

TOMOYO Linux Cross Reference
Linux/arch/mips/include/asm/div64.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 /arch/mips/include/asm/div64.h (Architecture alpha) and /arch/ppc/include/asm-ppc/div64.h (Architecture ppc)


  1 /*                                                  1 
  2  * Copyright (C) 2000, 2004, 2021  Maciej W. R    
  3  * Copyright (C) 2003, 07 Ralf Baechle (ralf@l    
  4  *                                                
  5  * This file is subject to the terms and condi    
  6  * License.  See the file "COPYING" in the mai    
  7  * for more details.                              
  8  */                                               
  9 #ifndef __ASM_DIV64_H                             
 10 #define __ASM_DIV64_H                             
 11                                                   
 12 #include <asm/bitsperlong.h>                      
 13                                                   
 14 #if BITS_PER_LONG == 32                           
 15                                                   
 16 /*                                                
 17  * No traps on overflows for any of these...      
 18  */                                               
 19                                                   
 20 #define do_div64_32(res, high, low, base) ({      
 21         unsigned long __cf, __tmp, __tmp2, __i    
 22         unsigned long __quot32, __mod32;          
 23                                                   
 24         __asm__(                                  
 25         "       .set    push                      
 26         "       .set    noat                      
 27         "       .set    noreorder                 
 28         "       move    %2, $0                    
 29         "       move    %3, $0                    
 30         "       b       1f                        
 31         "        li     %4, 0x21                  
 32         "0:                                       
 33         "       sll     $1, %0, 0x1               
 34         "       srl     %3, %0, 0x1f              
 35         "       or      %0, $1, %5                
 36         "       sll     %1, %1, 0x1               
 37         "       sll     %2, %2, 0x1               
 38         "1:                                       
 39         "       bnez    %3, 2f                    
 40         "        sltu   %5, %0, %z6               
 41         "       bnez    %5, 3f                    
 42         "2:                                       
 43         "        addiu  %4, %4, -1                
 44         "       subu    %0, %0, %z6               
 45         "       addiu   %2, %2, 1                 
 46         "3:                                       
 47         "       bnez    %4, 0b                    
 48         "        srl    %5, %1, 0x1f              
 49         "       .set    pop"                      
 50         : "=&r" (__mod32), "=&r" (__tmp),         
 51           "=&r" (__quot32), "=&r" (__cf),         
 52           "=&r" (__i), "=&r" (__tmp2)             
 53         : "Jr" (base), "" (high), "1" (low));     
 54                                                   
 55         (res) = __quot32;                         
 56         __mod32;                                  
 57 })                                                
 58                                                   
 59 #define __div64_32(n, base) ({                    
 60         unsigned long __upper, __low, __high,     
 61         unsigned long long __quot;                
 62         unsigned long long __div;                 
 63         unsigned long __mod;                      
 64                                                   
 65         __div = (*n);                             
 66         __radix = (base);                         
 67                                                   
 68         __high = __div >> 32;                     
 69         __low = __div;                            
 70                                                   
 71         if (__high < __radix) {                   
 72                 __upper = __high;                 
 73                 __high = 0;                       
 74         } else {                                  
 75                 __upper = __high % __radix;       
 76                 __high /= __radix;                
 77         }                                         
 78                                                   
 79         __mod = do_div64_32(__low, __upper, __    
 80                                                   
 81         __quot = __high;                          
 82         __quot = __quot << 32 | __low;            
 83         (*n) = __quot;                            
 84         __mod;                                    
 85 })                                                
 86                                                   
 87 #endif /* BITS_PER_LONG == 32 */                  
 88                                                   
 89 #include <asm-generic/div64.h>                    
 90                                                   
 91 #endif /* __ASM_DIV64_H */                        
 92                                                   

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