]>
Commit | Line | Data |
---|---|---|
f1b59d26 | 1 | #include <linux-rwlock.h> |
f1ca4da6 BB |
2 | |
3 | int | |
4 | rw_lock_held(krwlock_t *rwlp) | |
5 | { | |
6 | BUG_ON(rwlp->rw_magic != RW_MAGIC); | |
7 | ||
8 | #ifdef CONFIG_RWSEM_GENERIC_SPINLOCK | |
9 | if (rwlp->rw_sem.activity != 0) { | |
10 | #else | |
11 | if (rwlp->rw_sem.count != 0) { | |
12 | #endif | |
13 | return 1; | |
14 | } | |
f1b59d26 | 15 | |
f1ca4da6 BB |
16 | return 0; |
17 | } | |
18 | ||
19 | int | |
20 | rw_read_held(krwlock_t *rwlp) | |
21 | { | |
22 | BUG_ON(rwlp->rw_magic != RW_MAGIC); | |
23 | ||
24 | if (rw_lock_held(rwlp) && rwlp->rw_owner == NULL) { | |
25 | return 1; | |
26 | } | |
27 | ||
28 | return 0; | |
29 | } | |
30 | ||
31 | int | |
32 | rw_write_held(krwlock_t *rwlp) | |
33 | { | |
34 | BUG_ON(rwlp->rw_magic != RW_MAGIC); | |
35 | ||
36 | if (rwlp->rw_owner == current) { | |
37 | return 1; | |
38 | } | |
39 | ||
40 | return 0; | |
41 | } |