From: Willy Tarreau Date: Mon, 25 Apr 2022 17:00:55 +0000 (+0200) Subject: BUILD: pollers: use an initcall to register the pollers X-Git-Tag: v2.6-dev8~81 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=740d749d77060c393f2ff6462ee72f7745ca3d90;p=thirdparty%2Fhaproxy.git BUILD: pollers: use an initcall to register the pollers Pollers are among the few remaining blocks still using constructors to register themselves. That's not needed anymore since the initcalls so better turn to initcalls. --- diff --git a/src/ev_epoll.c b/src/ev_epoll.c index 1babe56c23..5832062329 100644 --- a/src/ev_epoll.c +++ b/src/ev_epoll.c @@ -357,11 +357,8 @@ static int _do_fork(struct poller *p) } /* - * It is a constructor, which means that it will automatically be called before - * main(). This is GCC-specific but it works at least since 2.95. - * Special care must be taken so that it does not need any uninitialized data. + * Registers the poller. */ -__attribute__((constructor)) static void _do_register(void) { struct poller *p; @@ -388,6 +385,8 @@ static void _do_register(void) p->fork = _do_fork; } +INITCALL0(STG_REGISTER, _do_register); + /* * Local variables: diff --git a/src/ev_evports.c b/src/ev_evports.c index c3be00e727..4d611541cf 100644 --- a/src/ev_evports.c +++ b/src/ev_evports.c @@ -402,10 +402,8 @@ static int _do_fork(struct poller *p) } /* - * This constructor must be called before main() to register the event ports - * poller. + * Registers the poller. */ -__attribute__((constructor)) static void _do_register(void) { struct poller *p; @@ -431,3 +429,5 @@ static void _do_register(void) p->poll = _do_poll; p->fork = _do_fork; } + +INITCALL0(STG_REGISTER, _do_register); diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c index 1bd79fd697..3bc7121cbd 100644 --- a/src/ev_kqueue.c +++ b/src/ev_kqueue.c @@ -336,11 +336,8 @@ static int _do_fork(struct poller *p) } /* - * It is a constructor, which means that it will automatically be called before - * main(). This is GCC-specific but it works at least since 2.95. - * Special care must be taken so that it does not need any uninitialized data. + * Registers the poller. */ -__attribute__((constructor)) static void _do_register(void) { struct poller *p; @@ -367,6 +364,7 @@ static void _do_register(void) p->fork = _do_fork; } +INITCALL0(STG_REGISTER, _do_register); /* * Local variables: diff --git a/src/ev_poll.c b/src/ev_poll.c index 5cfdff112b..5f52262ada 100644 --- a/src/ev_poll.c +++ b/src/ev_poll.c @@ -316,11 +316,8 @@ static int _do_test(struct poller *p) } /* - * It is a constructor, which means that it will automatically be called before - * main(). This is GCC-specific but it works at least since 2.95. - * Special care must be taken so that it does not need any uninitialized data. + * Registers the poller. */ -__attribute__((constructor)) static void _do_register(void) { struct poller *p; @@ -341,6 +338,7 @@ static void _do_register(void) p->poll = _do_poll; } +INITCALL0(STG_REGISTER, _do_register); /* * Local variables: diff --git a/src/ev_select.c b/src/ev_select.c index 3c8471fcde..3880d0d143 100644 --- a/src/ev_select.c +++ b/src/ev_select.c @@ -300,11 +300,8 @@ static int _do_test(struct poller *p) } /* - * It is a constructor, which means that it will automatically be called before - * main(). This is GCC-specific but it works at least since 2.95. - * Special care must be taken so that it does not need any uninitialized data. + * Registers the poller. */ -__attribute__((constructor)) static void _do_register(void) { struct poller *p; @@ -325,6 +322,7 @@ static void _do_register(void) p->poll = _do_poll; } +INITCALL0(STG_REGISTER, _do_register); /* * Local variables: