diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/init.c | 1 | ||||
-rw-r--r-- | src/init.h | 5 | ||||
-rw-r--r-- | src/w32-gettext.c | 23 |
3 files changed, 27 insertions, 2 deletions
@@ -96,6 +96,7 @@ gpg_err_init (void) /* No way to continue - commit suicide. */ abort (); } + _gpg_w32__init_gettext_module (); real_init (); } # endif /*!DLL_EXPORT*/ @@ -60,6 +60,11 @@ struct tls_space_s struct tls_space_s *get_tls (void); +/* Explicit constructor for w32-gettext.c */ +#ifndef DLL_EXPORT +void _gpg_w32__init_gettext_module (void); +#endif + #endif /*HAVE_W32_SYSTEM*/ #endif /*INIT_H*/ diff --git a/src/w32-gettext.c b/src/w32-gettext.c index e67e301..ca4fbbd 100644 --- a/src/w32-gettext.c +++ b/src/w32-gettext.c @@ -1146,13 +1146,32 @@ static char *current_domainname; -/* Constructor for this module. Called from DllMain. */ +/* Constructor for this module. This can only be used if we are a + DLL. IF used as a static lib we can't control the process set; for + example it might be used with a main module which is not build with + mingw and thus does not know how to call the constructors. */ +#ifdef DLL_EXPORT static void module_init (void) __attribute__ ((__constructor__)); +#endif static void module_init (void) { - InitializeCriticalSection (&domainlist_access_cs); + static int init_done; + + if (!init_done) + { + InitializeCriticalSection (&domainlist_access_cs); + init_done = 1; + } +} + +#ifndef DLL_EXPORT +void +_gpg_w32__init_gettext_module (void) +{ + module_init (); } +#endif /* Free the domain data. */ |