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

TOMOYO Linux Cross Reference
Linux/kernel/time/timeconst.bc

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 /kernel/time/timeconst.bc (Version linux-6.11.5) and /kernel/time/timeconst.bc (Version linux-3.10.108)


  1 /* SPDX-License-Identifier: GPL-2.0 */            
  2                                                   
  3 scale=0                                           
  4                                                   
  5 define gcd(a,b) {                                 
  6         auto t;                                   
  7         while (b) {                               
  8                 t = b;                            
  9                 b = a % b;                        
 10                 a = t;                            
 11         }                                         
 12         return a;                                 
 13 }                                                 
 14                                                   
 15 /* Division by reciprocal multiplication. */      
 16 define fmul(b,n,d) {                              
 17        return (2^b*n+d-1)/d;                      
 18 }                                                 
 19                                                   
 20 /* Adjustment factor when a ceiling value is u    
 21    (imul * n) + (fmulxx * n + fadjxx) >> xx) *    
 22 define fadj(b,n,d) {                              
 23         auto v;                                   
 24         d = d/gcd(n,d);                           
 25         v = 2^b*(d-1)/d;                          
 26         return v;                                 
 27 }                                                 
 28                                                   
 29 /* Compute the appropriate mul/adj values as w    
 30    which brings the mul value into the range 2    
 31    a shift value will be correct in the signed    
 32    by at most one in the upper half of the uns    
 33 define fmuls(b,n,d) {                             
 34         auto s, m;                                
 35         for (s = 0; 1; s++) {                     
 36                 m = fmul(s,n,d);                  
 37                 if (m >= 2^(b-1))                 
 38                         return s;                 
 39         }                                         
 40         return 0;                                 
 41 }                                                 
 42                                                   
 43 define timeconst(hz) {                            
 44         print "/* Automatically generated by k    
 45         print "/* Time conversion constants fo    
 46         print "\n"                                
 47                                                   
 48         print "#ifndef KERNEL_TIMECONST_H\n"      
 49         print "#define KERNEL_TIMECONST_H\n\n"    
 50                                                   
 51         print "#include <linux/param.h>\n"        
 52         print "#include <linux/types.h>\n\n"      
 53                                                   
 54         print "#if HZ != ", hz, "\n"              
 55         print "#error \qinclude/generated/time    
 56         print "#endif\n\n"                        
 57                                                   
 58         if (hz < 2) {                             
 59                 print "#error Totally bogus HZ    
 60         } else {                                  
 61                 s=fmuls(32,1000,hz)               
 62                 obase=16                          
 63                 print "#define HZ_TO_MSEC_MUL3    
 64                 print "#define HZ_TO_MSEC_ADJ3    
 65                 obase=10                          
 66                 print "#define HZ_TO_MSEC_SHR3    
 67                                                   
 68                 s=fmuls(32,hz,1000)               
 69                 obase=16                          
 70                 print "#define MSEC_TO_HZ_MUL3    
 71                 print "#define MSEC_TO_HZ_ADJ3    
 72                 obase=10                          
 73                 print "#define MSEC_TO_HZ_SHR3    
 74                                                   
 75                 obase=10                          
 76                 cd=gcd(hz,1000)                   
 77                 print "#define HZ_TO_MSEC_NUM\    
 78                 print "#define HZ_TO_MSEC_DEN\    
 79                 print "#define MSEC_TO_HZ_NUM\    
 80                 print "#define MSEC_TO_HZ_DEN\    
 81                 print "\n"                        
 82                                                   
 83                 s=fmuls(32,1000000,hz)            
 84                 obase=16                          
 85                 print "#define HZ_TO_USEC_MUL3    
 86                 print "#define HZ_TO_USEC_ADJ3    
 87                 obase=10                          
 88                 print "#define HZ_TO_USEC_SHR3    
 89                                                   
 90                 s=fmuls(32,hz,1000000)            
 91                 obase=16                          
 92                 print "#define USEC_TO_HZ_MUL3    
 93                 print "#define USEC_TO_HZ_ADJ3    
 94                 obase=10                          
 95                 print "#define USEC_TO_HZ_SHR3    
 96                                                   
 97                 obase=10                          
 98                 cd=gcd(hz,1000000)                
 99                 print "#define HZ_TO_USEC_NUM\    
100                 print "#define HZ_TO_USEC_DEN\    
101                 print "#define USEC_TO_HZ_NUM\    
102                 print "#define USEC_TO_HZ_DEN\    
103                                                   
104                 cd=gcd(hz,1000000000)             
105                 print "#define HZ_TO_NSEC_NUM\    
106                 print "#define HZ_TO_NSEC_DEN\    
107                 print "#define NSEC_TO_HZ_NUM\    
108                 print "#define NSEC_TO_HZ_DEN\    
109                 print "\n"                        
110                                                   
111                 print "#endif /* KERNEL_TIMECO    
112         }                                         
113         halt                                      
114 }                                                 
115                                                   
116 hz = read();                                      
117 timeconst(hz)                                     
                                                      

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