ReactOS 0.4.16-dev-205-g7b2bb7e
bit_spinlock.h File Reference

Go to the source code of this file.

Functions

static void bit_spin_lock (int bitnum, unsigned long *addr)
 
static int bit_spin_trylock (int bitnum, unsigned long *addr)
 
static void bit_spin_unlock (int bitnum, unsigned long *addr)
 
static void __bit_spin_unlock (int bitnum, unsigned long *addr)
 
static int bit_spin_is_locked (int bitnum, unsigned long *addr)
 

Function Documentation

◆ __bit_spin_unlock()

static void __bit_spin_unlock ( int  bitnum,
unsigned long addr 
)
inlinestatic

Definition at line 68 of file bit_spinlock.h.

69{
70#ifdef CONFIG_DEBUG_SPINLOCK
71 BUG_ON(!test_bit(bitnum, addr));
72#endif
73#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
74 __clear_bit_unlock(bitnum, addr);
75#endif
77 __release(bitlock);
78}
#define __release(x)
Definition: types.h:106
#define preempt_enable()
Definition: types.h:108
GLenum const GLvoid * addr
Definition: glext.h:9621
static int test_bit(int nr, volatile const unsigned long *addr)
Definition: module.h:383
#define BUG_ON(c)
Definition: module.h:255

◆ bit_spin_is_locked()

static int bit_spin_is_locked ( int  bitnum,
unsigned long addr 
)
inlinestatic

Definition at line 83 of file bit_spinlock.h.

84{
85#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
86 return test_bit(bitnum, addr);
87#elif defined CONFIG_PREEMPT
88 return preempt_count();
89#else
90 return 1;
91#endif
92}

◆ bit_spin_lock()

static void bit_spin_lock ( int  bitnum,
unsigned long addr 
)
inlinestatic

Definition at line 10 of file bit_spinlock.h.

11{
12 /*
13 * Assuming the lock is uncontended, this never enters
14 * the body of the outer loop. If it is contended, then
15 * within the inner loop a non-atomic test is used to
16 * busywait with less bus contention for a good time to
17 * attempt to acquire the lock bit.
18 */
20#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
21 while (unlikely(test_and_set_bit_lock(bitnum, addr))) {
22 while (test_bit(bitnum, addr)) {
24 cpu_relax();
26 }
27 }
28#endif
29 __acquire(bitlock);
30}
#define __acquire(x)
Definition: types.h:105
#define preempt_disable()
Definition: types.h:109
#define unlikely
Definition: module.h:264

◆ bit_spin_trylock()

static int bit_spin_trylock ( int  bitnum,
unsigned long addr 
)
inlinestatic

Definition at line 35 of file bit_spinlock.h.

36{
38#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
39 if (unlikely(test_and_set_bit_lock(bitnum, addr))) {
41 return 0;
42 }
43#endif
44 __acquire(bitlock);
45 return 1;
46}

◆ bit_spin_unlock()

static void bit_spin_unlock ( int  bitnum,
unsigned long addr 
)
inlinestatic

Definition at line 51 of file bit_spinlock.h.

52{
53#ifdef CONFIG_DEBUG_SPINLOCK
54 BUG_ON(!test_bit(bitnum, addr));
55#endif
56#if defined(CONFIG_SMP) || defined(CONFIG_DEBUG_SPINLOCK)
57 clear_bit_unlock(bitnum, addr);
58#endif
60 __release(bitlock);
61}