Lines Matching +full:flags +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0
3 * atomic32.c: 32-bit atomic_t implementation
8 * Based on asm-parisc/atomic.h Copyright (C) 2000 Philipp Rumpf
17 #define ATOMIC_HASH(a) (&__atomic_hash[(((unsigned long)a)>>8) & (ATOMIC_HASH_SIZE-1)])
20 [0 ... (ATOMIC_HASH_SIZE-1)] = __SPIN_LOCK_UNLOCKED(__atomic_hash)
35 unsigned long flags; \
36 spin_lock_irqsave(ATOMIC_HASH(v), flags); \
38 ret = v->counter; \
39 v->counter c_op i; \
41 spin_unlock_irqrestore(ATOMIC_HASH(v), flags); \
50 unsigned long flags; \
51 spin_lock_irqsave(ATOMIC_HASH(v), flags); \
53 ret = (v->counter c_op i); \
55 spin_unlock_irqrestore(ATOMIC_HASH(v), flags); \
73 unsigned long flags; in arch_atomic_xchg() local
75 spin_lock_irqsave(ATOMIC_HASH(v), flags); in arch_atomic_xchg()
76 ret = v->counter; in arch_atomic_xchg()
77 v->counter = new; in arch_atomic_xchg()
78 spin_unlock_irqrestore(ATOMIC_HASH(v), flags); in arch_atomic_xchg()
86 unsigned long flags; in arch_atomic_cmpxchg() local
88 spin_lock_irqsave(ATOMIC_HASH(v), flags); in arch_atomic_cmpxchg()
89 ret = v->counter; in arch_atomic_cmpxchg()
91 v->counter = new; in arch_atomic_cmpxchg()
93 spin_unlock_irqrestore(ATOMIC_HASH(v), flags); in arch_atomic_cmpxchg()
101 unsigned long flags; in arch_atomic_fetch_add_unless() local
103 spin_lock_irqsave(ATOMIC_HASH(v), flags); in arch_atomic_fetch_add_unless()
104 ret = v->counter; in arch_atomic_fetch_add_unless()
106 v->counter += a; in arch_atomic_fetch_add_unless()
107 spin_unlock_irqrestore(ATOMIC_HASH(v), flags); in arch_atomic_fetch_add_unless()
115 unsigned long flags; in arch_atomic_set() local
117 spin_lock_irqsave(ATOMIC_HASH(v), flags); in arch_atomic_set()
118 v->counter = i; in arch_atomic_set()
119 spin_unlock_irqrestore(ATOMIC_HASH(v), flags); in arch_atomic_set()
123 unsigned long sp32___set_bit(unsigned long *addr, unsigned long mask) in sp32___set_bit() argument
125 unsigned long old, flags; in sp32___set_bit() local
127 spin_lock_irqsave(ATOMIC_HASH(addr), flags); in sp32___set_bit()
129 *addr = old | mask; in sp32___set_bit()
130 spin_unlock_irqrestore(ATOMIC_HASH(addr), flags); in sp32___set_bit()
132 return old & mask; in sp32___set_bit()
136 unsigned long sp32___clear_bit(unsigned long *addr, unsigned long mask) in sp32___clear_bit() argument
138 unsigned long old, flags; in sp32___clear_bit() local
140 spin_lock_irqsave(ATOMIC_HASH(addr), flags); in sp32___clear_bit()
142 *addr = old & ~mask; in sp32___clear_bit()
143 spin_unlock_irqrestore(ATOMIC_HASH(addr), flags); in sp32___clear_bit()
145 return old & mask; in sp32___clear_bit()
149 unsigned long sp32___change_bit(unsigned long *addr, unsigned long mask) in sp32___change_bit() argument
151 unsigned long old, flags; in sp32___change_bit() local
153 spin_lock_irqsave(ATOMIC_HASH(addr), flags); in sp32___change_bit()
155 *addr = old ^ mask; in sp32___change_bit()
156 spin_unlock_irqrestore(ATOMIC_HASH(addr), flags); in sp32___change_bit()
158 return old & mask; in sp32___change_bit()
165 unsigned long flags; \
168 spin_lock_irqsave(ATOMIC_HASH(ptr), flags); \
171 spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags);\
187 unsigned long flags; in __xchg_u32() local
190 spin_lock_irqsave(ATOMIC_HASH(ptr), flags); in __xchg_u32()
193 spin_unlock_irqrestore(ATOMIC_HASH(ptr), flags); in __xchg_u32()