From: Bruno Haible Date: Sat, 20 Sep 2025 13:49:50 +0000 (+0200) Subject: nl_langinfo: Work around nl_langinfo multithread-safety bug on macOS 26. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ebd5a9aa7e24dce4ac2fd4f5074b43b00759d54;p=thirdparty%2Fgnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 08dd88a67a..2009ef2582 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2025-09-20 Bruno Haible + + 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 fchownat: fix unlikely EOVERFLOW bug diff --git a/doc/posix-functions/nl_langinfo.texi b/doc/posix-functions/nl_langinfo.texi index d29628c12f..02ff6ebbe0 100644 --- a/doc/posix-functions/nl_langinfo.texi +++ b/doc/posix-functions/nl_langinfo.texi @@ -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: diff --git a/lib/nl_langinfo.c b/lib/nl_langinfo.c index e7a9334ec9..f575c256c6 100644 --- a/lib/nl_langinfo.c +++ b/lib/nl_langinfo.c @@ -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 * diff --git a/m4/nl_langinfo.m4 b/m4/nl_langinfo.m4 index 8459fa4530..969c8ffdd1 100644 --- a/m4/nl_langinfo.m4 +++ b/m4/nl_langinfo.m4 @@ -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.])