File tree Expand file tree Collapse file tree 1 file changed +16
-35
lines changed
Expand file tree Collapse file tree 1 file changed +16
-35
lines changed Original file line number Diff line number Diff line change @@ -56,38 +56,19 @@ unsigned long notrace __xchg8(char x, volatile char *ptr)
5656}
5757
5858
59- u64 notrace __cmpxchg_u64 (volatile u64 * ptr , u64 old , u64 new )
60- {
61- unsigned long flags ;
62- u64 prev ;
63-
64- _atomic_spin_lock_irqsave (ptr , flags );
65- if ((prev = * ptr ) == old )
66- * ptr = new ;
67- _atomic_spin_unlock_irqrestore (ptr , flags );
68- return prev ;
69- }
70-
71- u32 notrace __cmpxchg_u32 (volatile u32 * ptr , u32 old , u32 new )
72- {
73- unsigned long flags ;
74- u32 prev ;
75-
76- _atomic_spin_lock_irqsave (ptr , flags );
77- if ((prev = * ptr ) == old )
78- * ptr = new ;
79- _atomic_spin_unlock_irqrestore (ptr , flags );
80- return prev ;
81- }
82-
83- u8 notrace __cmpxchg_u8 (volatile u8 * ptr , u8 old , u8 new )
84- {
85- unsigned long flags ;
86- u8 prev ;
87-
88- _atomic_spin_lock_irqsave (ptr , flags );
89- if ((prev = * ptr ) == old )
90- * ptr = new ;
91- _atomic_spin_unlock_irqrestore (ptr , flags );
92- return prev ;
93- }
59+ #define CMPXCHG (T ) \
60+ T notrace __cmpxchg_##T(volatile T *ptr, T old, T new) \
61+ { \
62+ unsigned long flags; \
63+ T prev; \
64+ \
65+ _atomic_spin_lock_irqsave(ptr, flags); \
66+ if ((prev = *ptr) == old) \
67+ *ptr = new; \
68+ _atomic_spin_unlock_irqrestore(ptr, flags); \
69+ return prev; \
70+ }
71+
72+ CMPXCHG (u64 )
73+ CMPXCHG (u32 )
74+ CMPXCHG (u8 )
You can’t perform that action at this time.
0 commit comments