]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
nl_langinfo: Work around nl_langinfo multithread-safety bug on macOS 26.
authorBruno Haible <bruno@clisp.org>
Sat, 20 Sep 2025 13:49:50 +0000 (15:49 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 20 Sep 2025 13:49:50 +0000 (15:49 +0200)
* m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Set NL_LANGINFO_MTSAFE to 0
on macOS.
* lib/nl_langinfo.c (ITEMS): Define appropriately on macOS.
* doc/posix-functions/nl_langinfo.texi: Document the macOS bug.

ChangeLog
doc/posix-functions/nl_langinfo.texi
lib/nl_langinfo.c
m4/nl_langinfo.m4

index 08dd88a67a3bb6a13472f3a3f385ed0bbc178e38..2009ef2582b8bafeb5e9db0d49d5b731a2f7aaed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2025-09-20  Bruno Haible  <bruno@clisp.org>
+
+       nl_langinfo: Work around nl_langinfo multithread-safety bug on macOS 26.
+       * m4/nl_langinfo.m4 (gl_FUNC_NL_LANGINFO): Set NL_LANGINFO_MTSAFE to 0
+       on macOS.
+       * lib/nl_langinfo.c (ITEMS): Define appropriately on macOS.
+       * doc/posix-functions/nl_langinfo.texi: Document the macOS bug.
+
 2025-09-20  Paul Eggert  <eggert@cs.ucla.edu>
 
        fchownat: fix unlikely EOVERFLOW bug
index d29628c12f68515ee804421566c706d80c5f0f62..02ff6ebbe091bbf6824abd3bb70628ad0bff47c2 100644 (file)
@@ -29,7 +29,7 @@ The constants @code{ERA}, @code{ERA_D_FMT}, @code{ERA_D_T_FMT},
 OpenBSD 7.5.
 @item
 This function is not multithread-safe on some platforms:
-Solaris 11.3.
+macOS 26, Solaris 11.3.
 @end itemize
 
 Portability problems not fixed by Gnulib:
index e7a9334ec909ba94a31211a4cd969332691d6324..f575c256c6169000cba2705e4c14c7d45c27c52b 100644 (file)
@@ -154,11 +154,15 @@ ctype_codeset (void)
    "thread5 disturbed by threadN!", even when threadN invokes only
       nl_langinfo (CODESET);
       nl_langinfo (CRNCYSTR);
-   Similarly on Solaris 10.  */
+   Similarly on Solaris 10 and macOS 26.  */
 
-# if !NL_LANGINFO_MTSAFE /* Solaris */
+# if !NL_LANGINFO_MTSAFE /* macOS, Solaris */
 
-#  define ITEMS (MAXSTRMSG + 1)
+#  ifdef __sun /* Solaris */
+#   define ITEMS (MAXSTRMSG + 1)
+#  else /* macOS */
+#   define ITEMS (CRNCYSTR + 20)
+#  endif
 #  define MAX_RESULT_LEN 80
 
 static char *
index 8459fa4530549b0b0e210c4eeafa795f863c061b..969c8ffdd1061a69cb648d965051c5ab9cc89444 100644 (file)
@@ -1,5 +1,5 @@
 # nl_langinfo.m4
-# serial 13
+# serial 14
 dnl Copyright (C) 2009-2025 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -16,10 +16,11 @@ AC_DEFUN([gl_FUNC_NL_LANGINFO],
   AC_REQUIRE([gl_PTHREADLIB])
   AC_CHECK_HEADERS_ONCE([threads.h])
   if test $ac_cv_func_nl_langinfo = yes; then
-    # On Solaris 10 and Solaris 11.3, nl_langinfo is not multithread-safe.
+    # On macOS 26, Solaris 10, and Solaris 11.3, nl_langinfo is not
+    # multithread-safe.
     case "$host_os" in
-      solaris*) NL_LANGINFO_MTSAFE=0 ;;
-      *)        NL_LANGINFO_MTSAFE=1 ;;
+      darwin* | solaris*) NL_LANGINFO_MTSAFE=0 ;;
+      *)                  NL_LANGINFO_MTSAFE=1 ;;
     esac
     AC_DEFINE_UNQUOTED([NL_LANGINFO_MTSAFE], [$NL_LANGINFO_MTSAFE],
       [Define to 1 if nl_langinfo is multithread-safe.])