]> Savannah Git Hosting - gnulib.git/commitdiff
setlocale-null: Don't use a lock in Cygwin >= 3.4.6.
authorBruno Haible <bruno@clisp.org>
Mon, 6 Feb 2023 17:33:37 +0000 (18:33 +0100)
committerBruno Haible <bruno@clisp.org>
Mon, 6 Feb 2023 17:33:37 +0000 (18:33 +0100)
Road paved by Corinna Vinschen <vinschen@redhat.com>.

* m4/setlocale_null.m4 (gl_FUNC_SETLOCALE_NULL): Assume that
setlocale (LC_ALL, NULL) is multithread-safe in Cygwin >= 3.4.6.
* lib/setlocale_null.c: Update comments.
* tests/test-setlocale_null-mt-all.c: Likewise.

ChangeLog
lib/setlocale_null.c
m4/setlocale_null.m4
tests/test-setlocale_null-mt-all.c

index 7a2c0cfa2fa1030b5799e543a36de11f05d52a5c..ddec3a97b388372de72c564729f4bf7e818637ed 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2023-02-06  Bruno Haible  <bruno@clisp.org>
+
+       setlocale-null: Don't use a lock in Cygwin >= 3.4.6.
+       Road paved by Corinna Vinschen <vinschen@redhat.com>.
+       * m4/setlocale_null.m4 (gl_FUNC_SETLOCALE_NULL): Assume that
+       setlocale (LC_ALL, NULL) is multithread-safe in Cygwin >= 3.4.6.
+       * lib/setlocale_null.c: Update comments.
+       * tests/test-setlocale_null-mt-all.c: Likewise.
+
 2023-02-05  Bruno Haible  <bruno@clisp.org>
 
        c-nullptr: Fix conflict with libstdc++ in GCC >= 11.
index 6ac563db14a9931cd2c471256cf75b2cd245d654..89c8a065981da3fdfedb1968d6b438f5e269635d 100644 (file)
@@ -173,7 +173,7 @@ setlocale_null_unlocked (int category, char *buf, size_t bufsize)
 #endif
 }
 
-#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */
+#if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE) /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */
 
 /* Use a lock, so that no two threads can invoke setlocale_null_unlocked
    at the same time.  */
@@ -198,7 +198,7 @@ setlocale_null_with_lock (int category, char *buf, size_t bufsize)
   return ret;
 }
 
-# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin */
+# elif HAVE_PTHREAD_API /* musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin < 3.4.6 */
 
 extern
 #  if defined _WIN32 || defined __CYGWIN__
index dd6a5ef538265159bb662cf5daf25913eb1582d8..b41df499a854c2a924d73dba4fe7508c7d0c2b1e 100644 (file)
@@ -1,4 +1,4 @@
-# setlocale_null.m4 serial 6
+# setlocale_null.m4 serial 7
 dnl Copyright (C) 2019-2023 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -13,9 +13,23 @@ AC_DEFUN([gl_FUNC_SETLOCALE_NULL],
   AC_CACHE_CHECK([whether setlocale (LC_ALL, NULL) is multithread-safe],
     [gl_cv_func_setlocale_null_all_mtsafe],
     [case "$host_os" in
-       # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku, Cygwin.
-       *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku* | cygwin*)
+       # Guess no on musl libc, macOS, FreeBSD, NetBSD, OpenBSD, AIX, Haiku.
+       *-musl* | darwin* | freebsd* | midnightbsd* | netbsd* | openbsd* | aix* | haiku*)
          gl_cv_func_setlocale_null_all_mtsafe=no ;;
+       # Guess no on Cygwin < 3.4.6.
+       cygwin*)
+         AC_EGREP_CPP([Lucky user],
+           [
+#if defined __CYGWIN__
+ #include <cygwin/version.h>
+ #if CYGWIN_VERSION_DLL_COMBINED >= CYGWIN_VERSION_DLL_MAKE_COMBINED (3004, 6)
+  Lucky user
+ #endif
+#endif
+          ],
+          [gl_cv_func_setlocale_null_all_mtsafe=yes],
+          [gl_cv_func_setlocale_null_all_mtsafe=no])
+        ;;
        # Guess yes on glibc, HP-UX, IRIX, Solaris, native Windows.
        *-gnu* | gnu* | hpux* | irix* | solaris* | mingw*)
          gl_cv_func_setlocale_null_all_mtsafe=yes ;;
index 6036c260cd59cb9e2e7e21a225884d8281773a95..74804066397cbe7f78f6dd118f97d7a55ef77854 100644 (file)
@@ -166,7 +166,7 @@ Solaris 11.0         OK
 Solaris 11.4         OK
 Solaris OpenIndiana  OK
 Haiku                crash < 1 sec
-Cygwin               crash < 1 sec
+Cygwin < 3.4.6       crash < 1 sec
 mingw                OK
 MSVC                 OK (assuming compiler option /MD !)
 */