Commit 7b0adda5 authored by Linus Torvalds's avatar Linus Torvalds

Remove broken-as-designed "rwlock_is_locked()" macro

rwlocks can't be "locked". They can be "locked for read", or
"locked for write", but not both. The confusion this caused is
evident in the long discussion about this on linux-kernel ;)
parent 5d4564e6
...@@ -107,7 +107,6 @@ typedef struct { ...@@ -107,7 +107,6 @@ typedef struct {
#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 } #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) (*(volatile int *)(x) != 0)
#ifdef CONFIG_DEBUG_RWLOCK #ifdef CONFIG_DEBUG_RWLOCK
extern void _raw_write_lock(rwlock_t * lock); extern void _raw_write_lock(rwlock_t * lock);
......
...@@ -186,8 +186,6 @@ typedef struct { ...@@ -186,8 +186,6 @@ typedef struct {
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) ((x)->lock != RW_LOCK_BIAS)
/* /*
* On x86, we implement read-write locks as a 32-bit counter * On x86, we implement read-write locks as a 32-bit counter
* with the high bit (sign) being the "contended" bit. * with the high bit (sign) being the "contended" bit.
......
...@@ -126,7 +126,6 @@ typedef struct { ...@@ -126,7 +126,6 @@ typedef struct {
#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 } #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0 }
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) (*(volatile int *) (x) != 0)
#define _raw_read_lock(rw) \ #define _raw_read_lock(rw) \
do { \ do { \
......
...@@ -199,8 +199,6 @@ typedef struct { ...@@ -199,8 +199,6 @@ typedef struct {
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) ((x)->lock != RW_LOCK_BIAS)
/* /*
* On x86, we implement read-write locks as a 32-bit counter * On x86, we implement read-write locks as a 32-bit counter
* with the high bit (sign) being the "contended" bit. * with the high bit (sign) being the "contended" bit.
......
...@@ -139,8 +139,6 @@ typedef struct { ...@@ -139,8 +139,6 @@ typedef struct {
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) ((x)->lock)
static inline void _raw_read_lock(rwlock_t *rw) static inline void _raw_read_lock(rwlock_t *rw)
{ {
unsigned int tmp; unsigned int tmp;
......
...@@ -151,8 +151,6 @@ typedef struct { ...@@ -151,8 +151,6 @@ typedef struct {
#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while (0) #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while (0)
#define rwlock_is_locked(lp) ((lp)->counter != 0)
#define _raw_read_trylock(lock) generic_raw_read_trylock(lock) #define _raw_read_trylock(lock) generic_raw_read_trylock(lock)
/* read_lock, read_unlock are pretty straightforward. Of course it somehow /* read_lock, read_unlock are pretty straightforward. Of course it somehow
......
...@@ -100,8 +100,6 @@ typedef struct { ...@@ -100,8 +100,6 @@ typedef struct {
#define RW_LOCK_UNLOCKED (rwlock_t) { 0 RWLOCK_DEBUG_INIT } #define RW_LOCK_UNLOCKED (rwlock_t) { 0 RWLOCK_DEBUG_INIT }
#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) ((x)->lock != 0)
#ifndef CONFIG_DEBUG_SPINLOCK #ifndef CONFIG_DEBUG_SPINLOCK
static __inline__ void _raw_read_lock(rwlock_t *rw) static __inline__ void _raw_read_lock(rwlock_t *rw)
......
...@@ -147,7 +147,6 @@ static void __inline__ _raw_spin_lock_flags(spinlock_t *lock, unsigned long flag ...@@ -147,7 +147,6 @@ static void __inline__ _raw_spin_lock_flags(spinlock_t *lock, unsigned long flag
#define RW_LOCK_UNLOCKED (rwlock_t) { 0 } #define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) ((x)->lock)
static __inline__ int is_read_locked(rwlock_t *rw) static __inline__ int is_read_locked(rwlock_t *rw)
{ {
......
...@@ -117,8 +117,6 @@ typedef struct { ...@@ -117,8 +117,6 @@ typedef struct {
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) ((x)->lock != 0)
#ifndef __s390x__ #ifndef __s390x__
#define _raw_read_lock(rw) \ #define _raw_read_lock(rw) \
asm volatile(" l 2,0(%1)\n" \ asm volatile(" l 2,0(%1)\n" \
......
...@@ -79,7 +79,6 @@ typedef struct { ...@@ -79,7 +79,6 @@ typedef struct {
#define RW_LOCK_BIAS 0x01000000 #define RW_LOCK_BIAS 0x01000000
#define RW_LOCK_UNLOCKED (rwlock_t) { { 0 }, { RW_LOCK_BIAS } } #define RW_LOCK_UNLOCKED (rwlock_t) { { 0 }, { RW_LOCK_BIAS } }
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while (0) #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while (0)
#define rwlock_is_locked(x) (atomic_read(&(x)->counter) != RW_LOCK_BIAS)
static inline void _raw_read_lock(rwlock_t *rw) static inline void _raw_read_lock(rwlock_t *rw)
{ {
......
...@@ -48,7 +48,6 @@ typedef struct _rwlock_debug rwlock_t; ...@@ -48,7 +48,6 @@ typedef struct _rwlock_debug rwlock_t;
#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, {0} } #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, {0} }
#define rwlock_init(lp) do { *(lp)= RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(lp) do { *(lp)= RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(lp) ((lp)->lock != 0)
extern void _do_read_lock(rwlock_t *rw, char *str); extern void _do_read_lock(rwlock_t *rw, char *str);
extern void _do_read_unlock(rwlock_t *rw, char *str); extern void _do_read_unlock(rwlock_t *rw, char *str);
...@@ -159,7 +158,6 @@ typedef struct { ...@@ -159,7 +158,6 @@ typedef struct {
#define RW_LOCK_UNLOCKED (rwlock_t) { 0 } #define RW_LOCK_UNLOCKED (rwlock_t) { 0 }
#define rwlock_init(lp) do { *(lp)= RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(lp) do { *(lp)= RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(lp) ((lp)->lock != 0)
/* Sort of like atomic_t's on Sparc, but even more clever. /* Sort of like atomic_t's on Sparc, but even more clever.
......
...@@ -142,7 +142,6 @@ extern int _do_spin_trylock (spinlock_t *lock); ...@@ -142,7 +142,6 @@ extern int _do_spin_trylock (spinlock_t *lock);
typedef unsigned int rwlock_t; typedef unsigned int rwlock_t;
#define RW_LOCK_UNLOCKED 0 #define RW_LOCK_UNLOCKED 0
#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) (*(x) != RW_LOCK_UNLOCKED)
static void inline __read_lock(rwlock_t *lock) static void inline __read_lock(rwlock_t *lock)
{ {
...@@ -257,7 +256,6 @@ typedef struct { ...@@ -257,7 +256,6 @@ typedef struct {
} rwlock_t; } rwlock_t;
#define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0xff, { } } #define RW_LOCK_UNLOCKED (rwlock_t) { 0, 0, 0xff, { } }
#define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(lp) do { *(lp) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) ((x)->lock != 0)
extern void _do_read_lock(rwlock_t *rw, char *str); extern void _do_read_lock(rwlock_t *rw, char *str);
extern void _do_read_unlock(rwlock_t *rw, char *str); extern void _do_read_unlock(rwlock_t *rw, char *str);
......
...@@ -159,8 +159,6 @@ typedef struct { ...@@ -159,8 +159,6 @@ typedef struct {
#define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0) #define rwlock_init(x) do { *(x) = RW_LOCK_UNLOCKED; } while(0)
#define rwlock_is_locked(x) ((x)->lock != RW_LOCK_BIAS)
/* /*
* On x86, we implement read-write locks as a 32-bit counter * On x86, we implement read-write locks as a 32-bit counter
* with the high bit (sign) being the "contended" bit. * with the high bit (sign) being the "contended" bit.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment