]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: init: convert all trivial registration calls to initcalls
authorWilly Tarreau <w@1wt.eu>
Sun, 25 Nov 2018 18:14:37 +0000 (19:14 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 26 Nov 2018 18:50:32 +0000 (19:50 +0100)
This switches explicit calls to various trivial registration methods for
keywords, muxes or protocols from constructors to INITCALL1 at stage
STG_REGISTER. All these calls have in common to consume a single pointer
and return void. Doing this removes 26 constructors. The following calls
were addressed :

- acl_register_keywords
- bind_register_keywords
- cfg_register_keywords
- cli_register_kw
- flt_register_keywords
- http_req_keywords_register
- http_res_keywords_register
- protocol_register
- register_mux_proto
- sample_register_convs
- sample_register_fetches
- srv_register_keywords
- tcp_req_conn_keywords_register
- tcp_req_cont_keywords_register
- tcp_req_sess_keywords_register
- tcp_res_cont_keywords_register
- flt_register_keywords

43 files changed:
doc/internals/filters.txt
src/51d.c
src/acl.c
src/activity.c
src/backend.c
src/cache.c
src/cli.c
src/compression.c
src/connection.c
src/da.c
src/dns.c
src/filters.c
src/flt_http_comp.c
src/flt_spoe.c
src/flt_trace.c
src/frontend.c
src/hlua.c
src/http_acl.c
src/http_act.c
src/http_conv.c
src/http_fetch.c
src/listener.c
src/log.c
src/map.c
src/memory.c
src/mux_h1.c
src/mux_h2.c
src/mux_pt.c
src/payload.c
src/proto_sockpair.c
src/proto_tcp.c
src/proto_uxst.c
src/proxy.c
src/queue.c
src/sample.c
src/server.c
src/ssl_sock.c
src/stats.c
src/stick_table.c
src/stream.c
src/tcp_rules.c
src/vars.c
src/wurfl.c

index 61a01553ff7eba7fb2575ba6c63c5c1a84097add..09090e556f6fc5afd69dfcd259056ecfccbf5680 100644 (file)
@@ -353,13 +353,7 @@ line:
             { NULL, NULL, NULL },
         }
     };
-
-    __attribute__((constructor))
-    static void
-    __my_filter_init(void)
-    {
-        flt_register_keywords(&flt_kws);
-    }
+    INITCALL1(STG_REGISTER, flt_register_keywords, &flt_kws);
 
 
 Then you must define the internal configuration your filter will use. For
index e092c5ba83294dade6a38f98916cb2045ad2e4ea..d537964880cb9fadaed54239d599e3a1edc266c8 100644 (file)
--- a/src/51d.c
+++ b/src/51d.c
@@ -4,6 +4,7 @@
 #include <common/chunk.h>
 #include <common/buffer.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <proto/arg.h>
 #include <proto/http_fetch.h>
 #include <proto/log.h>
@@ -667,25 +668,28 @@ static struct cfg_kw_list _51dcfg_kws = {{ }, {
        { 0, NULL, NULL },
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &_51dcfg_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
        { "51d.all", _51d_fetch, ARG5(1,STR,STR,STR,STR,STR), _51d_fetch_check, SMP_T_STR, SMP_USE_HRQHV },
        { NULL, NULL, 0, 0, 0 },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_conv_kw_list conv_kws = {ILH, {
        { "51d.single", _51d_conv, ARG5(1,STR,STR,STR,STR,STR), _51d_conv_check, SMP_T_STR, SMP_T_STR },
        { NULL, NULL, 0, 0, 0 },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws);
+
 __attribute__((constructor))
 static void __51d_init(void)
 {
        /* register sample fetch and conversion keywords */
-       sample_register_fetches(&sample_fetch_keywords);
-       sample_register_convs(&conv_kws);
-       cfg_register_keywords(&_51dcfg_kws);
        hap_register_build_opts("Built with 51Degrees support.", 0);
        hap_register_post_check(init_51degrees);
        hap_register_post_deinit(deinit_51degrees);
index a9cf7a15e83970ac6b0bc5e8aa468a862b9aa5cf..b598088ad14014d665d82917e68fab58f25fd46d 100644 (file)
--- a/src/acl.c
+++ b/src/acl.c
@@ -15,6 +15,7 @@
 #include <string.h>
 
 #include <common/config.h>
+#include <common/initcall.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
 #include <common/uri_auth.h>
@@ -1352,12 +1353,7 @@ static struct acl_kw_list acl_kws = {ILH, {
        { /* END */ },
 }};
 
-__attribute__((constructor))
-static void __acl_init(void)
-{
-       acl_register_keywords(&acl_kws);
-}
-
+INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws);
 
 /*
  * Local variables:
index 9460a8a7e95a9071ea8c994c976154a24a7935a3..4a807c8e4a57830153f40863a80519d60aa1093b 100644 (file)
@@ -14,6 +14,7 @@
 #include <common/config.h>
 #include <common/standard.h>
 #include <common/hathreads.h>
+#include <common/initcall.h>
 #include <types/activity.h>
 #include <proto/channel.h>
 #include <proto/cli.h>
@@ -116,6 +117,8 @@ static struct cfg_kw_list cfg_kws = {ILH, {
        { 0, NULL, NULL }
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 /* register cli keywords */
 static struct cli_kw_list cli_kws = {{ },{
        { { "show", "profiling", NULL }, "show profiling : show CPU profiling options",   NULL, cli_io_handler_show_profiling, NULL },
@@ -123,9 +126,4 @@ static struct cli_kw_list cli_kws = {{ },{
        {{},}
 }};
 
-__attribute__((constructor))
-static void __activity_init(void)
-{
-       cfg_register_keywords(&cfg_kws);
-       cli_register_kw(&cli_kws);
-}
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
index e55d87c346016e0c85bb90920007a2cb59345795..5aaa46d61ab8f8180965929e818d7eec3e5c643e 100644 (file)
@@ -24,6 +24,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/hash.h>
+#include <common/initcall.h>
 #include <common/ticks.h>
 #include <common/time.h>
 #include <common/namespace.h>
@@ -2073,12 +2074,15 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_conv_kw_list sample_conv_kws = {ILH, {
        { "nbsrv", sample_conv_nbsrv, 0, NULL, SMP_T_STR, SMP_T_SINT },
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
 
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted.
@@ -2087,14 +2091,7 @@ static struct acl_kw_list acl_kws = {ILH, {
        { /* END */ },
 }};
 
-
-__attribute__((constructor))
-static void __backend_init(void)
-{
-       sample_register_fetches(&smp_kws);
-       sample_register_convs(&sample_conv_kws);
-       acl_register_keywords(&acl_kws);
-}
+INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws);
 
 /*
  * Local variables:
index 21574339d79eca752e66f896344a855b8b1f0987..acab99da0f9487055695972622a3f5794c5d44d5 100644 (file)
@@ -34,6 +34,7 @@
 
 #include <common/cfgparse.h>
 #include <common/hash.h>
+#include <common/initcall.h>
 
 /* flt_cache_store */
 
@@ -1184,6 +1185,7 @@ static struct cli_kw_list cli_kws = {{},{
        {{},}
 }};
 
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
 
 static struct action_kw_list http_res_actions = {
        .kw = {
@@ -1192,6 +1194,8 @@ static struct action_kw_list http_res_actions = {
        }
 };
 
+INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions);
+
 static struct action_kw_list http_req_actions = {
        .kw = {
                { "cache-use", parse_cache_use },
@@ -1199,6 +1203,8 @@ static struct action_kw_list http_req_actions = {
        }
 };
 
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions);
+
 struct applet http_cache_applet = {
        .obj_type = OBJ_TYPE_APPLET,
        .name = "<CACHE>", /* used for logging */
@@ -1211,9 +1217,5 @@ static void __cache_init(void)
 {
        cfg_register_section("cache", cfg_parse_cache, cfg_post_parse_section_cache);
        cfg_register_postparser("cache", cfg_cache_postparser);
-       cli_register_kw(&cli_kws);
-       http_res_keywords_register(&http_res_actions);
-       http_req_keywords_register(&http_req_actions);
        pool_head_cache_st = create_pool("cache_st", sizeof(struct cache_st), MEM_F_SHARED);
 }
-
index 3f438621aa39c74ff35b0e833d2bbb47f0927af7..b8b233509a48f33fbfba255ead7ba9ca9991ac2b 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -30,6 +30,7 @@
 #include <common/compat.h>
 #include <common/config.h>
 #include <common/debug.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
@@ -2449,11 +2450,15 @@ static struct cli_kw_list cli_kws = {{ },{
        {{},}
 }};
 
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
+
 static struct cfg_kw_list cfg_kws = {ILH, {
        { CFG_GLOBAL, "stats", stats_parse_global },
        { 0, NULL, NULL },
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 static struct bind_kw_list bind_kws = { "STAT", { }, {
        { "level",     bind_parse_level,    1 }, /* set the unix socket admin level */
        { "expose-fd", bind_parse_expose_fd, 1 }, /* set the unix socket expose fd rights */
@@ -2461,13 +2466,7 @@ static struct bind_kw_list bind_kws = { "STAT", { }, {
        { NULL, NULL, 0 },
 }};
 
-__attribute__((constructor))
-static void __dumpstats_module_init(void)
-{
-       cfg_register_keywords(&cfg_kws);
-       cli_register_kw(&cli_kws);
-       bind_register_keywords(&bind_kws);
-}
+INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws);
 
 /*
  * Local variables:
index d3e6f28169d02fff62d9964780707e3ce27f7a65..b725e3130589645a51ea86c4d3e201126d8a8ca8 100644 (file)
@@ -28,8 +28,9 @@
 
 #include <common/cfgparse.h>
 #include <common/compat.h>
-#include <common/memory.h>
 #include <common/hathreads.h>
+#include <common/initcall.h>
+#include <common/memory.h>
 
 #include <types/global.h>
 #include <types/compression.h>
@@ -699,6 +700,8 @@ static struct cfg_kw_list cfg_kws = {ILH, {
        { 0, NULL, NULL }
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 __attribute__((constructor))
 static void __comp_fetch_init(void)
 {
@@ -735,5 +738,4 @@ static void __comp_fetch_init(void)
                memprintf(&ptr, "%s none", ptr);
 
        hap_register_build_opts(ptr, 1);
-       cfg_register_keywords(&cfg_kws);
 }
index 5022772906b5659c9abba7c8b20584b13d403c06..621477557d2cdfe3fb7e99fa0df898d8aab72b17 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <common/compat.h>
 #include <common/config.h>
+#include <common/initcall.h>
 #include <common/namespace.h>
 #include <common/hash.h>
 #include <common/net_helper.h>
@@ -1314,9 +1315,4 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
        { /* END */ },
 }};
 
-
-__attribute__((constructor))
-static void __connection_init(void)
-{
-       sample_register_fetches(&sample_fetch_keywords);
-}
+INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
index 990267a3c1e80b58d3620312210da69246463340..c1c07e397a8324800b4931728e5ffa2c7a8ff5a3 100644 (file)
--- a/src/da.c
+++ b/src/da.c
@@ -3,6 +3,7 @@
 #include <common/cfgparse.h>
 #include <common/errors.h>
 #include <common/http.h>
+#include <common/initcall.h>
 #include <proto/arg.h>
 #include <proto/http_fetch.h>
 #include <proto/log.h>
@@ -376,25 +377,28 @@ static struct cfg_kw_list dacfg_kws = {{ }, {
        { 0, NULL, NULL },
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &dacfg_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_fetch_kw_list fetch_kws = {ILH, {
        { "da-csv-fetch", da_haproxy_fetch, ARG12(1,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_USE_HRQHV },
        { NULL, NULL, 0, 0, 0 },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &fetch_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_conv_kw_list conv_kws = {ILH, {
        { "da-csv-conv", da_haproxy_conv, ARG12(1,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR,STR), NULL, SMP_T_STR, SMP_T_STR },
        { NULL, NULL, 0, 0, 0 },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws);
+
 __attribute__((constructor))
 static void __da_init(void)
 {
        /* register sample fetch and format conversion keywords */
-       sample_register_fetches(&fetch_kws);
-       sample_register_convs(&conv_kws);
-       cfg_register_keywords(&dacfg_kws);
        hap_register_build_opts("Built with DeviceAtlas support.", 0);
        hap_register_post_check(init_deviceatlas);
        hap_register_post_deinit(deinit_deviceatlas);
index 5bce18b030a2bdd18403b357cc9e8aec795ff7d2..2dfbdd58782dc430e930879fef4cfc92dd5fc739 100644 (file)
--- a/src/dns.c
+++ b/src/dns.c
@@ -21,6 +21,7 @@
 
 #include <common/cfgparse.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <common/time.h>
 #include <common/ticks.h>
 #include <common/net_helper.h>
@@ -2050,6 +2051,7 @@ static struct cli_kw_list cli_kws = {{ }, {
        }
 };
 
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
 
 __attribute__((constructor))
 static void __dns_init(void)
@@ -2059,6 +2061,4 @@ static void __dns_init(void)
 
        cfg_register_postparser("dns runtime resolver", dns_finalize_config);
        hap_register_post_deinit(dns_deinit);
-
-       cli_register_kw(&cli_kws);
 }
index bdc106a6ea05e4ff91299e36980563604b51edc4..edce6038032eb74920480f08cee261fea74d64b5 100644 (file)
@@ -16,6 +16,7 @@
 #include <common/compat.h>
 #include <common/config.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <common/namespace.h>
 #include <common/standard.h>
 #include <common/hathreads.h>
@@ -1189,12 +1190,13 @@ static struct cfg_kw_list cfg_kws = {ILH, {
        }
 };
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 __attribute__((constructor))
 static void
 __filters_init(void)
 {
         pool_head_filter = create_pool("filter", sizeof(struct filter), MEM_F_SHARED);
-       cfg_register_keywords(&cfg_kws);
        hap_register_post_check(flt_init_all);
        hap_register_per_thread_init(flt_init_all_per_thread);
        hap_register_per_thread_deinit(flt_deinit_all_per_thread);
index b4f093c2a78616cdf6254edb89374c3d8a191b89..e0cee75b4f479fb0df4fca92df1fdbc0d54d7365 100644 (file)
@@ -12,6 +12,7 @@
 
 #include <common/buffer.h>
 #include <common/cfgparse.h>
+#include <common/initcall.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
 
@@ -993,6 +994,8 @@ static struct cfg_kw_list cfg_kws = {ILH, {
        }
 };
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 /* Declare the filter parser for "compression" keyword */
 static struct flt_kw_list filter_kws = { "COMP", { }, {
                { "compression", parse_http_comp_flt, NULL },
@@ -1000,6 +1003,8 @@ static struct flt_kw_list filter_kws = { "COMP", { }, {
        }
 };
 
+INITCALL1(STG_REGISTER, flt_register_keywords, &filter_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
                { "res.comp",      smp_fetch_res_comp,      0, NULL, SMP_T_BOOL, SMP_USE_HRSHP },
@@ -1008,12 +1013,11 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
        }
 };
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
+
 __attribute__((constructor))
 static void
 __flt_http_comp_init(void)
 {
-       cfg_register_keywords(&cfg_kws);
-       flt_register_keywords(&filter_kws);
-       sample_register_fetches(&sample_fetch_keywords);
        pool_head_comp_state = create_pool("comp_state", sizeof(struct comp_state), MEM_F_SHARED);
 }
index 02bc3d2e7971e00fc90ca8f6f13965f39e7acfd4..aa9d8750f855df8cde0f297e89fae1e8456c9866 100644 (file)
 #include <common/compat.h>
 #include <common/config.h>
 #include <common/debug.h>
+#include <common/hathreads.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/time.h>
-#include <common/hathreads.h>
 
 #include <types/arg.h>
 #include <types/global.h>
@@ -4641,37 +4642,44 @@ static struct flt_kw_list flt_kws = { "SPOE", { }, {
        }
 };
 
+INITCALL1(STG_REGISTER, flt_register_keywords, &flt_kws);
+
 /* Delcate the action parser for "spoe-action" keyword */
 static struct action_kw_list tcp_req_action_kws = { { }, {
                { "send-spoe-group", parse_send_spoe_group },
                { /* END */ },
        }
 };
+
+INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_action_kws);
+
 static struct action_kw_list tcp_res_action_kws = { { }, {
                { "send-spoe-group", parse_send_spoe_group },
                { /* END */ },
        }
 };
+
+INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_action_kws);
+
 static struct action_kw_list http_req_action_kws = { { }, {
                { "send-spoe-group", parse_send_spoe_group },
                { /* END */ },
        }
 };
+
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_action_kws);
+
 static struct action_kw_list http_res_action_kws = { { }, {
                { "send-spoe-group", parse_send_spoe_group },
                { /* END */ },
        }
 };
 
+INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_action_kws);
+
 __attribute__((constructor))
 static void __spoe_init(void)
 {
-       flt_register_keywords(&flt_kws);
-       tcp_req_cont_keywords_register(&tcp_req_action_kws);
-       tcp_res_cont_keywords_register(&tcp_res_action_kws);
-       http_req_keywords_register(&http_req_action_kws);
-       http_res_keywords_register(&http_res_action_kws);
-
        pool_head_spoe_ctx = create_pool("spoe_ctx", sizeof(struct spoe_context), MEM_F_SHARED);
        pool_head_spoe_appctx = create_pool("spoe_appctx", sizeof(struct spoe_appctx), MEM_F_SHARED);
 }
index 6b65fe9389ef7b5009466d4a5439b71cb2732f63..d5a4d93e4938876e58d04d624bd3414ac54c8ca9 100644 (file)
 
 #include <ctype.h>
 
+#include <common/hathreads.h>
+#include <common/initcall.h>
 #include <common/standard.h>
 #include <common/time.h>
 #include <common/tools.h>
-#include <common/hathreads.h>
 
 #include <types/channel.h>
 #include <types/filters.h>
@@ -628,9 +629,4 @@ static struct flt_kw_list flt_kws = { "TRACE", { }, {
        }
 };
 
-__attribute__((constructor))
-static void
-__flt_trace_init(void)
-{
-       flt_register_keywords(&flt_kws);
-}
+INITCALL1(STG_REGISTER, flt_register_keywords, &flt_kws);
index 65c696601f9dc5b5976e984638a6d997cc4afc3e..716725746085fb7ee7fc3db540dbbadcc4561df8 100644 (file)
@@ -26,6 +26,7 @@
 #include <common/compat.h>
 #include <common/config.h>
 #include <common/debug.h>
+#include <common/initcall.h>
 #include <common/standard.h>
 #include <common/time.h>
 
@@ -263,6 +264,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws);
 
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted.
@@ -271,14 +273,7 @@ static struct acl_kw_list acl_kws = {ILH, {
        { /* END */ },
 }};
 
-
-__attribute__((constructor))
-static void __frontend_init(void)
-{
-       sample_register_fetches(&smp_kws);
-       acl_register_keywords(&acl_kws);
-}
-
+INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws);
 
 /*
  * Local variables:
index c354af89c95cd7a20c844ca2a4e19414b0c1414b..d34aa798d8ec610673bf415d3f28215d13d0832b 100644 (file)
@@ -26,8 +26,9 @@
 
 #include <common/cfgparse.h>
 #include <common/compiler.h>
-#include <common/xref.h>
 #include <common/hathreads.h>
+#include <common/initcall.h>
+#include <common/xref.h>
 
 #include <types/cli.h>
 #include <types/hlua.h>
@@ -7520,6 +7521,8 @@ static struct cfg_kw_list cfg_kws = {{ },{
        { 0, NULL, NULL },
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 static int hlua_check_config()
 {
        struct proxy *px;
@@ -7672,9 +7675,6 @@ void hlua_init(void)
        /* Initialise struct hlua and com signals pool */
        pool_head_hlua = create_pool("hlua", sizeof(struct hlua), MEM_F_SHARED);
 
-       /* Register configuration keywords. */
-       cfg_register_keywords(&cfg_kws);
-
        /* Init main lua stack. */
        gL.Mref = LUA_REFNIL;
        gL.flags = 0;
index 7864df89feac39fb35ce9ac0093778176a02d592..edd3be579f684d5a52436232c070acfedd8674a2 100644 (file)
@@ -21,6 +21,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/http.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/standard.h>
 #include <common/version.h>
@@ -180,11 +181,7 @@ static struct acl_kw_list acl_kws = {ILH, {
        { /* END */ },
 }};
 
-__attribute__((constructor))
-static void __http_acl_init(void)
-{
-       acl_register_keywords(&acl_kws);
-}
+INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws);
 
 /*
  * Local variables:
index 8ca6ba482767f8addf3bf61baeb428ee66420804..37cf4350ad2b66d10ad1472b2eda2f5722bbeff0 100644 (file)
@@ -21,6 +21,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/http.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/standard.h>
 #include <common/version.h>
@@ -586,6 +587,8 @@ static struct action_kw_list http_req_actions = {
        }
 };
 
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions);
+
 static struct action_kw_list http_res_actions = {
        .kw = {
                { "capture",    parse_http_res_capture },
@@ -594,12 +597,7 @@ static struct action_kw_list http_res_actions = {
        }
 };
 
-__attribute__((constructor))
-static void __http_act_init(void)
-{
-       http_req_keywords_register(&http_req_actions);
-       http_res_keywords_register(&http_res_actions);
-}
+INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions);
 
 /*
  * Local variables:
index c6cfdab39fc4a8ffbd2a6831af62c79039ecf8a5..93b748c2f0ec6b34c8f486d3dfe361c83a4369f8 100644 (file)
@@ -21,6 +21,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/http.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/standard.h>
 #include <common/version.h>
@@ -335,11 +336,7 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
        { NULL, NULL, 0, 0, 0 },
 }};
 
-__attribute__((constructor))
-static void __http_conv_init(void)
-{
-       sample_register_convs(&sample_conv_kws);
-}
+INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
 
 /*
  * Local variables:
index 56c6a2bf90323c961517a2cdf78aba66661f9d7b..38905095962b931cc1694b042d67cbeed28cc030 100644 (file)
@@ -22,6 +22,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/http.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/standard.h>
 #include <common/version.h>
@@ -2851,12 +2852,7 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
        { /* END */ },
 }};
 
-
-__attribute__((constructor))
-static void __http_fetch_init(void)
-{
-       sample_register_fetches(&sample_fetch_keywords);
-}
+INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
 
 /*
  * Local variables:
index a730b18326a8728f7246ff8e59ad26d2b79f504c..2a38cfd2bd16f9eecb64ebcc1646d7eeac2cca15 100644 (file)
@@ -22,6 +22,7 @@
 #include <common/cfgparse.h>
 #include <common/config.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
 #include <common/time.h>
@@ -1013,6 +1014,8 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted.
  */
@@ -1020,6 +1023,8 @@ static struct acl_kw_list acl_kws = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted, doing so helps
  * all code contributors.
@@ -1040,12 +1045,11 @@ static struct bind_kw_list bind_kws = { "ALL", { }, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws);
+
 __attribute__((constructor))
 static void __listener_init(void)
 {
-       sample_register_fetches(&smp_kws);
-       acl_register_keywords(&acl_kws);
-       bind_register_keywords(&bind_kws);
        HA_SPIN_INIT(&lq_lock);
 }
 
index 3db3c0d9e4a2073dd71348be7ace0a1f14ee198a..5c6b8dfa9838f1891f0ca090ab3193f16e0d9c83 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -26,6 +26,7 @@
 
 #include <common/config.h>
 #include <common/compat.h>
+#include <common/initcall.h>
 #include <common/standard.h>
 #include <common/time.h>
 
@@ -2806,12 +2807,13 @@ static struct cli_kw_list cli_kws = {{ },{
        {{},}
 }};
 
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
+
 __attribute__((constructor))
 static void __log_init(void)
 {
        hap_register_per_thread_init(init_log_buffers_per_thread);
        hap_register_per_thread_deinit(deinit_log_buffers_per_thread);
-       cli_register_kw(&cli_kws);
 }
 /*
  * Local variables:
index 7eb9e3647ba15d9c2fcffe458b437b5e454be6e6..bfdb73d211e64035796f79096a2f26e1f2813eb8 100644 (file)
--- a/src/map.c
+++ b/src/map.c
@@ -13,6 +13,7 @@
 #include <limits.h>
 #include <stdio.h>
 
+#include <common/initcall.h>
 #include <common/standard.h>
 
 #include <types/applet.h>
@@ -1106,6 +1107,7 @@ static struct cli_kw_list cli_kws = {{ },{
        { { NULL }, NULL, NULL, NULL }
 }};
 
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
 
 /* Note: must not be declared <const> as its list will be overwritten
  *
@@ -1159,10 +1161,4 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
        { /* END */ },
 }};
 
-__attribute__((constructor))
-static void __map_init(void)
-{
-       /* register format conversion keywords */
-       sample_register_convs(&sample_conv_kws);
-       cli_register_kw(&cli_kws);
-}
+INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
index 17ac1d1f35b2f35be126f0ad41c3ffb118d2f275..1554243f08736cd30594f37cf66d64d43df50adc 100644 (file)
@@ -18,6 +18,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/hathreads.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
@@ -526,11 +527,7 @@ static struct cli_kw_list cli_kws = {{ },{
        {{},}
 }};
 
-__attribute__((constructor))
-static void __memory_init(void)
-{
-       cli_register_kw(&cli_kws);
-}
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
 
 /*
  * Local variables:
index 2e28d369e11ee23994e43f76d10671e975a9f3ab..c9bfaa3921033a85d1504a4ddee842e438c7106b 100644 (file)
@@ -11,6 +11,7 @@
  */
 #include <common/cfgparse.h>
 #include <common/config.h>
+#include <common/initcall.h>
 
 #include <types/pipe.h>
 #include <types/proxy.h>
@@ -1823,6 +1824,8 @@ const struct mux_ops mux_h1_ops = {
 static struct mux_proto_list mux_proto_htx =
 { .token = IST(""), .mode = PROTO_MODE_HTX, .side = PROTO_SIDE_BOTH, .mux = &mux_h1_ops };
 
+INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_htx);
+
 static void __h1_deinit(void)
 {
        pool_destroy(pool_head_h1c);
@@ -1832,7 +1835,6 @@ static void __h1_deinit(void)
 __attribute__((constructor))
 static void __h1_init(void)
 {
-       register_mux_proto(&mux_proto_htx);
        hap_register_post_deinit(__h1_deinit);
        pool_head_h1c = create_pool("h1c", sizeof(struct h1c), MEM_F_SHARED);
        pool_head_h1s = create_pool("h1s", sizeof(struct h1s), MEM_F_SHARED);
index 0407e3808bdd329932f21127ad8b8afb229d8635..c3cd1e12d5258510b67ca0071a7b820f4050d957 100644 (file)
@@ -16,6 +16,7 @@
 #include <common/hpack-dec.h>
 #include <common/hpack-enc.h>
 #include <common/hpack-tbl.h>
+#include <common/initcall.h>
 #include <common/net_helper.h>
 #include <proto/connection.h>
 #include <proto/h1.h>
@@ -3832,6 +3833,8 @@ const struct mux_ops h2_ops = {
 static struct mux_proto_list mux_proto_h2 =
        { .token = IST("h2"), .mode = PROTO_MODE_HTTP, .side = PROTO_SIDE_FE, .mux = &h2_ops };
 
+INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_h2);
+
 /* config keyword parsers */
 static struct cfg_kw_list cfg_kws = {ILH, {
        { CFG_GLOBAL, "tune.h2.header-table-size",      h2_parse_header_table_size      },
@@ -3840,6 +3843,8 @@ static struct cfg_kw_list cfg_kws = {ILH, {
        { 0, NULL, NULL }
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 static void __h2_deinit(void)
 {
        pool_destroy(pool_head_h2s);
@@ -3849,8 +3854,6 @@ static void __h2_deinit(void)
 __attribute__((constructor))
 static void __h2_init(void)
 {
-       register_mux_proto(&mux_proto_h2);
-       cfg_register_keywords(&cfg_kws);
        hap_register_post_deinit(__h2_deinit);
        pool_head_h2c = create_pool("h2c", sizeof(struct h2c), MEM_F_SHARED);
        pool_head_h2s = create_pool("h2s", sizeof(struct h2s), MEM_F_SHARED);
index a974ec30202f51d20897146fe3eb736dd506e49c..8e9c651fde71ce3e6c8c701e410798ebf173944d 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <common/config.h>
+#include <common/initcall.h>
 #include <proto/connection.h>
 #include <proto/stream.h>
 #include <proto/task.h>
@@ -316,10 +317,11 @@ const struct mux_ops mux_pt_ops = {
 static struct mux_proto_list mux_proto_pt =
        { .token = IST(""), .mode = PROTO_MODE_ANY, .side = PROTO_SIDE_BOTH, .mux = &mux_pt_ops };
 
+INITCALL1(STG_REGISTER, register_mux_proto, &mux_proto_pt);
+
 __attribute__((constructor))
 static void __mux_pt_init(void)
 {
-       register_mux_proto(&mux_proto_pt);
        pool_head_pt_ctx = create_pool("mux_pt", sizeof(struct mux_pt_ctx),
            MEM_F_SHARED);
 }
index 054168a51286b7cf864e13f4686049dbb8ca9efe..14191a7e20e0a758715904dec227e1c90040cae6 100644 (file)
@@ -13,6 +13,7 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <common/initcall.h>
 #include <common/net_helper.h>
 #include <proto/acl.h>
 #include <proto/arg.h>
@@ -1151,6 +1152,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws);
 
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted.
@@ -1166,13 +1168,7 @@ static struct acl_kw_list acl_kws = {ILH, {
        { /* END */ },
 }};
 
-
-__attribute__((constructor))
-static void __payload_init(void)
-{
-       sample_register_fetches(&smp_kws);
-       acl_register_keywords(&acl_kws);
-}
+INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws);
 
 /*
  * Local variables:
index ba82c5ea5e03e05ab101167363d5dfd61dd6c267..ef0e725639295ef00a37093fa2d244519baa3613 100644 (file)
@@ -30,6 +30,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
 #include <common/time.h>
@@ -74,6 +75,8 @@ static struct protocol proto_sockpair = {
        .nb_listeners = 0,
 };
 
+INITCALL1(STG_REGISTER, protocol_register, &proto_sockpair);
+
 /* Add <listener> to the list of sockpair listeners (port is ignored). The
  * listener's state is automatically updated from LI_INIT to LI_ASSIGNED.
  * The number of listeners for the protocol is updated.
@@ -389,12 +392,6 @@ int recv_fd_uxst(int sock)
        return recv_fd;
 }
 
-__attribute__((constructor))
-static void __uxst_protocol_init(void)
-{
-       protocol_register(&proto_sockpair);
-}
-
 /*
  * Local variables:
  *  c-indent-level: 8
index c7951c55a461b90a4a430e4015ac09774de995b9..26926680fcfc7812a7c2984f6dcdf2d488a35294 100644 (file)
@@ -36,6 +36,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
 #include <common/namespace.h>
@@ -90,6 +91,8 @@ static struct protocol proto_tcpv4 = {
        .nb_listeners = 0,
 };
 
+INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv4);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct protocol proto_tcpv6 = {
        .name = "tcpv6",
@@ -113,6 +116,8 @@ static struct protocol proto_tcpv6 = {
        .nb_listeners = 0,
 };
 
+INITCALL1(STG_REGISTER, protocol_register, &proto_tcpv6);
+
 /* Default TCP parameters, got by opening a temporary TCP socket. */
 #ifdef TCP_MAXSEG
 static THREAD_LOCAL int default_tcp_maxseg = -1;
@@ -1913,6 +1918,8 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
+
 /************************************************************************/
 /*           All supported bind keywords must be declared here.         */
 /************************************************************************/
@@ -1960,6 +1967,8 @@ static struct bind_kw_list bind_kws = { "TCP", { }, {
        { NULL, NULL, 0 },
 }};
 
+INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws);
+
 static struct srv_kw_list srv_kws = { "TCP", { }, {
 #ifdef TCP_USER_TIMEOUT
        { "tcp-ut",        srv_parse_tcp_ut,        1,  1 }, /* set TCP user timeout on server */
@@ -1967,6 +1976,8 @@ static struct srv_kw_list srv_kws = { "TCP", { }, {
        { NULL, NULL, 0 },
 }};
 
+INITCALL1(STG_REGISTER, srv_register_keywords, &srv_kws);
+
 static struct action_kw_list tcp_req_conn_actions = {ILH, {
        { "silent-drop",  tcp_parse_silent_drop },
        { "set-src",      tcp_parse_set_src_dst },
@@ -1976,6 +1987,8 @@ static struct action_kw_list tcp_req_conn_actions = {ILH, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_conn_keywords_register, &tcp_req_conn_actions);
+
 static struct action_kw_list tcp_req_sess_actions = {ILH, {
        { "silent-drop",  tcp_parse_silent_drop },
        { "set-src",      tcp_parse_set_src_dst },
@@ -1985,16 +1998,22 @@ static struct action_kw_list tcp_req_sess_actions = {ILH, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_req_sess_actions);
+
 static struct action_kw_list tcp_req_cont_actions = {ILH, {
        { "silent-drop", tcp_parse_silent_drop },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_cont_actions);
+
 static struct action_kw_list tcp_res_cont_actions = {ILH, {
        { "silent-drop", tcp_parse_silent_drop },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_cont_actions);
+
 static struct action_kw_list http_req_actions = {ILH, {
        { "silent-drop",  tcp_parse_silent_drop },
        { "set-src",      tcp_parse_set_src_dst },
@@ -2004,28 +2023,18 @@ static struct action_kw_list http_req_actions = {ILH, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions);
+
 static struct action_kw_list http_res_actions = {ILH, {
        { "silent-drop", tcp_parse_silent_drop },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions);
 
 __attribute__((constructor))
 static void __tcp_protocol_init(void)
 {
-       protocol_register(&proto_tcpv4);
-       protocol_register(&proto_tcpv6);
-       sample_register_fetches(&sample_fetch_keywords);
-       bind_register_keywords(&bind_kws);
-       srv_register_keywords(&srv_kws);
-       tcp_req_conn_keywords_register(&tcp_req_conn_actions);
-       tcp_req_sess_keywords_register(&tcp_req_sess_actions);
-       tcp_req_cont_keywords_register(&tcp_req_cont_actions);
-       tcp_res_cont_keywords_register(&tcp_res_cont_actions);
-       http_req_keywords_register(&http_req_actions);
-       http_res_keywords_register(&http_res_actions);
-
-
        hap_register_build_opts("Built with transparent proxy support using:"
 #if defined(IP_TRANSPARENT)
               " IP_TRANSPARENT"
index 149ba8e32f13faba598bae4b907ace6437a19a5d..878a10db5985e8c135bff08dd55bbe8f440a0d1f 100644 (file)
@@ -30,6 +30,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
 #include <common/time.h>
@@ -77,6 +78,8 @@ static struct protocol proto_unix = {
        .nb_listeners = 0,
 };
 
+INITCALL1(STG_REGISTER, protocol_register, &proto_unix);
+
 /********************************
  * 1) low-level socket functions
  ********************************/
@@ -720,17 +723,7 @@ static struct bind_kw_list bind_kws = { "UNIX", { }, {
        { NULL, NULL, 0 },
 }};
 
-/********************************
- * 4) high-level functions
- ********************************/
-
-__attribute__((constructor))
-static void __uxst_protocol_init(void)
-{
-       protocol_register(&proto_unix);
-       bind_register_keywords(&bind_kws);
-}
-
+INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws);
 
 /*
  * Local variables:
index 76d84a24fd5a836f95f0cbdd7956fe62bfbf4df8..f8d22b63362628fd2ca37f704c43cd9ab4a96de0 100644 (file)
@@ -22,6 +22,7 @@
 #include <common/compat.h>
 #include <common/config.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/time.h>
 
@@ -1497,6 +1498,8 @@ static struct cfg_kw_list cfg_kws = {ILH, {
        { 0, NULL, NULL },
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 /* Expects to find a frontend named <arg> and returns it, otherwise displays various
  * adequate error messages and returns NULL. This function is designed to be used by
  * functions requiring a frontend on the CLI.
@@ -2229,12 +2232,7 @@ static struct cli_kw_list cli_kws = {{ },{
        {{},}
 }};
 
-__attribute__((constructor))
-static void __proxy_module_init(void)
-{
-       cfg_register_keywords(&cfg_kws);
-       cli_register_kw(&cli_kws);
-}
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
 
 /*
  * Local variables:
index a5f129d50367659872dd8d464df7bb4cba610f9d..fa02b4adb036890693331b48854a23616c46ccf9 100644 (file)
@@ -70,6 +70,7 @@
  */
 
 #include <common/config.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/time.h>
 #include <common/hathreads.h>
@@ -601,12 +602,16 @@ static struct action_kw_list tcp_cont_kws = {ILH, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_cont_kws);
+
 static struct action_kw_list http_req_kws = {ILH, {
        { "set-priority-class", parse_set_priority_class },
        { "set-priority-offset", parse_set_priority_offset },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_kws);
+
 static int
 smp_fetch_priority_class(const struct arg *args, struct sample *smp, const char *kw, void *private)
 {
@@ -638,13 +643,7 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
        { /* END */},
 }};
 
-__attribute__((constructor))
-static void __queue_init(void)
-{
-       tcp_req_cont_keywords_register(&tcp_cont_kws);
-       http_req_keywords_register(&http_req_kws);
-       sample_register_fetches(&smp_kws);
-}
+INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws);
 
 /*
  * Local variables:
index 8ca4540645045798f662c16f00893070db1f88ac..134ff76f5f9ffddccb373617b43935045f0041da 100644 (file)
@@ -21,6 +21,7 @@
 #include <common/chunk.h>
 #include <common/hash.h>
 #include <common/http.h>
+#include <common/initcall.h>
 #include <common/standard.h>
 #include <common/uri_auth.h>
 #include <common/base64.h>
@@ -3089,6 +3090,8 @@ static struct sample_fetch_kw_list smp_kws = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &smp_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_conv_kw_list sample_conv_kws = {ILH, {
 #ifdef DEBUG_EXPR
@@ -3139,10 +3142,4 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
        { NULL, NULL, 0, 0, 0 },
 }};
 
-__attribute__((constructor))
-static void __sample_init(void)
-{
-       /* register sample fetch and format conversion keywords */
-       sample_register_fetches(&smp_kws);
-       sample_register_convs(&sample_conv_kws);
-}
+INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
index 0cf5ecaf56e89e52b79f06fb86ff007533a97124..eb2bc6e9cd2bfadda5bbc6e5b4d10be6caa3a208 100644 (file)
@@ -19,6 +19,7 @@
 #include <common/cfgparse.h>
 #include <common/config.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <common/namespace.h>
 #include <common/time.h>
 
@@ -1221,11 +1222,7 @@ static struct srv_kw_list srv_kws = { "ALL", { }, {
        { NULL, NULL, 0 },
 }};
 
-__attribute__((constructor))
-static void __listener_init(void)
-{
-       srv_register_keywords(&srv_kws);
-}
+INITCALL1(STG_REGISTER, srv_register_keywords, &srv_kws);
 
 /* Recomputes the server's eweight based on its state, uweight, the current time,
  * and the proxy's algorihtm. To be used after updating sv->uweight. The warmup
@@ -4700,11 +4697,7 @@ static struct cli_kw_list cli_kws = {{ },{
        {{},}
 }};
 
-__attribute__((constructor))
-static void __server_init(void)
-{
-       cli_register_kw(&cli_kws);
-}
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
 
 /*
  * This function applies server's status changes, it is
index 4fb984f279b849e5aa864d4d3141fb37609ec150..174ed1f955679f7509247fae1d015098c642a757 100644 (file)
@@ -69,6 +69,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <common/standard.h>
 #include <common/ticks.h>
 #include <common/time.h>
@@ -8927,6 +8928,7 @@ static struct cli_kw_list cli_kws = {{ },{
        { { NULL }, NULL, NULL, NULL }
 }};
 
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
 
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted.
@@ -9010,6 +9012,8 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
        { NULL, NULL, 0, 0, 0 },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
+
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted.
  */
@@ -9019,6 +9023,8 @@ static struct acl_kw_list acl_kws = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, acl_register_keywords, &acl_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted, doing so helps
  * all code contributors.
@@ -9045,6 +9051,8 @@ static struct ssl_bind_kw ssl_bind_kws[] = {
        { NULL, NULL, 0 },
 };
 
+/* no initcall for ssl_bind_kws, these ones are parsed in the parser loop */
+
 static struct bind_kw_list bind_kws = { "SSL", { }, {
        { "allow-0rtt",            bind_parse_allow_0rtt,         0 }, /* Allow 0RTT */
        { "alpn",                  bind_parse_alpn,               1 }, /* set ALPN supported protocols */
@@ -9086,6 +9094,8 @@ static struct bind_kw_list bind_kws = { "SSL", { }, {
        { NULL, NULL, 0 },
 }};
 
+INITCALL1(STG_REGISTER, bind_register_keywords, &bind_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten.
  * Please take care of keeping this list alphabetically sorted, doing so helps
  * all code contributors.
@@ -9135,6 +9145,8 @@ static struct srv_kw_list srv_kws = { "SSL", { }, {
        { NULL, NULL, 0, 0 },
 }};
 
+INITCALL1(STG_REGISTER, srv_register_keywords, &srv_kws);
+
 static struct cfg_kw_list cfg_kws = {ILH, {
        { CFG_GLOBAL, "ca-base",  ssl_parse_global_ca_crt_base },
        { CFG_GLOBAL, "crt-base", ssl_parse_global_ca_crt_base },
@@ -9166,6 +9178,8 @@ static struct cfg_kw_list cfg_kws = {ILH, {
        { 0, NULL, NULL },
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 /* transport-layer operations for SSL sockets */
 static struct xprt_ops ssl_sock = {
        .snd_buf  = ssl_sock_from_buf,
@@ -9217,6 +9231,8 @@ static struct action_kw_list http_req_actions = {ILH, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_actions);
+
 #if (OPENSSL_VERSION_NUMBER >= 0x1000200fL && !defined OPENSSL_NO_TLSEXT && !defined OPENSSL_IS_BORINGSSL && !defined LIBRESSL_VERSION_NUMBER)
 
 static void ssl_sock_sctl_free_func(void *parent, void *ptr, CRYPTO_EX_DATA *ad, int idx, long argl, void *argp)
@@ -9265,12 +9281,6 @@ static void __ssl_sock_init(void)
        ssl_app_data_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, NULL);
        ssl_capture_ptr_index = SSL_get_ex_new_index(0, NULL, NULL, NULL, ssl_sock_capture_free_func);
        ssl_pkey_info_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL);
-       sample_register_fetches(&sample_fetch_keywords);
-       acl_register_keywords(&acl_kws);
-       bind_register_keywords(&bind_kws);
-       srv_register_keywords(&srv_kws);
-       cfg_register_keywords(&cfg_kws);
-       cli_register_kw(&cli_kws);
 #ifndef OPENSSL_NO_ENGINE
        ENGINE_load_builtin_engines();
        hap_register_post_check(ssl_check_async_engine_count);
@@ -9330,8 +9340,6 @@ static void __ssl_sock_init(void)
 #endif
        /* Load SSL string for the verbose & debug mode. */
        ERR_load_SSL_strings();
-
-       http_req_keywords_register(&http_req_actions);
 }
 
 #ifndef OPENSSL_NO_ENGINE
index 9b0800eddb47dc76782b80fbc4eff283b1dc68e6..d0544a33632ffd88c446e20c2e609191d02f9c3d 100644 (file)
@@ -29,6 +29,7 @@
 #include <common/config.h>
 #include <common/debug.h>
 #include <common/http.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
@@ -3965,6 +3966,8 @@ static struct cli_kw_list cli_kws = {{ },{
        {{},}
 }};
 
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
+
 struct applet http_stats_applet = {
        .obj_type = OBJ_TYPE_APPLET,
        .name = "<STATS>", /* used for logging */
@@ -3972,12 +3975,6 @@ struct applet http_stats_applet = {
        .release = NULL,
 };
 
-__attribute__((constructor))
-static void __stat_init(void)
-{
-       cli_register_kw(&cli_kws);
-}
-
 /*
  * Local variables:
  *  c-indent-level: 8
index 6bddc90c4236393958d33f9c450de85455dd9e25..e24ef65b6ffd754f99dc6473e07279ad5c3e547d 100644 (file)
@@ -15,6 +15,7 @@
 #include <errno.h>
 
 #include <common/config.h>
+#include <common/initcall.h>
 #include <common/memory.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
@@ -3626,6 +3627,7 @@ static struct cli_kw_list cli_kws = {{ },{
        {{},}
 }};
 
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
 
 static struct action_kw_list tcp_conn_kws = { { }, {
        { "sc-inc-gpc0", parse_inc_gpc0, 1 },
@@ -3634,6 +3636,8 @@ static struct action_kw_list tcp_conn_kws = { { }, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_conn_keywords_register, &tcp_conn_kws);
+
 static struct action_kw_list tcp_sess_kws = { { }, {
        { "sc-inc-gpc0", parse_inc_gpc0, 1 },
        { "sc-inc-gpc1", parse_inc_gpc1, 1 },
@@ -3641,6 +3645,8 @@ static struct action_kw_list tcp_sess_kws = { { }, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_sess_kws);
+
 static struct action_kw_list tcp_req_kws = { { }, {
        { "sc-inc-gpc0", parse_inc_gpc0, 1 },
        { "sc-inc-gpc1", parse_inc_gpc1, 1 },
@@ -3648,6 +3654,8 @@ static struct action_kw_list tcp_req_kws = { { }, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_kws);
+
 static struct action_kw_list tcp_res_kws = { { }, {
        { "sc-inc-gpc0", parse_inc_gpc0, 1 },
        { "sc-inc-gpc1", parse_inc_gpc1, 1 },
@@ -3655,6 +3663,8 @@ static struct action_kw_list tcp_res_kws = { { }, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_kws);
+
 static struct action_kw_list http_req_kws = { { }, {
        { "sc-inc-gpc0", parse_inc_gpc0, 1 },
        { "sc-inc-gpc1", parse_inc_gpc1, 1 },
@@ -3662,6 +3672,8 @@ static struct action_kw_list http_req_kws = { { }, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_kws);
+
 static struct action_kw_list http_res_kws = { { }, {
        { "sc-inc-gpc0", parse_inc_gpc0, 1 },
        { "sc-inc-gpc1", parse_inc_gpc1, 1 },
@@ -3669,6 +3681,8 @@ static struct action_kw_list http_res_kws = { { }, {
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_kws);
+
 ///* Note: must not be declared <const> as its list will be overwritten.
 // * Please take care of keeping this list alphabetically sorted.
 // */
@@ -3805,6 +3819,7 @@ static struct sample_fetch_kw_list smp_fetch_keywords = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &smp_fetch_keywords);
 
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_conv_kw_list sample_conv_kws = {ILH, {
@@ -3832,19 +3847,4 @@ static struct sample_conv_kw_list sample_conv_kws = {ILH, {
        { /* END */ },
 }};
 
-__attribute__((constructor))
-static void __stick_table_init(void)
-{
-       /* register som action keywords. */
-       tcp_req_conn_keywords_register(&tcp_conn_kws);
-       tcp_req_sess_keywords_register(&tcp_sess_kws);
-       tcp_req_cont_keywords_register(&tcp_req_kws);
-       tcp_res_cont_keywords_register(&tcp_res_kws);
-       http_req_keywords_register(&http_req_kws);
-       http_res_keywords_register(&http_res_kws);
-
-       /* register sample fetch and format conversion keywords */
-       sample_register_fetches(&smp_fetch_keywords);
-       sample_register_convs(&sample_conv_kws);
-       cli_register_kw(&cli_kws);
-}
+INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
index eda2aed11045b9828edd4c5ae82ced27e5d452ca..31146d27fad47d421c8958e4eed8497b05aff0e1 100644 (file)
@@ -18,8 +18,9 @@
 #include <common/config.h>
 #include <common/buffer.h>
 #include <common/debug.h>
-#include <common/memory.h>
 #include <common/hathreads.h>
+#include <common/initcall.h>
+#include <common/memory.h>
 
 #include <types/applet.h>
 #include <types/capture.h>
@@ -3411,24 +3412,22 @@ static struct cli_kw_list cli_kws = {{ },{
        {{},}
 }};
 
+INITCALL1(STG_REGISTER, cli_register_kw, &cli_kws);
+
 /* main configuration keyword registration. */
 static struct action_kw_list stream_tcp_keywords = { ILH, {
        { "use-service", stream_parse_use_service },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &stream_tcp_keywords);
+
 static struct action_kw_list stream_http_keywords = { ILH, {
        { "use-service", stream_parse_use_service },
        { /* END */ }
 }};
 
-__attribute__((constructor))
-static void __stream_init(void)
-{
-       tcp_req_cont_keywords_register(&stream_tcp_keywords);
-       http_req_keywords_register(&stream_http_keywords);
-       cli_register_kw(&cli_kws);
-}
+INITCALL1(STG_REGISTER, http_req_keywords_register, &stream_http_keywords);
 
 /*
  * Local variables:
index 564b1eaa452ad21ede517c6d8de793c3c1b29fff..602749c4948d00957e495ef5e0b77ad182b67457 100644 (file)
@@ -13,6 +13,7 @@
 #include <common/compat.h>
 #include <common/config.h>
 #include <common/debug.h>
+#include <common/initcall.h>
 #include <common/mini-clist.h>
 #include <common/standard.h>
 #include <common/ticks.h>
@@ -1191,12 +1192,7 @@ static struct cfg_kw_list cfg_kws = {ILH, {
        { 0, NULL, NULL },
 }};
 
-
-__attribute__((constructor))
-static void __tcp_protocol_init(void)
-{
-       cfg_register_keywords(&cfg_kws);
-}
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
 
 /*
  * Local variables:
index 8f757f9bdb836297039ca93eb83063a0a7ba7f05..e44a78600a51527bbbd5df04e6ae9ed60febdc7c 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <common/cfgparse.h>
 #include <common/http.h>
+#include <common/initcall.h>
 #include <common/mini-clist.h>
 
 #include <types/vars.h>
@@ -861,42 +862,56 @@ static struct sample_fetch_kw_list sample_fetch_keywords = {ILH, {
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &sample_fetch_keywords);
+
 static struct sample_conv_kw_list sample_conv_kws = {ILH, {
        { "set-var",   smp_conv_store, ARG1(1,STR), conv_check_var, SMP_T_ANY, SMP_T_ANY },
        { "unset-var", smp_conv_clear, ARG1(1,STR), conv_check_var, SMP_T_ANY, SMP_T_ANY },
        { /* END */ },
 }};
 
+INITCALL1(STG_REGISTER, sample_register_convs, &sample_conv_kws);
+
 static struct action_kw_list tcp_req_sess_kws = { { }, {
        { "set-var",   parse_store, 1 },
        { "unset-var", parse_store, 1 },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_sess_keywords_register, &tcp_req_sess_kws);
+
 static struct action_kw_list tcp_req_cont_kws = { { }, {
        { "set-var",   parse_store, 1 },
        { "unset-var", parse_store, 1 },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_cont_kws);
+
 static struct action_kw_list tcp_res_kws = { { }, {
        { "set-var",   parse_store, 1 },
        { "unset-var", parse_store, 1 },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, tcp_res_cont_keywords_register, &tcp_res_kws);
+
 static struct action_kw_list http_req_kws = { { }, {
        { "set-var",   parse_store, 1 },
        { "unset-var", parse_store, 1 },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, http_req_keywords_register, &http_req_kws);
+
 static struct action_kw_list http_res_kws = { { }, {
        { "set-var",   parse_store, 1 },
        { "unset-var", parse_store, 1 },
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_kws);
+
 static struct cfg_kw_list cfg_kws = {{ },{
        { CFG_GLOBAL, "tune.vars.global-max-size", vars_max_size_global },
        { CFG_GLOBAL, "tune.vars.proc-max-size",   vars_max_size_proc   },
@@ -906,19 +921,12 @@ static struct cfg_kw_list cfg_kws = {{ },{
        { /* END */ }
 }};
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws);
+
 __attribute__((constructor))
 static void __vars_init(void)
 {
        var_pool = create_pool("vars", sizeof(struct var), MEM_F_SHARED);
 
-       sample_register_fetches(&sample_fetch_keywords);
-       sample_register_convs(&sample_conv_kws);
-       tcp_req_sess_keywords_register(&tcp_req_sess_kws);
-       tcp_req_cont_keywords_register(&tcp_req_cont_kws);
-       tcp_res_cont_keywords_register(&tcp_res_kws);
-       http_req_keywords_register(&http_req_kws);
-       http_res_keywords_register(&http_res_kws);
-       cfg_register_keywords(&cfg_kws);
-
        HA_RWLOCK_INIT(&var_names_rwlock);
 }
index f7ac9b665ed38ec235d560638b691a34b44abba6..eb1fb472dfb1cd86b435656d8ebdc9c09063bb79 100644 (file)
@@ -5,6 +5,7 @@
 #include <common/chunk.h>
 #include <common/buffer.h>
 #include <common/errors.h>
+#include <common/initcall.h>
 #include <proto/arg.h>
 #include <proto/log.h>
 #include <proto/proto_http.h>
@@ -669,6 +670,8 @@ static struct cfg_kw_list wurflcfg_kws = {{ }, {
        }
 };
 
+INITCALL1(STG_REGISTER, cfg_register_keywords, &wurflcfg_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_fetch_kw_list fetch_kws = {ILH, {
                { "wurfl-get-all", ha_wurfl_get_all, 0, NULL, SMP_T_STR, SMP_USE_HRQHV },
@@ -677,19 +680,20 @@ static struct sample_fetch_kw_list fetch_kws = {ILH, {
        }
 };
 
+INITCALL1(STG_REGISTER, sample_register_fetches, &fetch_kws);
+
 /* Note: must not be declared <const> as its list will be overwritten */
 static struct sample_conv_kw_list conv_kws = {ILH, {
                { NULL, NULL, 0, 0, 0 },
        }
 };
 
+INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws);
+
 __attribute__((constructor))
 static void __wurfl_init(void)
 {
        /* register sample fetch and format conversion keywords */
-       sample_register_fetches(&fetch_kws);
-       sample_register_convs(&conv_kws);
-       cfg_register_keywords(&wurflcfg_kws);
        hap_register_build_opts("Built with WURFL support.", 0);
        hap_register_post_check(ha_wurfl_init);
        hap_register_post_deinit(ha_wurfl_deinit);