15 #define LOCK_PREFIX "\n\tlock; "
18 #define barrier() __asm__ __volatile__("" \
24 #define cpu_relax() __asm__ __volatile__("pause\n" \
38 :
"+r"(value),
"+m"(*ptr)
69 :
"+r"(value),
"+m"(*ptr)
137 static inline void set_bit(
int offset,
volatile unsigned long *base)
139 __asm__ __volatile__(
"btsl %[offset], %[base]"
140 : [base]
"=m"(*(
volatile long *)base)
141 : [offset]
"Ir"(offset));
147 static inline void clear_bit(
int offset,
volatile unsigned long *base)
149 __asm__ __volatile__(
"btrl %[offset],%[base]"
150 : [base]
"=m"(*(
volatile long *)base)
151 : [offset]
"Ir"(offset));
158 static inline int test_bit(
int offset,
volatile unsigned long *base)
161 __asm__ __volatile__(
"btl %[offset],%[base]\n"
162 "sbbl %[old],%[old]\n"
164 : [base]
"m"(*(
volatile long *)base),
165 [offset]
"Ir"(offset));
Definition of memory barriers.
#define READ_ONCE(var)
Read the value from the given variable.
Definition: compiler.h:48
static void set_bit(int offset, volatile unsigned long *base)
Atomically sets a bit in memory, using Bit Test And Set (bts).
Definition: stdatomic.h:137
volatile unsigned atomic_t
Standard structure for atomic operations (see below for volatile explanation).
Definition: stdatomic.h:12
static void atomic_set(atomic_t *ptr, int value)
Atomically set the value pointed by ptr to value.
Definition: stdatomic.h:47
static int atomic_read(const atomic_t *ptr)
Atomically read the value pointed by ptr.
Definition: stdatomic.h:55
static int atomic_inc_and_test(atomic_t *ptr)
Atomically increment ptr and checks if the result is zero.
Definition: stdatomic.h:121
static int atomic_add_negative(atomic_t *ptr, int value)
Atomically add value to ptr and checks if the result is negative.
Definition: stdatomic.h:104
static int atomic_sub_and_test(atomic_t *ptr, int value)
Atomically subtract value from ptr and checks if the result is zero.
Definition: stdatomic.h:113
static int atomic_set_and_test(atomic_t *ptr, int value)
Atomically sets value at ptr.
Definition: stdatomic.h:33
static int atomic_dec(atomic_t *ptr)
Atomically decrement the value at ptr.
Definition: stdatomic.h:95
static void clear_bit(int offset, volatile unsigned long *base)
Atomically clears a bit in memory.
Definition: stdatomic.h:147
static int atomic_add(atomic_t *ptr, int value)
Atomically add value to the value pointed by ptr.
Definition: stdatomic.h:64
static int atomic_inc(atomic_t *ptr)
Atomically increment the value at ptr.
Definition: stdatomic.h:87
#define LOCK_PREFIX
The prefix used to lock.
Definition: stdatomic.h:15
static int atomic_sub(atomic_t *ptr, int value)
Atomically subtract value from the value pointed by ptr.
Definition: stdatomic.h:79
static int atomic_dec_and_test(atomic_t *ptr)
Atomically decrement ptr and checks if the result is zero.
Definition: stdatomic.h:129
static int test_bit(int offset, volatile unsigned long *base)
Atomically tests a bit in memory.
Definition: stdatomic.h:158