blob: d053854e21d85ee8148a4b368bcf96e7418dcbbf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#ifndef _HACK_ASM_ATOMIC_H
#define _HACK_ASM_ATOMIC_H
/* We don't need atomicity in the Linux code because we serialize all
entries to it. */
typedef struct { int counter; } atomic_t;
#define ATOMIC_INIT(i) { (i) }
#define atomic_read(v) ((v)->counter)
#define atomic_set(v,i) (((v)->counter) = (i))
static __inline__ void atomic_add(int i, atomic_t *v) { v->counter += i; }
static __inline__ void atomic_sub(int i, atomic_t *v) { v->counter -= i; }
static __inline__ void atomic_inc(atomic_t *v) { ++v->counter; }
static __inline__ void atomic_dec(atomic_t *v) { --v->counter; }
static __inline__ int atomic_dec_and_test(atomic_t *v)
{ return --v->counter == 0; }
static __inline__ int atomic_inc_and_test_greater_zero(atomic_t *v)
{ return ++v->counter > 0; }
#define atomic_clear_mask(mask, addr) (*(addr) &= ~(mask))
#define atomic_set_mask(mask, addr) (*(addr) |= (mask))
#endif
|