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

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/futex/include/futextest.h

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 /tools/testing/selftests/futex/include/futextest.h (Version linux-6.11.5) and /tools/testing/selftests/futex/include/futextest.h (Version linux-3.10.108)


  1 /* SPDX-License-Identifier: GPL-2.0-or-later *      1 
  2 /*********************************************    
  3  *                                                
  4  *   Copyright © International Business Machi    
  5  *                                                
  6  * DESCRIPTION                                    
  7  *      Glibc independent futex library for te    
  8  *                                                
  9  * AUTHOR                                         
 10  *      Darren Hart <dvhart@linux.intel.com>      
 11  *                                                
 12  * HISTORY                                        
 13  *      2009-Nov-6: Initial version by Darren     
 14  *                                                
 15  *********************************************    
 16                                                   
 17 #ifndef _FUTEXTEST_H                              
 18 #define _FUTEXTEST_H                              
 19                                                   
 20 #include <unistd.h>                               
 21 #include <sys/syscall.h>                          
 22 #include <sys/types.h>                            
 23 #include <linux/futex.h>                          
 24                                                   
 25 typedef volatile u_int32_t futex_t;               
 26 #define FUTEX_INITIALIZER 0                       
 27                                                   
 28 /* Define the newer op codes if the system hea    
 29 #ifndef FUTEX_WAIT_BITSET                         
 30 #define FUTEX_WAIT_BITSET               9         
 31 #endif                                            
 32 #ifndef FUTEX_WAKE_BITSET                         
 33 #define FUTEX_WAKE_BITSET               10        
 34 #endif                                            
 35 #ifndef FUTEX_WAIT_REQUEUE_PI                     
 36 #define FUTEX_WAIT_REQUEUE_PI           11        
 37 #endif                                            
 38 #ifndef FUTEX_CMP_REQUEUE_PI                      
 39 #define FUTEX_CMP_REQUEUE_PI            12        
 40 #endif                                            
 41 #ifndef FUTEX_WAIT_REQUEUE_PI_PRIVATE             
 42 #define FUTEX_WAIT_REQUEUE_PI_PRIVATE   (FUTEX    
 43                                          FUTEX    
 44 #endif                                            
 45 #ifndef FUTEX_REQUEUE_PI_PRIVATE                  
 46 #define FUTEX_CMP_REQUEUE_PI_PRIVATE    (FUTEX    
 47                                          FUTEX    
 48 #endif                                            
 49                                                   
 50 /**                                               
 51  * futex() - SYS_futex syscall wrapper            
 52  * @uaddr:      address of first futex            
 53  * @op:         futex op code                     
 54  * @val:        typically expected value of ua    
 55  * @timeout:    typically an absolute struct t    
 56  *              otherwise). Overloaded by some    
 57  * @uaddr2:     address of second futex for so    
 58  * @val3:       varies by op                      
 59  * @opflags:    flags to be bitwise OR'd with     
 60  *                                                
 61  * futex() is used by all the following futex     
 62  * used for misuse and abuse testing. Generall    
 63  * should be used instead. It is a macro inste    
 64  * some of the types over overloaded (timeout     
 65  * example).                                      
 66  *                                                
 67  * These argument descriptions are the default    
 68  * like-named arguments in the following wrapp    
 69  */                                               
 70 #define futex(uaddr, op, val, timeout, uaddr2,    
 71         syscall(SYS_futex, uaddr, op | opflags    
 72                                                   
 73 /**                                               
 74  * futex_wait() - block on uaddr with optional    
 75  * @timeout:    relative timeout                  
 76  */                                               
 77 static inline int                                 
 78 futex_wait(futex_t *uaddr, futex_t val, struct    
 79 {                                                 
 80         return futex(uaddr, FUTEX_WAIT, val, t    
 81 }                                                 
 82                                                   
 83 /**                                               
 84  * futex_wake() - wake one or more tasks block    
 85  * @nr_wake:    wake up to this many tasks        
 86  */                                               
 87 static inline int                                 
 88 futex_wake(futex_t *uaddr, int nr_wake, int op    
 89 {                                                 
 90         return futex(uaddr, FUTEX_WAKE, nr_wak    
 91 }                                                 
 92                                                   
 93 /**                                               
 94  * futex_wait_bitset() - block on uaddr with b    
 95  * @bitset:     bitset to be used with futex_w    
 96  */                                               
 97 static inline int                                 
 98 futex_wait_bitset(futex_t *uaddr, futex_t val,    
 99                   u_int32_t bitset, int opflag    
100 {                                                 
101         return futex(uaddr, FUTEX_WAIT_BITSET,    
102                      opflags);                    
103 }                                                 
104                                                   
105 /**                                               
106  * futex_wake_bitset() - wake one or more task    
107  * @bitset:     bitset to compare with that us    
108  */                                               
109 static inline int                                 
110 futex_wake_bitset(futex_t *uaddr, int nr_wake,    
111 {                                                 
112         return futex(uaddr, FUTEX_WAKE_BITSET,    
113                      opflags);                    
114 }                                                 
115                                                   
116 /**                                               
117  * futex_lock_pi() - block on uaddr as a PI mu    
118  * @detect:     whether (1) or not (0) to perf    
119  */                                               
120 static inline int                                 
121 futex_lock_pi(futex_t *uaddr, struct timespec     
122               int opflags)                        
123 {                                                 
124         return futex(uaddr, FUTEX_LOCK_PI, det    
125 }                                                 
126                                                   
127 /**                                               
128  * futex_unlock_pi() - release uaddr as a PI m    
129  */                                               
130 static inline int                                 
131 futex_unlock_pi(futex_t *uaddr, int opflags)      
132 {                                                 
133         return futex(uaddr, FUTEX_UNLOCK_PI, 0    
134 }                                                 
135                                                   
136 /**                                               
137  * futex_wake_op() - FIXME: COME UP WITH A GOO    
138  */                                               
139 static inline int                                 
140 futex_wake_op(futex_t *uaddr, futex_t *uaddr2,    
141               int wake_op, int opflags)           
142 {                                                 
143         return futex(uaddr, FUTEX_WAKE_OP, nr_    
144                      opflags);                    
145 }                                                 
146                                                   
147 /**                                               
148  * futex_requeue() - requeue without expected     
149  * @nr_wake:    wake up to this many tasks        
150  * @nr_requeue: requeue up to this many tasks     
151  *                                                
152  * Due to its inherently racy implementation,     
153  * favor of futex_cmp_requeue().                  
154  */                                               
155 static inline int                                 
156 futex_requeue(futex_t *uaddr, futex_t *uaddr2,    
157               int opflags)                        
158 {                                                 
159         return futex(uaddr, FUTEX_REQUEUE, nr_    
160                      opflags);                    
161 }                                                 
162                                                   
163 /**                                               
164  * futex_cmp_requeue() - requeue tasks from ua    
165  * @nr_wake:    wake up to this many tasks        
166  * @nr_requeue: requeue up to this many tasks     
167  */                                               
168 static inline int                                 
169 futex_cmp_requeue(futex_t *uaddr, futex_t val,    
170                   int nr_requeue, int opflags)    
171 {                                                 
172         return futex(uaddr, FUTEX_CMP_REQUEUE,    
173                      val, opflags);               
174 }                                                 
175                                                   
176 /**                                               
177  * futex_wait_requeue_pi() - block on uaddr an    
178  * @uaddr:      non-PI futex source               
179  * @uaddr2:     PI futex target                   
180  *                                                
181  * This is the first half of the requeue_pi me    
182  * paired with futex_cmp_requeue_pi().            
183  */                                               
184 static inline int                                 
185 futex_wait_requeue_pi(futex_t *uaddr, futex_t     
186                       struct timespec *timeout    
187 {                                                 
188         return futex(uaddr, FUTEX_WAIT_REQUEUE    
189                      opflags);                    
190 }                                                 
191                                                   
192 /**                                               
193  * futex_cmp_requeue_pi() - requeue tasks from    
194  * @uaddr:      non-PI futex source               
195  * @uaddr2:     PI futex target                   
196  * @nr_wake:    wake up to this many tasks        
197  * @nr_requeue: requeue up to this many tasks     
198  */                                               
199 static inline int                                 
200 futex_cmp_requeue_pi(futex_t *uaddr, futex_t v    
201                      int nr_requeue, int opfla    
202 {                                                 
203         return futex(uaddr, FUTEX_CMP_REQUEUE_    
204                      val, opflags);               
205 }                                                 
206                                                   
207 /**                                               
208  * futex_cmpxchg() - atomic compare and exchan    
209  * @uaddr:      The address of the futex to be    
210  * @oldval:     The expected value of the fute    
211  * @newval:     The new value to try and assig    
212  *                                                
213  * Implement cmpxchg using gcc atomic builtins    
214  * http://gcc.gnu.org/onlinedocs/gcc-4.1.0/gcc    
215  *                                                
216  * Return the old futex value.                    
217  */                                               
218 static inline u_int32_t                           
219 futex_cmpxchg(futex_t *uaddr, u_int32_t oldval    
220 {                                                 
221         return __sync_val_compare_and_swap(uad    
222 }                                                 
223                                                   
224 /**                                               
225  * futex_dec() - atomic decrement of the futex    
226  * @uaddr:      The address of the futex to be    
227  *                                                
228  * Return the new futex value.                    
229  */                                               
230 static inline u_int32_t                           
231 futex_dec(futex_t *uaddr)                         
232 {                                                 
233         return __sync_sub_and_fetch(uaddr, 1);    
234 }                                                 
235                                                   
236 /**                                               
237  * futex_inc() - atomic increment of the futex    
238  * @uaddr:      the address of the futex to be    
239  *                                                
240  * Return the new futex value.                    
241  */                                               
242 static inline u_int32_t                           
243 futex_inc(futex_t *uaddr)                         
244 {                                                 
245         return __sync_add_and_fetch(uaddr, 1);    
246 }                                                 
247                                                   
248 /**                                               
249  * futex_set() - atomic decrement of the futex    
250  * @uaddr:      the address of the futex to be    
251  * @newval:     New value for the atomic_t        
252  *                                                
253  * Return the new futex value.                    
254  */                                               
255 static inline u_int32_t                           
256 futex_set(futex_t *uaddr, u_int32_t newval)       
257 {                                                 
258         *uaddr = newval;                          
259         return newval;                            
260 }                                                 
261                                                   
262 #endif                                            
263                                                   

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