From 4671352fe2a4f56c6707322dcab0015e2e8600c4 Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Mon, 17 Dec 2012 17:11:50 +0100 Subject: Only initialize p11-kit libraries once * Make the gcc constructor call p11_library_init_once() --- common/library.c | 14 ++++++++++---- common/library.h | 6 ++++-- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'common') 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 */ -- cgit v1.1