diff --git a/include/types/global.h b/include/types/global.h index 24eeb0ce7..85f5d25c0 100644 --- a/include/types/global.h +++ b/include/types/global.h @@ -25,8 +25,9 @@ #include #include -#include +#include #include +#include #include #include @@ -246,6 +247,10 @@ void hap_register_per_thread_deinit(void (*fct)()); void mworker_accept_wrapper(int fd); +/* simplified way to declare static build options in a file */ +#define REGISTER_BUILD_OPTS(str) \ + INITCALL2(STG_REGISTER, hap_register_build_opts, (str), 0) + #endif /* _TYPES_GLOBAL_H */ /* diff --git a/src/51d.c b/src/51d.c index d53796488..d709ec0e7 100644 --- a/src/51d.c +++ b/src/51d.c @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -689,8 +690,8 @@ INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws); __attribute__((constructor)) static void __51d_init(void) { - /* register sample fetch and conversion keywords */ - hap_register_build_opts("Built with 51Degrees support.", 0); hap_register_post_check(init_51degrees); hap_register_post_deinit(deinit_51degrees); } + +REGISTER_BUILD_OPTS("Built with 51Degrees support."); diff --git a/src/auth.c b/src/auth.c index 2f9cc4fb4..8d1da3e3b 100644 --- a/src/auth.c +++ b/src/auth.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -313,8 +314,4 @@ pat_match_auth(struct sample *smp, struct pattern_expr *expr, int fill) return NULL; } -__attribute__((constructor)) -static void __auth_init(void) -{ - hap_register_build_opts("Encrypted password support via crypt(3): yes", 0); -} +REGISTER_BUILD_OPTS("Encrypted password support via crypt(3): yes"); diff --git a/src/compression.c b/src/compression.c index af44f4d6d..218a28486 100644 --- a/src/compression.c +++ b/src/compression.c @@ -705,9 +705,6 @@ INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); __attribute__((constructor)) static void __comp_fetch_init(void) { - char *ptr = NULL; - int i; - #ifdef USE_SLZ slz_make_crc_table(); slz_prepare_dist_table(); @@ -720,6 +717,13 @@ static void __comp_fetch_init(void) #if defined(USE_ZLIB) && defined(DEFAULT_MAXZLIBMEM) global.maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U; #endif +} + +static void comp_register_build_opts(void) +{ + char *ptr = NULL; + int i; + #ifdef USE_ZLIB memprintf(&ptr, "Built with zlib version : " ZLIB_VERSION); memprintf(&ptr, "%s\nRunning on zlib version : %s", ptr, zlibVersion()); @@ -738,3 +742,5 @@ static void __comp_fetch_init(void) hap_register_build_opts(ptr, 1); } + +INITCALL0(STG_REGISTER, comp_register_build_opts); diff --git a/src/da.c b/src/da.c index c1c07e397..ee3d9af5d 100644 --- a/src/da.c +++ b/src/da.c @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -398,8 +399,8 @@ INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws); __attribute__((constructor)) static void __da_init(void) { - /* register sample fetch and format conversion keywords */ - hap_register_build_opts("Built with DeviceAtlas support.", 0); hap_register_post_check(init_deviceatlas); hap_register_post_deinit(deinit_deviceatlas); } + +REGISTER_BUILD_OPTS("Built with DeviceAtlas support."); diff --git a/src/hathreads.c b/src/hathreads.c index eb3eb59fb..d9128a7fd 100644 --- a/src/hathreads.c +++ b/src/hathreads.c @@ -17,6 +17,7 @@ #include #include #include +#include #include @@ -110,7 +111,6 @@ static void __hathreads_init(void) #if defined(DEBUG_THREAD) || defined(DEBUG_FULL) memset(lock_stats, 0, sizeof(lock_stats)); #endif - hap_register_build_opts("Built with multi-threading support.", 0); } #endif // USE_THREAD @@ -148,3 +148,5 @@ int parse_nbthread(const char *arg, char **err) #endif return nbthread; } + +REGISTER_BUILD_OPTS("Built with multi-threading support."); diff --git a/src/hlua.c b/src/hlua.c index 820ddf58a..294b6b3f5 100644 --- a/src/hlua.c +++ b/src/hlua.c @@ -8210,8 +8210,15 @@ void hlua_init(void) __attribute__((constructor)) static void __hlua_init(void) { - char *ptr = NULL; - memprintf(&ptr, "Built with Lua version : %s", LUA_RELEASE); - hap_register_build_opts(ptr, 1); cfg_register_postparser("hlua", hlua_check_config); } + +static void hlua_register_build_options(void) +{ + char *ptr = NULL; + + memprintf(&ptr, "Built with Lua version : %s", LUA_RELEASE); + hap_register_build_opts(ptr, 1); +} + +INITCALL0(STG_REGISTER, hlua_register_build_options); diff --git a/src/namespace.c b/src/namespace.c index 72f5079eb..8a2e5a7b1 100644 --- a/src/namespace.c +++ b/src/namespace.c @@ -106,8 +106,4 @@ int my_socketat(const struct netns_entry *ns, int domain, int type, int protocol return sock; } -__attribute__((constructor)) -static void __ns_init(void) -{ - hap_register_build_opts("Built with network namespace support.", 0); -} +REGISTER_BUILD_OPTS("Built with network namespace support."); diff --git a/src/proto_tcp.c b/src/proto_tcp.c index 26926680f..0c531e6ec 100644 --- a/src/proto_tcp.c +++ b/src/proto_tcp.c @@ -2032,30 +2032,26 @@ static struct action_kw_list http_res_actions = {ILH, { INITCALL1(STG_REGISTER, http_res_keywords_register, &http_res_actions); -__attribute__((constructor)) -static void __tcp_protocol_init(void) -{ - hap_register_build_opts("Built with transparent proxy support using:" +REGISTER_BUILD_OPTS("Built with transparent proxy support using:" #if defined(IP_TRANSPARENT) - " IP_TRANSPARENT" + " IP_TRANSPARENT" #endif #if defined(IPV6_TRANSPARENT) - " IPV6_TRANSPARENT" + " IPV6_TRANSPARENT" #endif #if defined(IP_FREEBIND) - " IP_FREEBIND" + " IP_FREEBIND" #endif #if defined(IP_BINDANY) - " IP_BINDANY" + " IP_BINDANY" #endif #if defined(IPV6_BINDANY) - " IPV6_BINDANY" + " IPV6_BINDANY" #endif #if defined(SO_BINDANY) - " SO_BINDANY" + " SO_BINDANY" #endif - "", 0); -} + ""); /* diff --git a/src/regex.c b/src/regex.c index f3f74c3dc..713f0c987 100644 --- a/src/regex.c +++ b/src/regex.c @@ -411,8 +411,7 @@ int regex_comp(const char *str, struct my_regex *regex, int cs, int cap, char ** return 1; } -__attribute__((constructor)) -static void __regex_init(void) +static void regex_register_build_options(void) { char *ptr = NULL; @@ -458,6 +457,8 @@ static void __regex_init(void) hap_register_build_opts(ptr, 1); } +INITCALL0(STG_REGISTER, regex_register_build_options); + /* * Local variables: * c-indent-level: 8 diff --git a/src/ssl_sock.c b/src/ssl_sock.c index 3be4b2aed..86d4f227a 100644 --- a/src/ssl_sock.c +++ b/src/ssl_sock.c @@ -9251,9 +9251,6 @@ static void ssl_sock_capture_free_func(void *parent, void *ptr, CRYPTO_EX_DATA * __attribute__((constructor)) static void __ssl_sock_init(void) { - char *ptr; - int i; - STACK_OF(SSL_COMP)* cm; if (global_ssl.listen_default_ciphers) @@ -9288,7 +9285,26 @@ static void __ssl_sock_init(void) hap_register_post_check(tlskeys_finalize_config); #endif - ptr = NULL; + global.ssl_session_max_cost = SSL_SESSION_MAX_COST; + global.ssl_handshake_max_cost = SSL_HANDSHAKE_MAX_COST; + +#ifndef OPENSSL_NO_DH + ssl_dh_ptr_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL); + hap_register_post_deinit(ssl_free_dh); +#endif +#ifndef OPENSSL_NO_ENGINE + hap_register_post_deinit(ssl_free_engines); +#endif + /* Load SSL string for the verbose & debug mode. */ + ERR_load_SSL_strings(); +} + +/* Compute and register the version string */ +static void ssl_register_build_options() +{ + char *ptr = NULL; + int i; + memprintf(&ptr, "Built with OpenSSL version : " #ifdef OPENSSL_IS_BORINGSSL "BoringSSL"); @@ -9326,21 +9342,11 @@ static void __ssl_sock_init(void) memprintf(&ptr, "%s %s", ptr, methodVersions[i].name); hap_register_build_opts(ptr, 1); - - global.ssl_session_max_cost = SSL_SESSION_MAX_COST; - global.ssl_handshake_max_cost = SSL_HANDSHAKE_MAX_COST; - -#ifndef OPENSSL_NO_DH - ssl_dh_ptr_index = SSL_CTX_get_ex_new_index(0, NULL, NULL, NULL, NULL); - hap_register_post_deinit(ssl_free_dh); -#endif -#ifndef OPENSSL_NO_ENGINE - hap_register_post_deinit(ssl_free_engines); -#endif - /* Load SSL string for the verbose & debug mode. */ - ERR_load_SSL_strings(); } +INITCALL0(STG_REGISTER, ssl_register_build_options); + + #ifndef OPENSSL_NO_ENGINE void ssl_free_engines(void) { struct ssl_engine_list *wl, *wlb; diff --git a/src/wurfl.c b/src/wurfl.c index eb1fb472d..cd6abef36 100644 --- a/src/wurfl.c +++ b/src/wurfl.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include #include @@ -693,8 +694,6 @@ INITCALL1(STG_REGISTER, sample_register_convs, &conv_kws); __attribute__((constructor)) static void __wurfl_init(void) { - /* register sample fetch and format conversion keywords */ - hap_register_build_opts("Built with WURFL support.", 0); hap_register_post_check(ha_wurfl_init); hap_register_post_deinit(ha_wurfl_deinit); } @@ -802,3 +801,5 @@ static const char *ha_wurfl_retrieve_header(const char *header_name, const void ha_wurfl_log("WURFL: retrieve header request returns [%s]\n", ((ha_wurfl_header_t *)wh)->header_value); return ((ha_wurfl_header_t *)wh)->header_value; } + +REGISTER_BUILD_OPTS("Built with WURFL support.");