]>
git.proxmox.com Git - mirror_spl.git/blob - include/sys/rwlock.h
2 * This file is part of the SPL: Solaris Porting Layer.
4 * Copyright (c) 2008 Lawrence Livermore National Security, LLC.
5 * Produced at Lawrence Livermore National Laboratory
7 * Brian Behlendorf <behlendorf1@llnl.gov>,
8 * Herb Wartens <wartens2@llnl.gov>,
9 * Jim Garlick <garlick@llnl.gov>
12 * This is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 * You should have received a copy of the GNU General Public License along
23 * with this program; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
30 #include <linux/module.h>
31 #include <linux/slab.h>
32 #include <linux/rwsem.h>
33 #include <asm/current.h>
34 #include <sys/types.h>
42 RW_DRIVER
= 2, /* driver (DDI) rwlock */
43 RW_DEFAULT
= 4 /* kernel default rwlock */
52 #define RW_MAGIC 0x3423645a
53 #define RW_POISON 0xa6
59 struct rw_semaphore rw_sem
;
60 struct task_struct
*rw_owner
; /* holder of the write lock */
63 extern void __rw_init(krwlock_t
*rwlp
, char *name
, krw_type_t type
, void *arg
);
64 extern void __rw_destroy(krwlock_t
*rwlp
);
65 extern int __rw_tryenter(krwlock_t
*rwlp
, krw_t rw
);
66 extern void __rw_enter(krwlock_t
*rwlp
, krw_t rw
);
67 extern void __rw_exit(krwlock_t
*rwlp
);
68 extern void __rw_downgrade(krwlock_t
*rwlp
);
69 extern int __rw_tryupgrade(krwlock_t
*rwlp
);
70 extern kthread_t
*__rw_owner(krwlock_t
*rwlp
);
71 extern int __rw_read_held(krwlock_t
*rwlp
);
72 extern int __rw_write_held(krwlock_t
*rwlp
);
73 extern int __rw_lock_held(krwlock_t
*rwlp
);
75 #define rw_init(rwlp, name, type, arg) \
78 __rw_init(rwlp, #rwlp, type, arg); \
80 __rw_init(rwlp, name, type, arg); \
82 #define rw_destroy(rwlp) __rw_destroy(rwlp)
83 #define rw_tryenter(rwlp, rw) __rw_tryenter(rwlp, rw)
84 #define rw_enter(rwlp, rw) __rw_enter(rwlp, rw)
85 #define rw_exit(rwlp) __rw_exit(rwlp)
86 #define rw_downgrade(rwlp) __rw_downgrade(rwlp)
87 #define rw_tryupgrade(rwlp) __rw_tryupgrade(rwlp)
88 #define rw_owner(rwlp) __rw_owner(rwlp)
89 #define RW_READ_HELD(rwlp) __rw_read_held(rwlp)
90 #define RW_WRITE_HELD(rwlp) __rw_write_held(rwlp)
91 #define RW_LOCK_HELD(rwlp) __rw_lock_held(rwlp)
97 #endif /* _SPL_RWLOCK_H */