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

TOMOYO Linux Cross Reference
Linux/arch/parisc/include/asm/bitops.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.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /arch/parisc/include/asm/bitops.h (Architecture sparc64) and /arch/ppc/include/asm-ppc/bitops.h (Architecture ppc)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2 #ifndef _PARISC_BITOPS_H                          
  3 #define _PARISC_BITOPS_H                          
  4                                                   
  5 #ifndef _LINUX_BITOPS_H                           
  6 #error only <linux/bitops.h> can be included d    
  7 #endif                                            
  8                                                   
  9 #include <linux/compiler.h>                       
 10 #include <asm/types.h>                            
 11 #include <asm/byteorder.h>                        
 12 #include <asm/barrier.h>                          
 13 #include <linux/atomic.h>                         
 14                                                   
 15 /* See http://marc.theaimsgroup.com/?t=1088266    
 16  * on use of volatile and __*_bit() (set/clear    
 17  *      *_bit() want use of volatile.             
 18  *      __*_bit() are "relaxed" and don't use     
 19  */                                               
 20                                                   
 21 static __inline__ void set_bit(int nr, volatil    
 22 {                                                 
 23         unsigned long mask = BIT_MASK(nr);        
 24         unsigned long flags;                      
 25                                                   
 26         addr += BIT_WORD(nr);                     
 27         _atomic_spin_lock_irqsave(addr, flags)    
 28         *addr |= mask;                            
 29         _atomic_spin_unlock_irqrestore(addr, f    
 30 }                                                 
 31                                                   
 32 static __inline__ void clear_bit(int nr, volat    
 33 {                                                 
 34         unsigned long mask = BIT_MASK(nr);        
 35         unsigned long flags;                      
 36                                                   
 37         addr += BIT_WORD(nr);                     
 38         _atomic_spin_lock_irqsave(addr, flags)    
 39         *addr &= ~mask;                           
 40         _atomic_spin_unlock_irqrestore(addr, f    
 41 }                                                 
 42                                                   
 43 static __inline__ void change_bit(int nr, vola    
 44 {                                                 
 45         unsigned long mask = BIT_MASK(nr);        
 46         unsigned long flags;                      
 47                                                   
 48         addr += BIT_WORD(nr);                     
 49         _atomic_spin_lock_irqsave(addr, flags)    
 50         *addr ^= mask;                            
 51         _atomic_spin_unlock_irqrestore(addr, f    
 52 }                                                 
 53                                                   
 54 static __inline__ int test_and_set_bit(int nr,    
 55 {                                                 
 56         unsigned long mask = BIT_MASK(nr);        
 57         unsigned long old;                        
 58         unsigned long flags;                      
 59         int set;                                  
 60                                                   
 61         addr += BIT_WORD(nr);                     
 62         _atomic_spin_lock_irqsave(addr, flags)    
 63         old = *addr;                              
 64         set = (old & mask) ? 1 : 0;               
 65         if (!set)                                 
 66                 *addr = old | mask;               
 67         _atomic_spin_unlock_irqrestore(addr, f    
 68                                                   
 69         return set;                               
 70 }                                                 
 71                                                   
 72 static __inline__ int test_and_clear_bit(int n    
 73 {                                                 
 74         unsigned long mask = BIT_MASK(nr);        
 75         unsigned long old;                        
 76         unsigned long flags;                      
 77         int set;                                  
 78                                                   
 79         addr += BIT_WORD(nr);                     
 80         _atomic_spin_lock_irqsave(addr, flags)    
 81         old = *addr;                              
 82         set = (old & mask) ? 1 : 0;               
 83         if (set)                                  
 84                 *addr = old & ~mask;              
 85         _atomic_spin_unlock_irqrestore(addr, f    
 86                                                   
 87         return set;                               
 88 }                                                 
 89                                                   
 90 static __inline__ int test_and_change_bit(int     
 91 {                                                 
 92         unsigned long mask = BIT_MASK(nr);        
 93         unsigned long oldbit;                     
 94         unsigned long flags;                      
 95                                                   
 96         addr += BIT_WORD(nr);                     
 97         _atomic_spin_lock_irqsave(addr, flags)    
 98         oldbit = *addr;                           
 99         *addr = oldbit ^ mask;                    
100         _atomic_spin_unlock_irqrestore(addr, f    
101                                                   
102         return (oldbit & mask) ? 1 : 0;           
103 }                                                 
104                                                   
105 #include <asm-generic/bitops/non-atomic.h>        
106                                                   
107 /**                                               
108  * __ffs - find first bit in word. returns 0 t    
109  * @word: The word to search                      
110  *                                                
111  * __ffs() return is undefined if no bit is se    
112  *                                                
113  * 32-bit fast __ffs by LaMont Jones "lamont A    
114  * 64-bit enhancement by Grant Grundler "grund    
115  * (with help from willy/jejb to get the seman    
116  *                                                
117  * This algorithm avoids branches by making us    
118  * One side effect of "extr" instructions is i    
119  * How PSW[N] (nullify next insn) gets set is     
120  * "condition" field (eg "<>" or "TR" below) i    
121  * Only the 1st and one of either the 2cd or 3    
122  * Each set of 3 insn will get executed in 2 c    
123  * cycles for each mispredicted branch.           
124  */                                               
125                                                   
126 static __inline__ unsigned long __ffs(unsigned    
127 {                                                 
128         unsigned long ret;                        
129                                                   
130         __asm__(                                  
131 #ifdef CONFIG_64BIT                               
132                 " ldi       63,%1\n"              
133                 " extrd,u,*<>  %0,63,32,%%r0\n    
134                 " extrd,u,*TR  %0,31,32,%0\n"     
135                 " addi    -32,%1,%1\n"            
136 #else                                             
137                 " ldi       31,%1\n"              
138 #endif                                            
139                 " extru,<>  %0,31,16,%%r0\n"      
140                 " extru,TR  %0,15,16,%0\n"        
141                 " addi    -16,%1,%1\n"            
142                 " extru,<>  %0,31,8,%%r0\n"       
143                 " extru,TR  %0,23,8,%0\n"         
144                 " addi    -8,%1,%1\n"             
145                 " extru,<>  %0,31,4,%%r0\n"       
146                 " extru,TR  %0,27,4,%0\n"         
147                 " addi    -4,%1,%1\n"             
148                 " extru,<>  %0,31,2,%%r0\n"       
149                 " extru,TR  %0,29,2,%0\n"         
150                 " addi    -2,%1,%1\n"             
151                 " extru,=  %0,31,1,%%r0\n"        
152                 " addi    -1,%1,%1\n"             
153                         : "+r" (x), "=r" (ret)    
154         return ret;                               
155 }                                                 
156                                                   
157 #include <asm-generic/bitops/ffz.h>               
158                                                   
159 /*                                                
160  * ffs: find first bit set. returns 1 to BITS_    
161  * This is defined the same way as the libc an    
162  * ffs routines, therefore differs in spirit f    
163  */                                               
164 static __inline__ int ffs(int x)                  
165 {                                                 
166         return x ? (__ffs((unsigned long)x) +     
167 }                                                 
168                                                   
169 /*                                                
170  * fls: find last (most significant) bit set.     
171  * fls(0) = 0, fls(1) = 1, fls(0x80000000) = 3    
172  */                                               
173                                                   
174 static __inline__ int fls(unsigned int x)         
175 {                                                 
176         int ret;                                  
177         if (!x)                                   
178                 return 0;                         
179                                                   
180         __asm__(                                  
181         "       ldi             1,%1\n"           
182         "       extru,<>        %0,15,16,%%r0\    
183         "       zdep,TR         %0,15,16,%0\n"    
184         "       addi            16,%1,%1\n"       
185         "       extru,<>        %0,7,8,%%r0\n"    
186         "       zdep,TR         %0,23,24,%0\n"    
187         "       addi            8,%1,%1\n"        
188         "       extru,<>        %0,3,4,%%r0\n"    
189         "       zdep,TR         %0,27,28,%0\n"    
190         "       addi            4,%1,%1\n"        
191         "       extru,<>        %0,1,2,%%r0\n"    
192         "       zdep,TR         %0,29,30,%0\n"    
193         "       addi            2,%1,%1\n"        
194         "       extru,=         %0,0,1,%%r0\n"    
195         "       addi            1,%1,%1\n"        
196                 : "+r" (x), "=r" (ret) );         
197                                                   
198         return ret;                               
199 }                                                 
200                                                   
201 #include <asm-generic/bitops/__fls.h>             
202 #include <asm-generic/bitops/fls64.h>             
203 #include <asm-generic/bitops/hweight.h>           
204 #include <asm-generic/bitops/lock.h>              
205 #include <asm-generic/bitops/sched.h>             
206 #include <asm-generic/bitops/le.h>                
207 #include <asm-generic/bitops/ext2-atomic-setbi    
208                                                   
209 #endif /* _PARISC_BITOPS_H */                     
210                                                   

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