summaryrefslogtreecommitdiff
path: root/lib/locale.in.h
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2019-12-18 16:30:09 +0100
committerBruno Haible <bruno@clisp.org>2019-12-18 16:33:48 +0100
commit3a310962887322e0b94708984886de643f94f8a5 (patch)
treed17f7545cbae02461db7cc47a219396a6faf7a33 /lib/locale.in.h
parentf7efd84ea3e6ff2be5932b5213ac60c5c022f5b9 (diff)
downloadgnulib-3a310962887322e0b94708984886de643f94f8a5.tar.gz
setlocale-null: Make API more useful.
* lib/locale.in.h (setlocale_null_r): Renamed from setlocale_null. All callers changed. (setlocale_null): New declaration. * lib/setlocale_null.c (setlocale_null_androidfix): New function, extracted from setlocale_null_unlocked. (setlocale_null_unlocked): Invoke it. (setlocale_null_r): Renamed from setlocale_null. (setlocale_null): New function, extracted from setlocale_mtsafe in setlocale.c. * lib/setlocale.c: Don't include <errno.h>. (setlocale_mtsafe): Invoke setlocale_null. * lib/setlocale-lock.c: Update comments. * doc/posix-functions/setlocale.texi: Mention both functions.
Diffstat (limited to 'lib/locale.in.h')
-rw-r--r--lib/locale.in.h23
1 files changed, 17 insertions, 6 deletions
diff --git a/lib/locale.in.h b/lib/locale.in.h
index 67e6020fab..f4eccc230c 100644
--- a/lib/locale.in.h
+++ b/lib/locale.in.h
@@ -220,7 +220,7 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
In native Windows, there are 5 categories, and the maximum total length is
55+5*58. */
# define SETLOCALE_NULL_ALL_MAX (148+12*256+1)
-/* setlocale_null (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL),
+/* setlocale_null_r (CATEGORY, BUF, BUFSIZE) is like setlocale (CATEGORY, NULL),
except that
- it is guaranteed to be multithread-safe,
- it returns the resulting locale category name or locale name in the
@@ -234,14 +234,25 @@ _GL_WARN_ON_USE (setlocale, "setlocale works differently on native Windows - "
result is returned in BUF, but still NUL-terminated if BUFSIZE > 0.
For this call to be multithread-safe, *all* calls to
setlocale (CATEGORY, NULL) in all other threads must have been converted
- to use setlocale_null as well, and the other threads must not make other
- setlocale invocations (since changing the global locale has side effects
- on all threads). */
-_GL_FUNCDECL_SYS (setlocale_null, int,
+ to use setlocale_null_r or setlocale_null as well, and the other threads
+ must not make other setlocale invocations (since changing the global locale
+ has side effects on all threads). */
+_GL_FUNCDECL_SYS (setlocale_null_r, int,
(int category, char *buf, size_t bufsize)
_GL_ARG_NONNULL ((2)));
-_GL_CXXALIAS_SYS (setlocale_null, int,
+_GL_CXXALIAS_SYS (setlocale_null_r, int,
(int category, char *buf, size_t bufsize));
+_GL_CXXALIASWARN (setlocale_null_r);
+/* setlocale_null (CATEGORY) is like setlocale (CATEGORY, NULL), except that
+ it is guaranteed to be multithread-safe.
+ The return value is NULL if CATEGORY is invalid.
+ For this call to be multithread-safe, *all* calls to
+ setlocale (CATEGORY, NULL) in all other threads must have been converted
+ to use setlocale_null_r or setlocale_null as well, and the other threads
+ must not make other setlocale invocations (since changing the global locale
+ has side effects on all threads). */
+_GL_FUNCDECL_SYS (setlocale_null, const char *, (int category));
+_GL_CXXALIAS_SYS (setlocale_null, const char *, (int category));
_GL_CXXALIASWARN (setlocale_null);
#endif