Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F2937141
Masterwork From Distant Lands
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
mjoras
Oct 19 2017, 7:03 PM
2017-10-19 19:03:17 (UTC+0)
Size
23 KB
Referenced Files
None
Subscribers
None
Masterwork From Distant Lands
View Options
diff --git a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
index 82353cbb235..a5b667b52b4 100644
--- a/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
+++ b/sys/cddl/contrib/opensolaris/uts/common/dtrace/fasttrap.c
@@ -2530,7 +2530,7 @@ fasttrap_load(void)
* This event handler must run before kdtrace_thread_dtor() since it
* accesses the thread's struct kdtrace_thread.
*/
- fasttrap_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
+ fasttrap_thread_dtor_tag = EVENTHANDLER_STATIC_REGISTER(thread_dtor,
fasttrap_thread_dtor, NULL, EVENTHANDLER_PRI_FIRST);
#endif
@@ -2633,7 +2633,7 @@ fasttrap_unload(void)
#endif
#ifndef illumos
- EVENTHANDLER_DEREGISTER(thread_dtor, fasttrap_thread_dtor_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(thread_dtor, fasttrap_thread_dtor_tag);
for (i = 0; i < fasttrap_tpoints.fth_nent; i++)
mutex_destroy(&fasttrap_tpoints.fth_table[i].ftb_mtx);
diff --git a/sys/compat/linux/linux_common.c b/sys/compat/linux/linux_common.c
index b9e35311bdf..96af7221e3e 100644
--- a/sys/compat/linux/linux_common.c
+++ b/sys/compat/linux/linux_common.c
@@ -61,11 +61,12 @@ linux_common_modevent(module_t mod, int type, void *data)
switch(type) {
case MOD_LOAD:
linux_osd_jail_register();
- linux_exit_tag = EVENTHANDLER_REGISTER(process_exit,
+ linux_exit_tag = EVENTHANDLER_STATIC_REGISTER(process_exit,
linux_proc_exit, NULL, 1000);
- linux_exec_tag = EVENTHANDLER_REGISTER(process_exec,
+ linux_exec_tag = EVENTHANDLER_STATIC_REGISTER(process_exec,
linux_proc_exec, NULL, 1000);
- linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
+ linux_thread_dtor_tag =
+ EVENTHANDLER_STATIC_REGISTER(thread_dtor,
linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
SET_FOREACH(ldhp, linux_device_handler_set)
linux_device_register_handler(*ldhp);
@@ -74,9 +75,10 @@ linux_common_modevent(module_t mod, int type, void *data)
linux_osd_jail_deregister();
SET_FOREACH(ldhp, linux_device_handler_set)
linux_device_unregister_handler(*ldhp);
- EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
- EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
- EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exit, linux_exit_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exec, linux_exec_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(thread_dtor,
+ linux_thread_dtor_tag);
break;
default:
return (EOPNOTSUPP);
diff --git a/sys/compat/linuxkpi/common/src/linux_current.c b/sys/compat/linuxkpi/common/src/linux_current.c
index 331f6e2d2b7..48da75f261c 100644
--- a/sys/compat/linuxkpi/common/src/linux_current.c
+++ b/sys/compat/linuxkpi/common/src/linux_current.c
@@ -218,7 +218,7 @@ linux_get_pid_task(pid_t pid)
static void
linux_current_init(void *arg __unused)
{
- linuxkpi_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
+ linuxkpi_thread_dtor_tag = EVENTHANDLER_STATIC_REGISTER(thread_dtor,
linuxkpi_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
}
SYSINIT(linux_current, SI_SUB_EVENTHANDLER, SI_ORDER_SECOND, linux_current_init, NULL);
@@ -243,6 +243,6 @@ linux_current_uninit(void *arg __unused)
}
sx_sunlock(&allproc_lock);
- EVENTHANDLER_DEREGISTER(thread_dtor, linuxkpi_thread_dtor_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(thread_dtor, linuxkpi_thread_dtor_tag);
}
SYSUNINIT(linux_current, SI_SUB_EVENTHANDLER, SI_ORDER_SECOND, linux_current_uninit, NULL);
diff --git a/sys/dev/filemon/filemon_wrapper.c b/sys/dev/filemon/filemon_wrapper.c
index 6c71d27a767..cb46eec3911 100644
--- a/sys/dev/filemon/filemon_wrapper.c
+++ b/sys/dev/filemon/filemon_wrapper.c
@@ -436,11 +436,11 @@ filemon_wrapper_install(void)
freebsd32_sysent[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *) filemon_wrapper_linkat;
#endif /* COMPAT_FREEBSD32 */
- filemon_exec_tag = EVENTHANDLER_REGISTER(process_exec,
+ filemon_exec_tag = EVENTHANDLER_STATIC_REGISTER(process_exec,
filemon_event_process_exec, NULL, EVENTHANDLER_PRI_LAST);
- filemon_exit_tag = EVENTHANDLER_REGISTER(process_exit,
+ filemon_exit_tag = EVENTHANDLER_STATIC_REGISTER(process_exit,
filemon_event_process_exit, NULL, EVENTHANDLER_PRI_LAST);
- filemon_fork_tag = EVENTHANDLER_REGISTER(process_fork,
+ filemon_fork_tag = EVENTHANDLER_STATIC_REGISTER(process_fork,
filemon_event_process_fork, NULL, EVENTHANDLER_PRI_LAST);
}
@@ -468,7 +468,7 @@ filemon_wrapper_deinstall(void)
freebsd32_sysent[FREEBSD32_SYS_linkat].sy_call = (sy_call_t *)sys_linkat;
#endif /* COMPAT_FREEBSD32 */
- EVENTHANDLER_DEREGISTER(process_exec, filemon_exec_tag);
- EVENTHANDLER_DEREGISTER(process_exit, filemon_exit_tag);
- EVENTHANDLER_DEREGISTER(process_fork, filemon_fork_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exec, filemon_exec_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exit, filemon_exit_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_fork, filemon_fork_tag);
}
diff --git a/sys/dev/hwpmc/hwpmc_mod.c b/sys/dev/hwpmc/hwpmc_mod.c
index 821617138ec..0cb49eb4285 100644
--- a/sys/dev/hwpmc/hwpmc_mod.c
+++ b/sys/dev/hwpmc/hwpmc_mod.c
@@ -4993,9 +4993,9 @@ pmc_initialize(void)
pmc_processhash, pmc_processhashmask);
/* register process {exit,fork,exec} handlers */
- pmc_exit_tag = EVENTHANDLER_REGISTER(process_exit,
+ pmc_exit_tag = EVENTHANDLER_STATIC_REGISTER(process_exit,
pmc_process_exit, NULL, EVENTHANDLER_PRI_ANY);
- pmc_fork_tag = EVENTHANDLER_REGISTER(process_fork,
+ pmc_fork_tag = EVENTHANDLER_STATIC_REGISTER(process_fork,
pmc_process_fork, NULL, EVENTHANDLER_PRI_ANY);
/* register kld event handlers */
@@ -5059,8 +5059,8 @@ pmc_cleanup(void)
pmc_hook = NULL; /* prevent new threads from entering module */
/* deregister event handlers */
- EVENTHANDLER_DEREGISTER(process_fork, pmc_fork_tag);
- EVENTHANDLER_DEREGISTER(process_exit, pmc_exit_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_fork, pmc_fork_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exit, pmc_exit_tag);
EVENTHANDLER_DEREGISTER(kld_load, pmc_kld_load_tag);
EVENTHANDLER_DEREGISTER(kld_unload, pmc_kld_unload_tag);
diff --git a/sys/fs/pseudofs/pseudofs_vncache.c b/sys/fs/pseudofs/pseudofs_vncache.c
index 093d80565ea..5fb23511256 100644
--- a/sys/fs/pseudofs/pseudofs_vncache.c
+++ b/sys/fs/pseudofs/pseudofs_vncache.c
@@ -86,8 +86,8 @@ pfs_vncache_load(void)
{
mtx_init(&pfs_vncache_mutex, "pfs_vncache", NULL, MTX_DEF);
- pfs_exit_tag = EVENTHANDLER_REGISTER(process_exit, pfs_exit, NULL,
- EVENTHANDLER_PRI_ANY);
+ pfs_exit_tag = EVENTHANDLER_STATIC_REGISTER(process_exit, pfs_exit,
+ NULL, EVENTHANDLER_PRI_ANY);
}
/*
@@ -97,7 +97,7 @@ void
pfs_vncache_unload(void)
{
- EVENTHANDLER_DEREGISTER(process_exit, pfs_exit_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exit, pfs_exit_tag);
mtx_lock(&pfs_vncache_mutex);
pfs_purge_locked(NULL, true);
mtx_unlock(&pfs_vncache_mutex);
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index 422645b67dc..d0c466089f4 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -1159,11 +1159,11 @@ linux_elf_modevent(module_t mod, int type, void *data)
linux_ioctl_register_handler(*lihp);
LIST_INIT(&futex_list);
mtx_init(&futex_mtx, "ftllk", NULL, MTX_DEF);
- linux_exit_tag = EVENTHANDLER_REGISTER(process_exit, linux_proc_exit,
- NULL, 1000);
- linux_exec_tag = EVENTHANDLER_REGISTER(process_exec, linux_proc_exec,
- NULL, 1000);
- linux_thread_dtor_tag = EVENTHANDLER_REGISTER(thread_dtor,
+ linux_exit_tag = EVENTHANDLER_STATIC_REGISTER(process_exit,
+ linux_proc_exit, NULL, 1000);
+ linux_exec_tag = EVENTHANDLER_STATIC_REGISTER(process_exec,
+ linux_proc_exec, NULL, 1000);
+ linux_thread_dtor_tag = EVENTHANDLER_STATIC_REGISTER(thread_dtor,
linux_thread_dtor, NULL, EVENTHANDLER_PRI_ANY);
linux_get_machine(&linux_kplatform);
linux_szplatform = roundup(strlen(linux_kplatform) + 1,
@@ -1190,9 +1190,9 @@ linux_elf_modevent(module_t mod, int type, void *data)
SET_FOREACH(lihp, linux_ioctl_handler_set)
linux_ioctl_unregister_handler(*lihp);
mtx_destroy(&futex_mtx);
- EVENTHANDLER_DEREGISTER(process_exit, linux_exit_tag);
- EVENTHANDLER_DEREGISTER(process_exec, linux_exec_tag);
- EVENTHANDLER_DEREGISTER(thread_dtor, linux_thread_dtor_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exit, linux_exit_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exec, linux_exec_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(thread_dtor, linux_thread_dtor_tag);
linux_osd_jail_deregister();
if (bootverbose)
printf("Linux ELF exec handler removed\n");
diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c
index f71ba6efaf5..3bb0becb9c9 100644
--- a/sys/kern/init_main.c
+++ b/sys/kern/init_main.c
@@ -569,10 +569,10 @@ proc0_init(void *dummy __unused)
* Call the init and ctor for the new thread and proc. We wait
* to do this until all other structures are fairly sane.
*/
- EVENTHANDLER_INVOKE(process_init, p);
- EVENTHANDLER_INVOKE(thread_init, td);
- EVENTHANDLER_INVOKE(process_ctor, p);
- EVENTHANDLER_INVOKE(thread_ctor, td);
+ EVENTHANDLER_STATIC_INVOKE(process_init, p);
+ EVENTHANDLER_STATIC_INVOKE(thread_init, td);
+ EVENTHANDLER_STATIC_INVOKE(process_ctor, p);
+ EVENTHANDLER_STATIC_INVOKE(thread_ctor, td);
/*
* Charge root for one process.
diff --git a/sys/kern/kern_dtrace.c b/sys/kern/kern_dtrace.c
index adc36a8e3a8..acdc454aa49 100644
--- a/sys/kern/kern_dtrace.c
+++ b/sys/kern/kern_dtrace.c
@@ -113,13 +113,13 @@ static void
init_dtrace(void *dummy __unused)
{
- EVENTHANDLER_REGISTER(process_ctor, kdtrace_proc_ctor, NULL,
+ EVENTHANDLER_STATIC_REGISTER(process_ctor, kdtrace_proc_ctor, NULL,
EVENTHANDLER_PRI_ANY);
- EVENTHANDLER_REGISTER(process_dtor, kdtrace_proc_dtor, NULL,
+ EVENTHANDLER_STATIC_REGISTER(process_dtor, kdtrace_proc_dtor, NULL,
EVENTHANDLER_PRI_ANY);
- EVENTHANDLER_REGISTER(thread_ctor, kdtrace_thread_ctor, NULL,
+ EVENTHANDLER_STATIC_REGISTER(thread_ctor, kdtrace_thread_ctor, NULL,
EVENTHANDLER_PRI_ANY);
- EVENTHANDLER_REGISTER(thread_dtor, kdtrace_thread_dtor, NULL,
+ EVENTHANDLER_STATIC_REGISTER(thread_dtor, kdtrace_thread_dtor, NULL,
EVENTHANDLER_PRI_ANY);
}
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 953da2d908a..70fa5f1577c 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1074,7 +1074,7 @@ exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv)
imgp->sysent = sv;
/* May be called with Giant held */
- EVENTHANDLER_INVOKE(process_exec, p, imgp);
+ EVENTHANDLER_STATIC_INVOKE(process_exec, p, imgp);
/*
* Blow away entire process VM, if address space not shared,
diff --git a/sys/kern/kern_exit.c b/sys/kern/kern_exit.c
index d05951e150c..ad86035b75c 100644
--- a/sys/kern/kern_exit.c
+++ b/sys/kern/kern_exit.c
@@ -329,7 +329,7 @@ exit1(struct thread *td, int rval, int signo)
* Event handler could change exit status.
* XXX what if one of these generates an error?
*/
- EVENTHANDLER_INVOKE(process_exit, p);
+ EVENTHANDLER_STATIC_INVOKE(process_exit, p);
/*
* If parent is waiting for us to exit or exec,
diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c
index 997a783522e..bac4787815c 100644
--- a/sys/kern/kern_fork.c
+++ b/sys/kern/kern_fork.c
@@ -699,7 +699,7 @@ do_fork(struct thread *td, struct fork_req *fr, struct proc *p2, struct thread *
* Both processes are set up, now check if any loadable modules want
* to adjust anything.
*/
- EVENTHANDLER_INVOKE(process_fork, p1, p2, fr->fr_flags);
+ EVENTHANDLER_STATIC_INVOKE(process_fork, p1, p2, fr->fr_flags);
/*
* Set the child start time and mark the process as being complete.
diff --git a/sys/kern/kern_proc.c b/sys/kern/kern_proc.c
index de829228b1d..8324ffe8a4e 100644
--- a/sys/kern/kern_proc.c
+++ b/sys/kern/kern_proc.c
@@ -164,6 +164,14 @@ CTASSERT(sizeof(struct kinfo_proc) == KINFO_PROC_SIZE);
CTASSERT(sizeof(struct kinfo_proc32) == KINFO_PROC32_SIZE);
#endif
+EVENTHANDLER_STATIC_DEFINE(process_ctor, proc_ctor_fn);
+EVENTHANDLER_STATIC_DEFINE(process_dtor, proc_dtor_fn);
+EVENTHANDLER_STATIC_DEFINE(process_init, proc_init_fn);
+EVENTHANDLER_STATIC_DEFINE(process_fini, proc_fini_fn);
+EVENTHANDLER_STATIC_DEFINE(process_exit, exitlist_fn);
+EVENTHANDLER_STATIC_DEFINE(process_fork, forklist_fn);
+EVENTHANDLER_STATIC_DEFINE(process_exec, execlist_fn);
+
/*
* Initialize global process hashing structures.
*/
@@ -195,12 +203,12 @@ proc_ctor(void *mem, int size, void *arg, int flags)
p = (struct proc *)mem;
SDT_PROBE4(proc, , ctor , entry, p, size, arg, flags);
- EVENTHANDLER_INVOKE(process_ctor, p);
+ EVENTHANDLER_STATIC_INVOKE(process_ctor, p);
SDT_PROBE4(proc, , ctor , return, p, size, arg, flags);
td = FIRST_THREAD_IN_PROC(p);
if (td != NULL) {
/* Make sure all thread constructors are executed */
- EVENTHANDLER_INVOKE(thread_ctor, td);
+ EVENTHANDLER_STATIC_INVOKE(thread_ctor, td);
}
return (0);
}
@@ -230,9 +238,9 @@ proc_dtor(void *mem, int size, void *arg)
MPASS(td->td_su == NULL);
/* Make sure all thread destructors are executed */
- EVENTHANDLER_INVOKE(thread_dtor, td);
+ EVENTHANDLER_STATIC_INVOKE(thread_dtor, td);
}
- EVENTHANDLER_INVOKE(process_dtor, p);
+ EVENTHANDLER_STATIC_INVOKE(process_dtor, p);
if (p->p_ksi != NULL)
KASSERT(! KSI_ONQ(p->p_ksi), ("SIGCHLD queue"));
SDT_PROBE3(proc, , dtor, return, p, size, arg);
@@ -256,7 +264,7 @@ proc_init(void *mem, int size, int flags)
cv_init(&p->p_pwait, "ppwait");
cv_init(&p->p_dbgwait, "dbgwait");
TAILQ_INIT(&p->p_threads); /* all threads in proc */
- EVENTHANDLER_INVOKE(process_init, p);
+ EVENTHANDLER_STATIC_INVOKE(process_init, p);
p->p_stats = pstats_alloc();
p->p_pgrp = NULL;
SDT_PROBE3(proc, , init, return, p, size, flags);
@@ -274,7 +282,7 @@ proc_fini(void *mem, int size)
struct proc *p;
p = (struct proc *)mem;
- EVENTHANDLER_INVOKE(process_fini, p);
+ EVENTHANDLER_STATIC_INVOKE(process_fini, p);
pstats_free(p->p_stats);
thread_free(FIRST_THREAD_IN_PROC(p));
mtx_destroy(&p->p_mtx);
diff --git a/sys/kern/kern_thread.c b/sys/kern/kern_thread.c
index d3e7e306a68..92553f60678 100644
--- a/sys/kern/kern_thread.c
+++ b/sys/kern/kern_thread.c
@@ -144,6 +144,11 @@ struct tidhashhead *tidhashtbl;
u_long tidhash;
struct rwlock tidhash_lock;
+EVENTHANDLER_STATIC_DEFINE(thread_ctor, thread_ctor_fn);
+EVENTHANDLER_STATIC_DEFINE(thread_dtor, thread_dtor_fn);
+EVENTHANDLER_STATIC_DEFINE(thread_init, thread_init_fn);
+EVENTHANDLER_STATIC_DEFINE(thread_fini, thread_fini_fn);
+
static lwpid_t
tid_alloc(void)
{
@@ -201,7 +206,7 @@ thread_ctor(void *mem, int size, void *arg, int flags)
*/
td->td_critnest = 1;
td->td_lend_user_pri = PRI_MAX;
- EVENTHANDLER_INVOKE(thread_ctor, td);
+ EVENTHANDLER_STATIC_INVOKE(thread_ctor, td);
#ifdef AUDIT
audit_thread_alloc(td);
#endif
@@ -247,7 +252,7 @@ thread_dtor(void *mem, int size, void *arg)
td_softdep_cleanup(td);
MPASS(td->td_su == NULL);
- EVENTHANDLER_INVOKE(thread_dtor, td);
+ EVENTHANDLER_STATIC_INVOKE(thread_dtor, td);
tid_free(td->td_tid);
}
@@ -264,7 +269,7 @@ thread_init(void *mem, int size, int flags)
td->td_sleepqueue = sleepq_alloc();
td->td_turnstile = turnstile_alloc();
td->td_rlqe = NULL;
- EVENTHANDLER_INVOKE(thread_init, td);
+ EVENTHANDLER_STATIC_INVOKE(thread_init, td);
umtx_thread_init(td);
td->td_kstack = 0;
td->td_sel = NULL;
@@ -280,7 +285,7 @@ thread_fini(void *mem, int size)
struct thread *td;
td = (struct thread *)mem;
- EVENTHANDLER_INVOKE(thread_fini, td);
+ EVENTHANDLER_STATIC_INVOKE(thread_fini, td);
rlqentry_free(td->td_rlqe);
turnstile_free(td->td_turnstile);
sleepq_free(td->td_sleepqueue);
diff --git a/sys/kern/kern_time.c b/sys/kern/kern_time.c
index 92672438253..29909e7f509 100644
--- a/sys/kern/kern_time.c
+++ b/sys/kern/kern_time.c
@@ -1102,9 +1102,9 @@ itimer_start(void)
p31b_setcfg(CTL_P1003_1B_TIMERS, 200112L);
p31b_setcfg(CTL_P1003_1B_DELAYTIMER_MAX, INT_MAX);
p31b_setcfg(CTL_P1003_1B_TIMER_MAX, TIMER_MAX);
- EVENTHANDLER_REGISTER(process_exit, itimers_event_hook_exit,
+ EVENTHANDLER_STATIC_REGISTER(process_exit, itimers_event_hook_exit,
(void *)ITIMER_EV_EXIT, EVENTHANDLER_PRI_ANY);
- EVENTHANDLER_REGISTER(process_exec, itimers_event_hook_exec,
+ EVENTHANDLER_STATIC_REGISTER(process_exec, itimers_event_hook_exec,
(void *)ITIMER_EV_EXEC, EVENTHANDLER_PRI_ANY);
}
diff --git a/sys/kern/kern_umtx.c b/sys/kern/kern_umtx.c
index d72c57d5f59..b4ac3007295 100644
--- a/sys/kern/kern_umtx.c
+++ b/sys/kern/kern_umtx.c
@@ -448,7 +448,7 @@ umtxq_sysinit(void *arg __unused)
umtx_init_profiling();
#endif
mtx_init(&umtx_lock, "umtx lock", NULL, MTX_DEF);
- EVENTHANDLER_REGISTER(process_exec, umtx_exec_hook, NULL,
+ EVENTHANDLER_STATIC_REGISTER(process_exec, umtx_exec_hook, NULL,
EVENTHANDLER_PRI_ANY);
umtx_shm_init();
}
diff --git a/sys/kern/sysv_sem.c b/sys/kern/sysv_sem.c
index 60688960e24..e57543c0117 100644
--- a/sys/kern/sysv_sem.c
+++ b/sys/kern/sysv_sem.c
@@ -302,7 +302,7 @@ seminit(void)
LIST_INIT(&semu_list);
mtx_init(&sem_mtx, "sem", NULL, MTX_DEF);
mtx_init(&sem_undo_mtx, "semu", NULL, MTX_DEF);
- semexit_tag = EVENTHANDLER_REGISTER(process_exit, semexit_myhook, NULL,
+ semexit_tag = EVENTHANDLER_STATIC_REGISTER(process_exit, semexit_myhook, NULL,
EVENTHANDLER_PRI_ANY);
/* Set current prisons according to their allow.sysvipc. */
@@ -352,7 +352,7 @@ semunload(void)
syscall32_helper_unregister(sem32_syscalls);
#endif
syscall_helper_unregister(sem_syscalls);
- EVENTHANDLER_DEREGISTER(process_exit, semexit_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exit, semexit_tag);
if (sem_prison_slot != 0)
osd_jail_deregister(sem_prison_slot);
#ifdef MAC
diff --git a/sys/kern/uipc_mqueue.c b/sys/kern/uipc_mqueue.c
index f299858708c..8c16eed21fc 100644
--- a/sys/kern/uipc_mqueue.c
+++ b/sys/kern/uipc_mqueue.c
@@ -682,7 +682,7 @@ mqfs_init(struct vfsconf *vfc)
mqfs_fileno_init(mi);
mqfs_fileno_alloc(mi, root);
mqfs_fixup_dir(root);
- exit_tag = EVENTHANDLER_REGISTER(process_exit, mq_proc_exit, NULL,
+ exit_tag = EVENTHANDLER_STATIC_REGISTER(process_exit, mq_proc_exit, NULL,
EVENTHANDLER_PRI_ANY);
mq_fdclose = mqueue_fdclose;
p31b_setcfg(CTL_P1003_1B_MESSAGE_PASSING, _POSIX_MESSAGE_PASSING);
@@ -701,7 +701,7 @@ mqfs_uninit(struct vfsconf *vfc)
if (!unloadable)
return (EOPNOTSUPP);
osd_jail_deregister(mqfs_osd_jail_slot);
- EVENTHANDLER_DEREGISTER(process_exit, exit_tag);
+ EVENTHANDLER_STATIC_DEREGISTER(process_exit, exit_tag);
mi = &mqfs_data;
mqfs_destroy(mi->mi_root);
mi->mi_root = NULL;
diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 302ab9e3b13..e47861cd32b 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -399,9 +399,9 @@ aio_onceonly(void)
if (aio_listio_max > MIN(MAX_AIO_QUEUE_PER_PROC, max_queue_count))
aio_listio_max = MIN(MAX_AIO_QUEUE_PER_PROC, max_queue_count);
- exit_tag = EVENTHANDLER_REGISTER(process_exit, aio_proc_rundown, NULL,
+ exit_tag = EVENTHANDLER_STATIC_REGISTER(process_exit, aio_proc_rundown, NULL,
EVENTHANDLER_PRI_ANY);
- exec_tag = EVENTHANDLER_REGISTER(process_exec, aio_proc_rundown_exec,
+ exec_tag = EVENTHANDLER_STATIC_REGISTER(process_exec, aio_proc_rundown_exec,
NULL, EVENTHANDLER_PRI_ANY);
kqueue_add_filteropts(EVFILT_AIO, &aio_filtops);
kqueue_add_filteropts(EVFILT_LIO, &lio_filtops);
diff --git a/sys/sys/eventhandler.h b/sys/sys/eventhandler.h
index 7fccffffa8a..aa744f98a69 100644
--- a/sys/sys/eventhandler.h
+++ b/sys/sys/eventhandler.h
@@ -97,11 +97,57 @@ typedef struct eventhandler_entry *eventhandler_tag;
EHL_UNLOCK((list)); \
} while (0)
+
+/*
+ * Static event handler lists require the eventhandler list be present at link
+ * time. They don't allow addition of entries to unknown eventhandler lists.
+ *
+ * Static handler lists must be defined once by the "owner" of the eventhandler
+ * list, and the declaration must be in scope at any point the list is
+ * manipulated.
+ */
+#define EVENTHANDLER_STATIC_DECLARE(name, type) \
+extern struct eventhandler_list Xeventhandler_list_ ## name ; \
+struct eventhandler_entry_ ## name { \
+ struct eventhandler_entry ee; \
+ type eh_func; \
+}; \
+struct __hack
+
+#define EVENTHANDLER_STATIC_DEFINE(name, type) \
+struct eventhandler_list Xeventhandler_list_ ## name = { #name }; \
+struct __hack
+
+#define EVENTHANDLER_STATIC_INVOKE(name, ...) \
+do { \
+ struct eventhandler_list *_el = &Xeventhandler_list_ ## name ; \
+ \
+ if (_el->el_flags & EHL_INITTED) { \
+ EHL_LOCK(_el); \
+ _EVENTHANDLER_INVOKE(name, _el , ## __VA_ARGS__); \
+ } \
+} while (0)
+
+#define EVENTHANDLER_STATIC_REGISTER(name, func, arg, priority) \
+ eventhandler_register(&Xeventhandler_list_ ## name, \
+ #name, func, arg, priority)
+
+#define EVENTHANDLER_STATIC_DEREGISTER(name, tag) \
+do { \
+ struct eventhandler_list *_el = &Xeventhandler_list_ ## name ; \
+ \
+ KASSERT(_el->el_flags & EHL_INITTED, \
+ ("eventhandler_fast_deregister on un-inited list %s", \
+ #name)); \
+ EHL_LOCK(_el); \
+ eventhandler_deregister(_el, tag); \
+} while (0)
+
/*
- * Slow handlers are entirely dynamic; lists are created
+ * Non-static handlers are entirely dynamic; lists are created
* when entries are added to them, and thus have no concept of "owner",
*
- * Slow handlers need to be declared, but do not need to be defined. The
+ * These handlers need to be declared, but do not need to be defined. The
* declaration must be in scope wherever the handler is to be invoked.
*/
#define EVENTHANDLER_DECLARE(name, type) \
@@ -228,13 +274,13 @@ typedef void (*proc_ctor_fn)(void *, struct proc *);
typedef void (*proc_dtor_fn)(void *, struct proc *);
typedef void (*proc_init_fn)(void *, struct proc *);
typedef void (*proc_fini_fn)(void *, struct proc *);
-EVENTHANDLER_DECLARE(process_ctor, proc_ctor_fn);
-EVENTHANDLER_DECLARE(process_dtor, proc_dtor_fn);
-EVENTHANDLER_DECLARE(process_init, proc_init_fn);
-EVENTHANDLER_DECLARE(process_fini, proc_fini_fn);
-EVENTHANDLER_DECLARE(process_exit, exitlist_fn);
-EVENTHANDLER_DECLARE(process_fork, forklist_fn);
-EVENTHANDLER_DECLARE(process_exec, execlist_fn);
+EVENTHANDLER_STATIC_DECLARE(process_ctor, proc_ctor_fn);
+EVENTHANDLER_STATIC_DECLARE(process_dtor, proc_dtor_fn);
+EVENTHANDLER_STATIC_DECLARE(process_init, proc_init_fn);
+EVENTHANDLER_STATIC_DECLARE(process_fini, proc_fini_fn);
+EVENTHANDLER_STATIC_DECLARE(process_exit, exitlist_fn);
+EVENTHANDLER_STATIC_DECLARE(process_fork, forklist_fn);
+EVENTHANDLER_STATIC_DECLARE(process_exec, execlist_fn);
/*
* application dump event
@@ -253,10 +299,10 @@ typedef void (*thread_ctor_fn)(void *, struct thread *);
typedef void (*thread_dtor_fn)(void *, struct thread *);
typedef void (*thread_fini_fn)(void *, struct thread *);
typedef void (*thread_init_fn)(void *, struct thread *);
-EVENTHANDLER_DECLARE(thread_ctor, thread_ctor_fn);
-EVENTHANDLER_DECLARE(thread_dtor, thread_dtor_fn);
-EVENTHANDLER_DECLARE(thread_init, thread_init_fn);
-EVENTHANDLER_DECLARE(thread_fini, thread_fini_fn);
+EVENTHANDLER_STATIC_DECLARE(thread_ctor, thread_ctor_fn);
+EVENTHANDLER_STATIC_DECLARE(thread_dtor, thread_dtor_fn);
+EVENTHANDLER_STATIC_DECLARE(thread_init, thread_init_fn);
+EVENTHANDLER_STATIC_DECLARE(thread_fini, thread_fini_fn);
typedef void (*uma_zone_chfn)(void *);
EVENTHANDLER_DECLARE(nmbclusters_change, uma_zone_chfn);
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1164338
Default Alt Text
Masterwork From Distant Lands (23 KB)
Attached To
Mode
P147 Masterwork From Distant Lands
Attached
Detach File
Event Timeline
Log In to Comment