]> Savannah Git Hosting - gnulib.git/commitdiff
mbrtowc, mbrtoc32, nl_langinfo, setlocale-null: Obey --disable-threads.
authorBruno Haible <bruno@clisp.org>
Fri, 17 Nov 2023 18:37:24 +0000 (19:37 +0100)
committerBruno Haible <bruno@clisp.org>
Fri, 17 Nov 2023 19:34:13 +0000 (20:34 +0100)
Reported by David Edelsohn <dje.gcc@gmail.com> in
<https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636830.html>,
<https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636843.html>.

* m4/threadlib.m4 (gl_THREADLIB_BODY): If --disable-threads was
specified, define AVOID_ANY_THREADS to 1.
* lib/mbtowc-lock.c: Omit all code if --disable-threads was specified.
* lib/nl_langinfo-lock.c: Likewise.
* lib/setlocale-lock.c: Likewise.
* lib/mbtowc-lock.h: Omit locking code if --disable-threads was
specified.
* lib/nl_langinfo.c: Likewise.
* lib/setlocale_null.c: Likewise.
* lib/mbrtowc.c: Don't include any multithreading headers if
--disable-threads was specified.
* lib/mbrtoc32.c: Likewise.

ChangeLog
lib/mbrtoc32.c
lib/mbrtowc.c
lib/mbtowc-lock.c
lib/mbtowc-lock.h
lib/nl_langinfo-lock.c
lib/nl_langinfo.c
lib/setlocale-lock.c
lib/setlocale_null.c
m4/threadlib.m4

index a634e81232e69d8ff8bb6ffa9e125af29a4c8e1c..807b2d6e7ddd92089e522bdb69446008b5b0bddd 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,22 @@
+2023-11-17  Bruno Haible  <bruno@clisp.org>
+
+       mbrtowc, mbrtoc32, nl_langinfo, setlocale-null: Obey --disable-threads.
+       Reported by David Edelsohn <dje.gcc@gmail.com> in
+       <https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636830.html>,
+       <https://gcc.gnu.org/pipermail/gcc-patches/2023-November/636843.html>.
+       * m4/threadlib.m4 (gl_THREADLIB_BODY): If --disable-threads was
+       specified, define AVOID_ANY_THREADS to 1.
+       * lib/mbtowc-lock.c: Omit all code if --disable-threads was specified.
+       * lib/nl_langinfo-lock.c: Likewise.
+       * lib/setlocale-lock.c: Likewise.
+       * lib/mbtowc-lock.h: Omit locking code if --disable-threads was
+       specified.
+       * lib/nl_langinfo.c: Likewise.
+       * lib/setlocale_null.c: Likewise.
+       * lib/mbrtowc.c: Don't include any multithreading headers if
+       --disable-threads was specified.
+       * lib/mbrtoc32.c: Likewise.
+
 2023-11-17  Bruno Haible  <bruno@clisp.org>
 
        gettext: Recognize a statically built libintl on macOS and AIX.
index 0933437a4b8d3ca896b6ebfe586a0edb9d70e67c..755d092e05fad7f21ef8914fd369a037b64055a7 100644 (file)
      branch below.
    They are equivalent.  */
 
-# if defined _WIN32 && !defined __CYGWIN__
+# if AVOID_ANY_THREADS
+
+/* The option '--disable-threads' explicitly requests no locking.  */
+
+# elif defined _WIN32 && !defined __CYGWIN__
 
 #  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
 #  include <windows.h>
index c1a689a270d61423c37484d19f9a3a23688ddb8c..0a061906d75989fa130ba3c93054d049c54def4f 100644 (file)
 # include <stdint.h>
 # include <stdlib.h>
 
-# if defined _WIN32 && !defined __CYGWIN__
+# if AVOID_ANY_THREADS
+
+/* The option '--disable-threads' explicitly requests no locking.  */
+
+# elif defined _WIN32 && !defined __CYGWIN__
 
 #  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
 #  include <windows.h>
index c4d0b088f6ae2a23962c0dd620db5315587e176e..9d160682636d1a56e0ae534e23d3f769de0c1b33 100644 (file)
 
 #include <config.h>
 
+/* The option '--disable-threads' explicitly requests no locking.  */
 /* When it is known that the gl_get_mbtowc_lock function is defined
    by a dependency library, it should not be defined here.  */
-#if OMIT_MBTOWC_LOCK
+#if AVOID_ANY_THREADS || OMIT_MBTOWC_LOCK
 
 /* This declaration is solely to ensure that after preprocessing
    this file is never empty.  */
index beb37722f5e0db4a64b76635a124bb9bc8636478..b0cc80c6a670df651f76cfbd3538bd623ba5e51e 100644 (file)
@@ -32,7 +32,7 @@ mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m)
 /* Prohibit renaming this symbol.  */
 #undef gl_get_mbtowc_lock
 
-#if GNULIB_MBRTOWC_SINGLE_THREAD
+#if AVOID_ANY_THREADS || GNULIB_MBRTOWC_SINGLE_THREAD
 
 /* All uses of this function are in a single thread.  No locking needed.  */
 
index fb1229995957d363ca4e0bf054f53d1d16060c9d..f4cea0c2904e54601fae0ffa03db1b8278c43ff9 100644 (file)
 
 #include <config.h>
 
+/* The option '--disable-threads' explicitly requests no locking.  */
 /* When it is known that the gl_get_nl_langinfo_lock function is defined
    by a dependency library, it should not be defined here.  */
-#if OMIT_NL_LANGINFO_LOCK
+#if AVOID_ANY_THREADS || OMIT_NL_LANGINFO_LOCK
 
 /* This declaration is solely to ensure that after preprocessing
    this file is never empty.  */
index f872c6d5e22dbf7ddcda9a05c10ddf9f88e8a97e..3be275510e693055f1820dfe0c5103cf712998cf 100644 (file)
 #endif
 
 #if REPLACE_NL_LANGINFO && !NL_LANGINFO_MTSAFE
-# if defined _WIN32 && !defined __CYGWIN__
+
+# if AVOID_ANY_THREADS
+
+/* The option '--disable-threads' explicitly requests no locking.  */
+
+# elif defined _WIN32 && !defined __CYGWIN__
 
 #  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
 #  include <windows.h>
@@ -51,6 +56,7 @@
 #  include <threads.h>
 
 # endif
+
 #endif
 
 /* nl_langinfo() must be multithread-safe.  To achieve this without using
@@ -186,7 +192,12 @@ nl_langinfo_unlocked (nl_item item)
 /* Prohibit renaming this symbol.  */
 #  undef gl_get_nl_langinfo_lock
 
-#  if defined _WIN32 && !defined __CYGWIN__
+#  if AVOID_ANY_THREADS
+
+/* The option '--disable-threads' explicitly requests no locking.  */
+#   define nl_langinfo_with_lock nl_langinfo_unlocked
+
+#  elif defined _WIN32 && !defined __CYGWIN__
 
 extern __declspec(dllimport) CRITICAL_SECTION *gl_get_nl_langinfo_lock (void);
 
index 593f63711b3390a5e4d52868ddd58b9571ce6fdf..090f824abe6259eeac883b7bc5ee86051baedd6e 100644 (file)
 
 #include <config.h>
 
+/* The option '--disable-threads' explicitly requests no locking.  */
 /* When it is known that the gl_get_setlocale_null_lock function is defined
    by a dependency library, it should not be defined here.  */
-#if OMIT_SETLOCALE_LOCK
+#if AVOID_ANY_THREADS || OMIT_SETLOCALE_LOCK
 
 /* This declaration is solely to ensure that after preprocessing
    this file is never empty.  */
index 89c8a065981da3fdfedb1968d6b438f5e269635d..9d7cb785f74bf36b82be359a9f230caac111e063 100644 (file)
 #endif
 
 #if !(SETLOCALE_NULL_ALL_MTSAFE && SETLOCALE_NULL_ONE_MTSAFE)
-# if defined _WIN32 && !defined __CYGWIN__
+
+# if AVOID_ANY_THREADS
+
+/* The option '--disable-threads' explicitly requests no locking.  */
+
+# elif defined _WIN32 && !defined __CYGWIN__
 
 #  define WIN32_LEAN_AND_MEAN  /* avoid including junk */
 #  include <windows.h>
@@ -51,6 +56,7 @@
 #  include <threads.h>
 
 # endif
+
 #endif
 
 /* Use the system's setlocale() function, not the gnulib override, here.  */
@@ -181,7 +187,12 @@ setlocale_null_unlocked (int category, char *buf, size_t bufsize)
 /* Prohibit renaming this symbol.  */
 # undef gl_get_setlocale_null_lock
 
-# if defined _WIN32 && !defined __CYGWIN__
+# if AVOID_ANY_THREADS
+
+/* The option '--disable-threads' explicitly requests no locking.  */
+#  define setlocale_null_with_lock setlocale_null_unlocked
+
+# elif defined _WIN32 && !defined __CYGWIN__
 
 extern __declspec(dllimport) CRITICAL_SECTION *gl_get_setlocale_null_lock (void);
 
index 855e563d887e9b450b850384ce84cd11d035f816..b35ad53fd85128fd04d88ae0a42bcb70ce4fa738 100644 (file)
@@ -1,4 +1,4 @@
-# threadlib.m4 serial 40
+# threadlib.m4 serial 41
 dnl Copyright (C) 2005-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,
@@ -584,6 +584,10 @@ AC_DEFUN([gl_THREADLIB_BODY],
           ;;
       esac
     fi
+  else
+    dnl "$gl_use_threads" is "no".
+    AC_DEFINE([AVOID_ANY_THREADS], [1],
+      [Define if no multithread safety and no multithreading is desired.])
   fi
   AC_MSG_CHECKING([for multithread API to use])
   AC_MSG_RESULT([$gl_threads_api])