[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: new module 'setlocale-null'
From: |
Bruno Haible |
Subject: |
Re: new module 'setlocale-null' |
Date: |
Mon, 23 Dec 2019 08:56:02 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-166-generic; KDE/5.18.0; x86_64; ; ) |
This patch ensures that the gl_get_setlocale_null_lock function gets
exported from shared libraries (such as libintl.so) also on ELF systems,
so that different shared libraries attached to the same process use the
same lock.
2019-12-23 Bruno Haible <address@hidden>
setlocale-null: Export the lock function also on non-Windows platforms.
* lib/setlocale-lock.c (DLL_EXPORTED): New macro.
(gl_get_setlocale_null_lock): Declare as DLL_EXPORTED.
* m4/setlocale_null.m4 (gl_PREREQ_SETLOCALE_LOCK): New macro.
* modules/setlocale-null (configure.ac): Invoke it.
(Files): Add m4/visibility.m4.
diff --git a/lib/setlocale-lock.c b/lib/setlocale-lock.c
index 9c47afc..60c1ba3 100644
--- a/lib/setlocale-lock.c
+++ b/lib/setlocale-lock.c
@@ -25,6 +25,19 @@
/* Prohibit renaming this symbol. */
#undef gl_get_setlocale_null_lock
+/* Macro for exporting a symbol (function, not variable) defined in this file,
+ when compiled into a shared library. */
+#ifndef DLL_EXPORTED
+# if HAVE_VISIBILITY
+ /* Override the effect of the compiler option '-fvisibility=hidden'. */
+# define DLL_EXPORTED __attribute__((__visibility__("default")))
+# elif defined _WIN32 || defined __CYGWIN__
+# define DLL_EXPORTED __declspec(dllexport)
+# else
+# define DLL_EXPORTED
+# endif
+#endif
+
#if defined _WIN32 && !defined __CYGWIN__
# define WIN32_LEAN_AND_MEAN /* avoid including junk */
@@ -36,7 +49,7 @@
because the latter is not guaranteed to be a stable ABI in the future. */
/* Make sure the function gets exported from DLLs. */
-__declspec(dllexport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
+DLL_EXPORTED CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
static glwthread_initguard_t guard = GLWTHREAD_INITGUARD_INIT;
static CRITICAL_SECTION lock;
@@ -72,10 +85,8 @@ gl_get_setlocale_null_lock (void)
static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
-# if defined _WIN32 || defined __CYGWIN__
-/* Make sure the function gets exported from DLLs. */
-__declspec(dllexport) pthread_mutex_t *gl_get_setlocale_null_lock (void);
-# endif
+/* Make sure the function gets exported from shared libraries. */
+DLL_EXPORTED pthread_mutex_t *gl_get_setlocale_null_lock (void);
/* Returns the internal lock used by setlocale_null_r. */
pthread_mutex_t *
@@ -101,6 +112,9 @@ atomic_init (void)
init_needed = 0;
}
+/* Make sure the function gets exported from shared libraries. */
+DLL_EXPORTED mtx_t *gl_get_setlocale_null_lock (void);
+
/* Returns the internal lock used by setlocale_null_r. */
mtx_t *
gl_get_setlocale_null_lock (void)
diff --git a/m4/setlocale_null.m4 b/m4/setlocale_null.m4
index eff6e76..465ef11 100644
--- a/m4/setlocale_null.m4
+++ b/m4/setlocale_null.m4
@@ -90,3 +90,9 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
dnl with gcc or xlc, and empty otherwise.
AC_SUBST([LIB_SETLOCALE_NULL])
])
+
+# Prerequisites of lib/setlocale-lock.c.
+AC_DEFUN([gl_PREREQ_SETLOCALE_LOCK],
+[
+ gl_VISIBILITY
+])
diff --git a/modules/setlocale-null b/modules/setlocale-null
index 5240369..2774004 100644
--- a/modules/setlocale-null
+++ b/modules/setlocale-null
@@ -8,6 +8,7 @@ lib/setlocale-lock.c
lib/windows-initguard.h
m4/setlocale_null.m4
m4/threadlib.m4
+m4/visibility.m4
Depends-on:
locale
@@ -17,6 +18,7 @@ configure.ac:
gl_FUNC_SETLOCALE_NULL
if test $SETLOCALE_NULL_ALL_MTSAFE = 0 || test $SETLOCALE_NULL_ONE_MTSAFE = 0;
then
AC_LIBOBJ([setlocale-lock])
+ gl_PREREQ_SETLOCALE_LOCK
fi
gl_LOCALE_MODULE_INDICATOR([setlocale_null])
- new module 'setlocale-null', Bruno Haible, 2019/12/15
- setlocale-null: remove need for -lpthread on musl libc, *BSD, Haiku, Bruno Haible, 2019/12/16
- Re: new module 'setlocale-null', Bruno Haible, 2019/12/18
- Re: new module 'setlocale-null', Bruno Haible, 2019/12/22
- Re: new module 'setlocale-null',
Bruno Haible <=
- Re: new module 'setlocale-null', Bruno Haible, 2019/12/24