summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri.staessens@ugent.be>2017-11-20 03:15:27 +0100
committerSander Vrijders <sander.vrijders@ugent.be>2017-11-20 10:19:00 +0100
commit9f1ad299c93112fd9744311aad04d16f46ab2442 (patch)
treef588f98a5aa9a573427766bdb3c3801d48d9659a
parent489b3f241667a6a054983625ab49ceb3ea0bf742 (diff)
downloadouroboros-9f1ad299c93112fd9744311aad04d16f46ab2442.tar.gz
ouroboros-9f1ad299c93112fd9744311aad04d16f46ab2442.zip
lib: Add library initializers to .init_array
The library initializers with argc and argv arguments were specified using the __attribute__((constructor)). This is undefined behaviour as constructors should have no arguments. This is fixed by passing the functions to the .init_array. Signed-off-by: Dimitri Staessens <dimitri.staessens@ugent.be> Signed-off-by: Sander Vrijders <sander.vrijders@ugent.be>
-rw-r--r--src/lib/dev.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/lib/dev.c b/src/lib/dev.c
index e2e864fc..35a2328c 100644
--- a/src/lib/dev.c
+++ b/src/lib/dev.c
@@ -316,9 +316,9 @@ static bool check_python(char * str)
return false;
}
-__attribute__((constructor)) static void init(int argc,
- char ** argv,
- char ** envp)
+static void init(int argc,
+ char ** argv,
+ char ** envp)
{
const char * ap_name = argv[0];
int i;
@@ -422,7 +422,7 @@ __attribute__((constructor)) static void init(int argc,
exit(EXIT_FAILURE);
}
-__attribute__((destructor)) static void fini(void)
+static void fini(void)
{
int i = 0;
@@ -468,6 +468,9 @@ __attribute__((destructor)) static void fini(void)
pthread_rwlock_destroy(&ai.lock);
}
+__attribute__((section(".init_array"))) __typeof__(init) * __init = init;
+__attribute__((section(".fini_array"))) __typeof__(fini) * __fini = fini;
+
int flow_accept(qosspec_t * qs,
const struct timespec * timeo)
{