diff options
author | rwatson <rwatson@FreeBSD.org> | 2009-05-29 10:52:37 +0000 |
---|---|---|
committer | rwatson <rwatson@FreeBSD.org> | 2009-05-29 10:52:37 +0000 |
commit | 52ba25996039c990d61c87ec08ee18c634d5e1ae (patch) | |
tree | bcd8f26df00704f44c24b12794f3b744baf80489 /sys/sys/rmlock.h | |
parent | be2772a684b761a0e896a5808a48c30e67fdbbe5 (diff) | |
download | FreeBSD-src-52ba25996039c990d61c87ec08ee18c634d5e1ae.zip FreeBSD-src-52ba25996039c990d61c87ec08ee18c634d5e1ae.tar.gz |
Make the rmlock(9) interface a bit more like the rwlock(9) interface:
- Add rm_init_flags() and accept extended options only for that variation.
- Add a flags space specifically for rm_init_flags(), rather than borrowing
the lock_init() flag space.
- Define flag RM_RECURSE to use instead of LO_RECURSABLE.
- Define flag RM_NOWITNESS to allow an rmlock to be exempt from WITNESS
checking; this wasn't possible previously as rm_init() always passed
LO_WITNESS when initializing an rmlock's struct lock.
- Add RM_SYSINIT_FLAGS().
- Rename embedded mutex in rmlocks to make it more obvious what it is.
- Update consumers.
- Update man page.
Diffstat (limited to 'sys/sys/rmlock.h')
-rw-r--r-- | sys/sys/rmlock.h | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/sys/sys/rmlock.h b/sys/sys/rmlock.h index 9167a1d..9766f67 100644 --- a/sys/sys/rmlock.h +++ b/sys/sys/rmlock.h @@ -38,10 +38,18 @@ #ifdef _KERNEL -void rm_init(struct rmlock *rm, const char *name, int opts); +/* + * Flags passed to rm_init(9). + */ +#define RM_NOWITNESS 0x00000001 +#define RM_RECURSE 0x00000002 + +void rm_init(struct rmlock *rm, const char *name); +void rm_init_flags(struct rmlock *rm, const char *name, int opts); void rm_destroy(struct rmlock *rm); int rm_wowned(struct rmlock *rm); void rm_sysinit(void *arg); +void rm_sysinit_flags(void *arg); void _rm_wlock_debug(struct rmlock *rm, const char *file, int line); void _rm_wunlock_debug(struct rmlock *rm, const char *file, int line); @@ -79,19 +87,35 @@ void _rm_runlock(struct rmlock *rm, struct rm_priotracker *tracker); struct rm_args { struct rmlock *ra_rm; const char *ra_desc; +}; + +struct rm_args_flags { + struct rmlock *ra_rm; + const char *ra_desc; int ra_opts; }; -#define RM_SYSINIT(name, rm, desc, opts) \ +#define RM_SYSINIT(name, rm, desc) \ static struct rm_args name##_args = { \ (rm), \ (desc), \ - (opts), \ }; \ SYSINIT(name##_rm_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ rm_sysinit, &name##_args); \ SYSUNINIT(name##_rm_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ rm_destroy, (rm)) + +#define RM_SYSINIT_FLAGS(name, rm, desc, opts) \ + static struct rm_args name##_args = { \ + (rm), \ + (desc), \ + (opts), \ + }; \ + SYSINIT(name##_rm_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ + rm_sysinit_flags, &name##_args); \ + SYSUNINIT(name##_rm_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \ + rm_destroy, (rm)) + #endif /* _KERNEL */ #endif /* !_SYS_RMLOCK_H_ */ |