Page MenuHomeFreeBSD

D40464.diff
No OneTemporary

D40464.diff

diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -1112,15 +1112,18 @@
#endif
/*
- * General init routine used by the MTX_SYSINIT() macro.
+ * General init and uninit routines used by the MTX_SYSINIT() macro.
*/
void
-mtx_sysinit(void *arg)
+mtx_sysinit(const struct mtx_args *margs)
{
- struct mtx_args *margs = arg;
+ mtx_init(margs->ma_mtx, margs->ma_desc, NULL, margs->ma_opts);
+}
- mtx_init((struct mtx *)margs->ma_mtx, margs->ma_desc, NULL,
- margs->ma_opts);
+void
+mtx_sysuninit(const struct mtx_args *margs)
+{
+ mtx_destroy(margs->ma_mtx);
}
/*
diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c
--- a/sys/kern/kern_rmlock.c
+++ b/sys/kern/kern_rmlock.c
@@ -339,14 +339,17 @@
}
void
-rm_sysinit(void *arg)
+rm_sysinit(const struct rm_args *args)
{
- struct rm_args *args;
-
- args = arg;
rm_init_flags(args->ra_rm, args->ra_desc, args->ra_flags);
}
+void
+rm_sysuninit(const struct rm_args *args)
+{
+ rm_destroy(args->ra_rm);
+}
+
static __noinline int
_rm_rlock_hard(struct rmlock *rm, struct rm_priotracker *tracker, int trylock)
{
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -254,13 +254,15 @@
}
void
-rw_sysinit(void *arg)
+rw_sysinit(const struct rw_args *args)
{
- struct rw_args *args;
+ rw_init_flags(args->ra_rw, args->ra_desc, args->ra_flags);
+}
- args = arg;
- rw_init_flags((struct rwlock *)args->ra_rw, args->ra_desc,
- args->ra_flags);
+void
+rw_sysuninit(const struct rw_args *args)
+{
+ rw_destroy(args->ra_rw);
}
int
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -225,13 +225,17 @@
#endif
void
-sx_sysinit(void *arg)
+sx_sysinit(const struct sx_args *sargs)
{
- struct sx_args *sargs = arg;
-
sx_init_flags(sargs->sa_sx, sargs->sa_desc, sargs->sa_flags);
}
+void
+sx_sysuninit(const struct sx_args *sargs)
+{
+ sx_destroy(sargs->sa_sx);
+}
+
void
sx_init_flags(struct sx *sx, const char *description, int opts)
{
diff --git a/sys/sys/mutex.h b/sys/sys/mutex.h
--- a/sys/sys/mutex.h
+++ b/sys/sys/mutex.h
@@ -45,6 +45,8 @@
#include <machine/atomic.h>
#include <machine/cpufunc.h>
+struct mtx_args;
+
/*
* Mutex types and options passed to mtx_init(). MTX_QUIET and MTX_DUPOK
* can also be passed in.
@@ -92,7 +94,8 @@
void _mtx_init(volatile uintptr_t *c, const char *name, const char *type,
int opts);
void _mtx_destroy(volatile uintptr_t *c);
-void mtx_sysinit(void *arg);
+void mtx_sysinit(const struct mtx_args *);
+void mtx_sysuninit(const struct mtx_args *);
int _mtx_trylock_flags_int(struct mtx *m, int opts LOCK_FILE_LINE_ARG_DEF);
int _mtx_trylock_flags_(volatile uintptr_t *c, int opts, const char *file,
int line);
@@ -519,13 +522,13 @@
#endif
struct mtx_args {
- void *ma_mtx;
+ struct mtx *ma_mtx;
const char *ma_desc;
int ma_opts;
};
#define MTX_SYSINIT(name, mtx, desc, opts) \
- static struct mtx_args name##_args = { \
+ static const struct mtx_args name##_args = { \
(mtx), \
(desc), \
(opts) \
@@ -533,7 +536,7 @@
SYSINIT(name##_mtx_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
mtx_sysinit, &name##_args); \
SYSUNINIT(name##_mtx_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
- _mtx_destroy, __DEVOLATILE(void *, &(mtx)->mtx_lock))
+ mtx_sysuninit, &name##_args);
/*
* The INVARIANTS-enabled mtx_assert() functionality.
diff --git a/sys/sys/rmlock.h b/sys/sys/rmlock.h
--- a/sys/sys/rmlock.h
+++ b/sys/sys/rmlock.h
@@ -50,11 +50,14 @@
#define RM_NEW 0x00000008
#define RM_DUPOK 0x00000010
+struct rm_args;
+
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(const struct rmlock *rm);
-void rm_sysinit(void *arg);
+void rm_sysinit(const struct rm_args *);
+void rm_sysuninit(const struct rm_args *);
void _rm_wlock_debug(struct rmlock *rm, const char *file, int line);
void _rm_wunlock_debug(struct rmlock *rm, const char *file, int line);
@@ -107,7 +110,7 @@
};
#define RM_SYSINIT_FLAGS(name, rm, desc, flags) \
- static struct rm_args name##_args = { \
+ static const struct rm_args name##_args = { \
(rm), \
(desc), \
(flags), \
@@ -115,7 +118,7 @@
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))
+ rm_sysuninit, &name##_args)
#define RM_SYSINIT(name, rm, desc) RM_SYSINIT_FLAGS(name, rm, desc, 0)
diff --git a/sys/sys/rwlock.h b/sys/sys/rwlock.h
--- a/sys/sys/rwlock.h
+++ b/sys/sys/rwlock.h
@@ -76,6 +76,8 @@
#ifdef _KERNEL
+struct rw_args;
+
#define rw_recurse lock_object.lo_data
#define RW_READ_VALUE(x) ((x)->rw_lock)
@@ -130,7 +132,8 @@
*/
void _rw_init_flags(volatile uintptr_t *c, const char *name, int opts);
void _rw_destroy(volatile uintptr_t *c);
-void rw_sysinit(void *arg);
+void rw_sysinit(const struct rw_args *);
+void rw_sysuninit(const struct rw_args *);
int _rw_wowned(const volatile uintptr_t *c);
void _rw_wlock_cookie(volatile uintptr_t *c, const char *file, int line);
int __rw_try_wlock_int(struct rwlock *rw LOCK_FILE_LINE_ARG_DEF);
@@ -247,13 +250,13 @@
#define rw_initialized(rw) lock_initialized(&(rw)->lock_object)
struct rw_args {
- void *ra_rw;
+ struct rwlock *ra_rw;
const char *ra_desc;
int ra_flags;
};
#define RW_SYSINIT_FLAGS(name, rw, desc, flags) \
- static struct rw_args name##_args = { \
+ static const struct rw_args name##_args = { \
(rw), \
(desc), \
(flags), \
@@ -261,7 +264,7 @@
SYSINIT(name##_rw_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
rw_sysinit, &name##_args); \
SYSUNINIT(name##_rw_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
- _rw_destroy, __DEVOLATILE(void *, &(rw)->rw_lock))
+ rw_sysuninit, &name##_args)
#define RW_SYSINIT(name, rw, desc) RW_SYSINIT_FLAGS(name, rw, desc, 0)
diff --git a/sys/sys/sx.h b/sys/sys/sx.h
--- a/sys/sys/sx.h
+++ b/sys/sys/sx.h
@@ -90,6 +90,8 @@
#ifdef _KERNEL
+struct sx_args;
+
#define sx_recurse lock_object.lo_data
#define SX_READ_VALUE(sx) ((sx)->sx_lock)
@@ -101,7 +103,8 @@
* Function prototipes. Routines that start with an underscore are not part
* of the public interface and are wrappered with a macro.
*/
-void sx_sysinit(void *arg);
+void sx_sysinit(const struct sx_args *);
+void sx_sysuninit(const struct sx_args *);
#define sx_init(sx, desc) sx_init_flags((sx), (desc), 0)
void sx_init_flags(struct sx *sx, const char *description, int opts);
void sx_destroy(struct sx *sx);
@@ -135,7 +138,7 @@
};
#define SX_SYSINIT_FLAGS(name, sxa, desc, flags) \
- static struct sx_args name##_args = { \
+ static const struct sx_args name##_args = { \
(sxa), \
(desc), \
(flags) \
@@ -143,7 +146,7 @@
SYSINIT(name##_sx_sysinit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
sx_sysinit, &name##_args); \
SYSUNINIT(name##_sx_sysuninit, SI_SUB_LOCK, SI_ORDER_MIDDLE, \
- sx_destroy, (sxa))
+ sx_sysuninit, &name##_args)
#define SX_SYSINIT(name, sxa, desc) SX_SYSINIT_FLAGS(name, sxa, desc, 0)

File Metadata

Mime Type
text/plain
Expires
Mon, Jan 27, 5:28 PM (6 h, 58 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16201779
Default Alt Text
D40464.diff (7 KB)

Event Timeline