From 740d749d77060c393f2ff6462ee72f7745ca3d90 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Mon, 25 Apr 2022 19:00:55 +0200 Subject: [PATCH] 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. --- src/ev_epoll.c | 7 +++---- src/ev_evports.c | 6 +++--- src/ev_kqueue.c | 6 ++---- src/ev_poll.c | 6 ++---- src/ev_select.c | 6 ++---- 5 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/ev_epoll.c b/src/ev_epoll.c index 1babe56c2..583206232 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 c3be00e72..4d611541c 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 1bd79fd69..3bc7121cb 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 5cfdff112..5f52262ad 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 3c8471fcd..3880d0d14 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: