]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: pollers: use an initcall to register the pollers
authorWilly Tarreau <w@1wt.eu>
Mon, 25 Apr 2022 17:00:55 +0000 (19:00 +0200)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Apr 2022 17:00:55 +0000 (19:00 +0200)
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
src/ev_evports.c
src/ev_kqueue.c
src/ev_poll.c
src/ev_select.c

index 1babe56c2345759a3dd7e7a74abaff4e71638db3..583206232939e99fcc152256d0f19564561d00a3 100644 (file)
@@ -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:
index c3be00e7273723928f7357548c0f502eaaeee6b4..4d611541cf5bf14121a63fa8243bf7b7efb7f588 100644 (file)
@@ -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);
index 1bd79fd697cdc0d6cf7acd268b21d1a89bc5ffc0..3bc7121cbdcaea5fcba71f9caf8430ca09eb5f4c 100644 (file)
@@ -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:
index 5cfdff112bfc422bcc740966684b836dd698d4fd..5f52262adaed60d749c10da39b1a9ab0161ff76e 100644 (file)
@@ -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:
index 3c8471fcde68d3c7a9c776f9a3a9766915480de4..3880d0d1437fb13764912ad6aa8f3b8ec248990b 100644 (file)
@@ -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: