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

TOMOYO Linux Cross Reference
Linux/arch/csky/include/asm/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 /arch/csky/include/asm/atomic.h (Architecture mips) and /arch/sparc64/include/asm-sparc64/atomic.h (Architecture sparc64)


  1 /* SPDX-License-Identifier: GPL-2.0 */              1 
  2                                                   
  3 #ifndef __ASM_CSKY_ATOMIC_H                       
  4 #define __ASM_CSKY_ATOMIC_H                       
  5                                                   
  6 #ifdef CONFIG_SMP                                 
  7 #include <asm-generic/atomic64.h>                 
  8                                                   
  9 #include <asm/cmpxchg.h>                          
 10 #include <asm/barrier.h>                          
 11                                                   
 12 #define __atomic_acquire_fence()        __bar_    
 13                                                   
 14 #define __atomic_release_fence()        __bar_    
 15                                                   
 16 static __always_inline int arch_atomic_read(co    
 17 {                                                 
 18         return READ_ONCE(v->counter);             
 19 }                                                 
 20 static __always_inline void arch_atomic_set(at    
 21 {                                                 
 22         WRITE_ONCE(v->counter, i);                
 23 }                                                 
 24                                                   
 25 #define ATOMIC_OP(op)                             
 26 static __always_inline                            
 27 void arch_atomic_##op(int i, atomic_t *v)         
 28 {                                                 
 29         unsigned long tmp;                        
 30         __asm__ __volatile__ (                    
 31         "1:     ldex.w          %0, (%2)          
 32         "       " #op "         %0, %1            
 33         "       stex.w          %0, (%2)          
 34         "       bez             %0, 1b            
 35         : "=&r" (tmp)                             
 36         : "r" (i), "r" (&v->counter)              
 37         : "memory");                              
 38 }                                                 
 39                                                   
 40 ATOMIC_OP(add)                                    
 41 ATOMIC_OP(sub)                                    
 42 ATOMIC_OP(and)                                    
 43 ATOMIC_OP( or)                                    
 44 ATOMIC_OP(xor)                                    
 45                                                   
 46 #undef ATOMIC_OP                                  
 47                                                   
 48 #define ATOMIC_FETCH_OP(op)                       
 49 static __always_inline                            
 50 int arch_atomic_fetch_##op##_relaxed(int i, at    
 51 {                                                 
 52         register int ret, tmp;                    
 53         __asm__ __volatile__ (                    
 54         "1:     ldex.w          %0, (%3) \n"      
 55         "       mov             %1, %0   \n"      
 56         "       " #op "         %0, %2   \n"      
 57         "       stex.w          %0, (%3) \n"      
 58         "       bez             %0, 1b   \n"      
 59                 : "=&r" (tmp), "=&r" (ret)        
 60                 : "r" (i), "r"(&v->counter)       
 61                 : "memory");                      
 62         return ret;                               
 63 }                                                 
 64                                                   
 65 #define ATOMIC_OP_RETURN(op, c_op)                
 66 static __always_inline                            
 67 int arch_atomic_##op##_return_relaxed(int i, a    
 68 {                                                 
 69         return arch_atomic_fetch_##op##_relaxe    
 70 }                                                 
 71                                                   
 72 #define ATOMIC_OPS(op, c_op)                      
 73         ATOMIC_FETCH_OP(op)                       
 74         ATOMIC_OP_RETURN(op, c_op)                
 75                                                   
 76 ATOMIC_OPS(add, +)                                
 77 ATOMIC_OPS(sub, -)                                
 78                                                   
 79 #define arch_atomic_fetch_add_relaxed   arch_a    
 80 #define arch_atomic_fetch_sub_relaxed   arch_a    
 81                                                   
 82 #define arch_atomic_add_return_relaxed  arch_a    
 83 #define arch_atomic_sub_return_relaxed  arch_a    
 84                                                   
 85 #undef ATOMIC_OPS                                 
 86 #undef ATOMIC_OP_RETURN                           
 87                                                   
 88 #define ATOMIC_OPS(op)                            
 89         ATOMIC_FETCH_OP(op)                       
 90                                                   
 91 ATOMIC_OPS(and)                                   
 92 ATOMIC_OPS( or)                                   
 93 ATOMIC_OPS(xor)                                   
 94                                                   
 95 #define arch_atomic_fetch_and_relaxed   arch_a    
 96 #define arch_atomic_fetch_or_relaxed    arch_a    
 97 #define arch_atomic_fetch_xor_relaxed   arch_a    
 98                                                   
 99 #undef ATOMIC_OPS                                 
100                                                   
101 #undef ATOMIC_FETCH_OP                            
102                                                   
103 static __always_inline int                        
104 arch_atomic_fetch_add_unless(atomic_t *v, int     
105 {                                                 
106         int prev, tmp;                            
107                                                   
108         __asm__ __volatile__ (                    
109                 RELEASE_FENCE                     
110                 "1:     ldex.w          %0, (%    
111                 "       cmpne           %0, %4    
112                 "       bf              2f        
113                 "       mov             %1, %0    
114                 "       add             %1, %2    
115                 "       stex.w          %1, (%    
116                 "       bez             %1, 1b    
117                 FULL_FENCE                        
118                 "2:\n"                            
119                 : "=&r" (prev), "=&r" (tmp)       
120                 : "r" (a), "r" (&v->counter),     
121                 : "memory");                      
122                                                   
123         return prev;                              
124 }                                                 
125 #define arch_atomic_fetch_add_unless arch_atom    
126                                                   
127 static __always_inline bool                       
128 arch_atomic_inc_unless_negative(atomic_t *v)      
129 {                                                 
130         int rc, tmp;                              
131                                                   
132         __asm__ __volatile__ (                    
133                 RELEASE_FENCE                     
134                 "1:     ldex.w          %0, (%    
135                 "       movi            %1, 0     
136                 "       blz             %0, 2f    
137                 "       movi            %1, 1     
138                 "       addi            %0, 1     
139                 "       stex.w          %0, (%    
140                 "       bez             %0, 1b    
141                 FULL_FENCE                        
142                 "2:\n"                            
143                 : "=&r" (tmp), "=&r" (rc)         
144                 : "r" (&v->counter)               
145                 : "memory");                      
146                                                   
147         return tmp ? true : false;                
148                                                   
149 }                                                 
150 #define arch_atomic_inc_unless_negative arch_a    
151                                                   
152 static __always_inline bool                       
153 arch_atomic_dec_unless_positive(atomic_t *v)      
154 {                                                 
155         int rc, tmp;                              
156                                                   
157         __asm__ __volatile__ (                    
158                 RELEASE_FENCE                     
159                 "1:     ldex.w          %0, (%    
160                 "       movi            %1, 0     
161                 "       bhz             %0, 2f    
162                 "       movi            %1, 1     
163                 "       subi            %0, 1     
164                 "       stex.w          %0, (%    
165                 "       bez             %0, 1b    
166                 FULL_FENCE                        
167                 "2:\n"                            
168                 : "=&r" (tmp), "=&r" (rc)         
169                 : "r" (&v->counter)               
170                 : "memory");                      
171                                                   
172         return tmp ? true : false;                
173 }                                                 
174 #define arch_atomic_dec_unless_positive arch_a    
175                                                   
176 static __always_inline int                        
177 arch_atomic_dec_if_positive(atomic_t *v)          
178 {                                                 
179         int dec, tmp;                             
180                                                   
181         __asm__ __volatile__ (                    
182                 RELEASE_FENCE                     
183                 "1:     ldex.w          %0, (%    
184                 "       subi            %1, %0    
185                 "       blz             %1, 2f    
186                 "       stex.w          %1, (%    
187                 "       bez             %1, 1b    
188                 FULL_FENCE                        
189                 "2:\n"                            
190                 : "=&r" (dec), "=&r" (tmp)        
191                 : "r" (&v->counter)               
192                 : "memory");                      
193                                                   
194         return dec - 1;                           
195 }                                                 
196 #define arch_atomic_dec_if_positive arch_atomi    
197                                                   
198 #else                                             
199 #include <asm-generic/atomic.h>                   
200 #endif                                            
201                                                   
202 #endif /* __ASM_CSKY_ATOMIC_H */                  
203                                                   

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