Commit 2028f285 authored by Bruno Haible's avatar Bruno Haible
Browse files

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.
parent 0da79aa8
2019-12-23 Bruno Haible <bruno@clisp.org>
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.
2019-12-22 Paul Eggert <eggert@cs.ucla.edu>
 
gethrxtime: fix rounding bug with negative args
......@@ -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)
......
......@@ -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
])
......@@ -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])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment