MINOR: initcall: use initcalls for most post_{check,deinit} and per_thread*
Most calls to hap_register_post_check(), hap_register_post_deinit(),
hap_register_per_thread_init(), hap_register_per_thread_deinit() can
be done using initcalls and will not require a constructor anymore.
Let's create a set of simplified macros for this, called respectively
REGISTER_POST_CHECK, REGISTER_POST_DEINIT, REGISTER_PER_THREAD_INIT,
and REGISTER_PER_THREAD_DEINIT.
Some files were not modified because they wouldn't benefit from this
or because they conditionally register (e.g. the pollers).
diff --git a/src/chunk.c b/src/chunk.c
index 303d3fd..fa3fb71 100644
--- a/src/chunk.c
+++ b/src/chunk.c
@@ -92,10 +92,6 @@
/* Initialize the trash buffers. It returns 0 if an error occurred. */
int init_trash_buffers(int first)
{
- if (!first) {
- hap_register_per_thread_init(init_trash_buffers_per_thread);
- hap_register_per_thread_deinit(deinit_trash_buffers_per_thread);
- }
pool_destroy(pool_head_trash);
pool_head_trash = create_pool("trash",
sizeof(struct buffer) + global.tune.bufsize,
@@ -320,6 +316,9 @@
return diff;
}
+REGISTER_PER_THREAD_INIT(init_trash_buffers_per_thread);
+REGISTER_PER_THREAD_DEINIT(deinit_trash_buffers_per_thread);
+
/*
* Local variables:
* c-indent-level: 8