]> git.proxmox.com Git - mirror_spl-debian.git/blame - modules/spl/spl-rwlock.c
Add highbit func,
[mirror_spl-debian.git] / modules / spl / spl-rwlock.c
CommitLineData
f4b37741 1#include <sys/rwlock.h>
f1ca4da6 2
3int
4rw_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 16 return 0;
17}
18
19int
20rw_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
31int
32rw_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}