summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/library.c4
-rw-r--r--common/library.h10
-rw-r--r--p11-kit/client-init.c2
-rw-r--r--p11-kit/proxy-init.c2
-rw-r--r--trust/module.c2
5 files changed, 16 insertions, 4 deletions
diff --git a/common/library.c b/common/library.c
index 465b35d..cde8384 100644
--- a/common/library.c
+++ b/common/library.c
@@ -71,8 +71,10 @@ p11_mutex_t p11_virtual_mutex;
#endif
#ifdef OS_UNIX
+#ifndef __GNUC__
pthread_once_t p11_library_once = PTHREAD_ONCE_INIT;
#endif
+#endif
unsigned int p11_forkid = 1;
@@ -146,7 +148,7 @@ p11_library_init_impl (void)
void
p11_library_init (void)
{
- p11_library_init_once ();
+ p11_library_init_impl ();
}
void
diff --git a/common/library.h b/common/library.h
index c3840f8..0a779b0 100644
--- a/common/library.h
+++ b/common/library.h
@@ -59,11 +59,21 @@ extern unsigned int p11_forkid;
#define p11_library_init_once()
#else /* !OS_WIN32 */
+
+#ifdef __GNUC__
+
+/* No implementation, because done by the ELF constructor */
+#define p11_library_init_once()
+
+#else
+
extern pthread_once_t p11_library_once;
#define p11_library_init_once() \
pthread_once (&p11_library_once, p11_library_init_impl);
+#endif /* !__GNUC__ */
+
void p11_library_init_impl (void);
#endif /* !OS_WIN32 */
diff --git a/p11-kit/client-init.c b/p11-kit/client-init.c
index d016053..74e8905 100644
--- a/p11-kit/client-init.c
+++ b/p11-kit/client-init.c
@@ -64,7 +64,7 @@ __attribute__((constructor))
void
_p11_kit_init (void)
{
- p11_library_init_once ();
+ p11_library_init ();
}
#ifdef __GNUC__
diff --git a/p11-kit/proxy-init.c b/p11-kit/proxy-init.c
index 397949b..118478f 100644
--- a/p11-kit/proxy-init.c
+++ b/p11-kit/proxy-init.c
@@ -53,7 +53,7 @@ __attribute__((constructor))
void
_p11_kit_init (void)
{
- p11_library_init_once ();
+ p11_library_init ();
}
#ifdef __GNUC__
diff --git a/trust/module.c b/trust/module.c
index 82a3fdf..fc67a4d 100644
--- a/trust/module.c
+++ b/trust/module.c
@@ -1845,7 +1845,7 @@ __attribute__((constructor))
void
p11_trust_module_init (void)
{
- p11_library_init_once ();
+ p11_library_init ();
}
#ifdef __GNUC__