summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2012-12-17 17:11:50 +0100
committerStef Walter <stefw@gnome.org>2013-01-09 13:49:44 +0100
commit4671352fe2a4f56c6707322dcab0015e2e8600c4 (patch)
treefabea162422abd876ffe007ce79081c434bc4aa1 /common
parentb39c9a7792824dfa8a05926261315356d9007098 (diff)
Only initialize p11-kit libraries once
* Make the gcc constructor call p11_library_init_once()
Diffstat (limited to 'common')
-rw-r--r--common/library.c14
-rw-r--r--common/library.h6
2 files changed, 14 insertions, 6 deletions
diff --git a/common/library.c b/common/library.c
index e8547b3..48fd0c9 100644
--- a/common/library.c
+++ b/common/library.c
@@ -159,11 +159,8 @@ _p11_library_get_thread_local (void)
return local;
}
-#ifdef __GNUC__
-__attribute__((constructor))
-#endif
void
-p11_library_init (void)
+p11_library_init_impl (void)
{
p11_debug_init ();
p11_debug ("initializing library");
@@ -172,6 +169,15 @@ p11_library_init (void)
}
#ifdef __GNUC__
+__attribute__((constructor))
+#endif
+void
+p11_library_init (void)
+{
+ p11_library_init_once ();
+}
+
+#ifdef __GNUC__
__attribute__((destructor))
#endif
void
diff --git a/common/library.h b/common/library.h
index 00e9c2c..f7d5058 100644
--- a/common/library.h
+++ b/common/library.h
@@ -66,10 +66,12 @@ void p11_message_quiet (void);
#define p11_library_init_once()
#else /* !OS_WIN32 */
-extern pthread_once_t p11_library_once;
+extern pthread_once_t p11_library_once;
#define p11_library_init_once() \
- pthread_once (&p11_library_once, p11_library_init);
+ pthread_once (&p11_library_once, p11_library_init_impl);
+
+void p11_library_init_impl (void);
#endif /* !OS_WIN32 */