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

TOMOYO Linux Cross Reference
Linux/include/asm-generic/bitops/generic-non-atomic.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 /include/asm-generic/bitops/generic-non-atomic.h (Version linux-6.12-rc7) and /include/asm-alpha/bitops/generic-non-atomic.h (Version linux-4.9.337)


  1 /* SPDX-License-Identifier: GPL-2.0-only */         1 
  2                                                   
  3 #ifndef __ASM_GENERIC_BITOPS_GENERIC_NON_ATOMI    
  4 #define __ASM_GENERIC_BITOPS_GENERIC_NON_ATOMI    
  5                                                   
  6 #include <linux/bits.h>                           
  7 #include <asm/barrier.h>                          
  8                                                   
  9 #ifndef _LINUX_BITOPS_H                           
 10 #error only <linux/bitops.h> can be included d    
 11 #endif                                            
 12                                                   
 13 /*                                                
 14  * Generic definitions for bit operations, sho    
 15  * directly.                                      
 16  */                                               
 17                                                   
 18 /**                                               
 19  * generic___set_bit - Set a bit in memory        
 20  * @nr: the bit to set                            
 21  * @addr: the address to start counting from      
 22  *                                                
 23  * Unlike set_bit(), this function is non-atom    
 24  * If it's called on the same region of memory    
 25  * may be that only one operation succeeds.       
 26  */                                               
 27 static __always_inline void                       
 28 generic___set_bit(unsigned long nr, volatile u    
 29 {                                                 
 30         unsigned long mask = BIT_MASK(nr);        
 31         unsigned long *p = ((unsigned long *)a    
 32                                                   
 33         *p  |= mask;                              
 34 }                                                 
 35                                                   
 36 static __always_inline void                       
 37 generic___clear_bit(unsigned long nr, volatile    
 38 {                                                 
 39         unsigned long mask = BIT_MASK(nr);        
 40         unsigned long *p = ((unsigned long *)a    
 41                                                   
 42         *p &= ~mask;                              
 43 }                                                 
 44                                                   
 45 /**                                               
 46  * generic___change_bit - Toggle a bit in memo    
 47  * @nr: the bit to change                         
 48  * @addr: the address to start counting from      
 49  *                                                
 50  * Unlike change_bit(), this function is non-a    
 51  * If it's called on the same region of memory    
 52  * may be that only one operation succeeds.       
 53  */                                               
 54 static __always_inline void                       
 55 generic___change_bit(unsigned long nr, volatil    
 56 {                                                 
 57         unsigned long mask = BIT_MASK(nr);        
 58         unsigned long *p = ((unsigned long *)a    
 59                                                   
 60         *p ^= mask;                               
 61 }                                                 
 62                                                   
 63 /**                                               
 64  * generic___test_and_set_bit - Set a bit and     
 65  * @nr: Bit to set                                
 66  * @addr: Address to count from                   
 67  *                                                
 68  * This operation is non-atomic and can be reo    
 69  * If two examples of this operation race, one    
 70  * but actually fail.  You must protect multip    
 71  */                                               
 72 static __always_inline bool                       
 73 generic___test_and_set_bit(unsigned long nr, v    
 74 {                                                 
 75         unsigned long mask = BIT_MASK(nr);        
 76         unsigned long *p = ((unsigned long *)a    
 77         unsigned long old = *p;                   
 78                                                   
 79         *p = old | mask;                          
 80         return (old & mask) != 0;                 
 81 }                                                 
 82                                                   
 83 /**                                               
 84  * generic___test_and_clear_bit - Clear a bit     
 85  * @nr: Bit to clear                              
 86  * @addr: Address to count from                   
 87  *                                                
 88  * This operation is non-atomic and can be reo    
 89  * If two examples of this operation race, one    
 90  * but actually fail.  You must protect multip    
 91  */                                               
 92 static __always_inline bool                       
 93 generic___test_and_clear_bit(unsigned long nr,    
 94 {                                                 
 95         unsigned long mask = BIT_MASK(nr);        
 96         unsigned long *p = ((unsigned long *)a    
 97         unsigned long old = *p;                   
 98                                                   
 99         *p = old & ~mask;                         
100         return (old & mask) != 0;                 
101 }                                                 
102                                                   
103 /* WARNING: non atomic and it can be reordered    
104 static __always_inline bool                       
105 generic___test_and_change_bit(unsigned long nr    
106 {                                                 
107         unsigned long mask = BIT_MASK(nr);        
108         unsigned long *p = ((unsigned long *)a    
109         unsigned long old = *p;                   
110                                                   
111         *p = old ^ mask;                          
112         return (old & mask) != 0;                 
113 }                                                 
114                                                   
115 /**                                               
116  * generic_test_bit - Determine whether a bit     
117  * @nr: bit number to test                        
118  * @addr: Address to start counting from          
119  */                                               
120 static __always_inline bool                       
121 generic_test_bit(unsigned long nr, const volat    
122 {                                                 
123         /*                                        
124          * Unlike the bitops with the '__' pre    
125          * so `volatile` must always stay here    
126          * `Documentation/atomic_bitops.txt` f    
127          */                                       
128         return 1UL & (addr[BIT_WORD(nr)] >> (n    
129 }                                                 
130                                                   
131 /**                                               
132  * generic_test_bit_acquire - Determine, with     
133  * @nr: bit number to test                        
134  * @addr: Address to start counting from          
135  */                                               
136 static __always_inline bool                       
137 generic_test_bit_acquire(unsigned long nr, con    
138 {                                                 
139         unsigned long *p = ((unsigned long *)a    
140         return 1UL & (smp_load_acquire(p) >> (    
141 }                                                 
142                                                   
143 /*                                                
144  * const_*() definitions provide good compile-    
145  * the passed arguments can be resolved at com    
146  */                                               
147 #define const___set_bit                 generi    
148 #define const___clear_bit               generi    
149 #define const___change_bit              generi    
150 #define const___test_and_set_bit        generi    
151 #define const___test_and_clear_bit      generi    
152 #define const___test_and_change_bit     generi    
153 #define const_test_bit_acquire          generi    
154                                                   
155 /**                                               
156  * const_test_bit - Determine whether a bit is    
157  * @nr: bit number to test                        
158  * @addr: Address to start counting from          
159  *                                                
160  * A version of generic_test_bit() which disca    
161  * allow a compiler to optimize code harder. N    
162  * for testing compile-time constants, e.g. by    
163  * directly from "regular" code.                  
164  */                                               
165 static __always_inline bool                       
166 const_test_bit(unsigned long nr, const volatil    
167 {                                                 
168         const unsigned long *p = (const unsign    
169         unsigned long mask = BIT_MASK(nr);        
170         unsigned long val = *p;                   
171                                                   
172         return !!(val & mask);                    
173 }                                                 
174                                                   
175 #endif /* __ASM_GENERIC_BITOPS_GENERIC_NON_ATO    
176                                                   

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