]> git.ipfire.org Git - thirdparty/gnulib.git/commitdiff
localename: add GNULIB_LOCALENAME_SINGLE_THREAD master
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 29 Jul 2026 22:19:28 +0000 (15:19 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Wed, 29 Jul 2026 22:19:58 +0000 (15:19 -0700)
If GNULIB_LOCALENAME_SINGLE_THREAD is defined,
omit locks in localename and getlocalename-related functions.
Useful for GNU grep; see <https://bugs.gnu.org/81515>.
* lib/getlocalename_l-unsafe.c, lib/getlocalename_l.c:
* lib/localename.c (USE_ISOC_AND_POSIX_THREADS, USE_ISOC_THREADS)
(USE_POSIX_THREADS, USE_WINDOWS_THREADS)
[GNULIB_LOCALENAME_SINGLE_THREAD]: Undef.

ChangeLog
doc/multithread.texi
lib/getlocalename_l-unsafe.c
lib/getlocalename_l.c
lib/glthread/lock.h
lib/localename.c

index b4df229a0ffef43670a9fcc57688300ae71e44ea..2cbc8b47d7b6de2a6a1ef7cbc25705071a6bbe89 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2026-07-29  Paul Eggert  <eggert@cs.ucla.edu>
+
+       localename: add GNULIB_LOCALENAME_SINGLE_THREAD
+       If GNULIB_LOCALENAME_SINGLE_THREAD is defined,
+       omit locks in localename and getlocalename-related functions.
+       Useful for GNU grep; see <https://bugs.gnu.org/81515>.
+       * lib/getlocalename_l-unsafe.c, lib/getlocalename_l.c:
+       * lib/localename.c (USE_ISOC_AND_POSIX_THREADS, USE_ISOC_THREADS)
+       (USE_POSIX_THREADS, USE_WINDOWS_THREADS)
+       [GNULIB_LOCALENAME_SINGLE_THREAD]: Undef.
+
 2026-07-29  Bruno Haible  <bruno@clisp.org>
 
        tests: Avoid some more runtime errors with Fil-C.
index bdf579df834b27445744cbc128b563a628ae33f4..d14c9cb71974485af39e0fcec97f3f1725994b32 100644 (file)
@@ -269,7 +269,7 @@ in the Linux kernel, to lock elision
 -- single-threaded programs can still profit performance-wise from the
 assertion that they are single-threaded.
 
-Gnulib defines four facilities that help optimizing for the single-threaded
+Gnulib defines several facilities that help optimizing for the single-threaded
 case.
 
 @itemize @bullet
@@ -344,4 +344,9 @@ and the other functions' Gnulib implementations use Gnulib
 You may define the C macro @code{GNULIB_EXCLUDE_SINGLE_THREAD}, if all the
 programs in your package invoke the functions of the @code{exclude} module
 only from a single thread.
+@item
+You may define the C macro @code{GNULIB_LOCALENAME_SINGLE_THREAD},
+if all the programs in your package invoke the functions of the
+@code{getlocalename_l-simple}, @code{getlocalename_l-unsafe} and
+@code{localename} modules only from a single thread.
 @end itemize
index 1d674f219b8de466ee6b2ccc28ccf84ccc754431..150858f91a275a4d59c504cd28b8e3547342b51c 100644 (file)
 
 #include <config.h>
 
+#if GNULIB_LOCALENAME_SINGLE_THREAD
+# undef USE_ISOC_AND_POSIX_THREADS
+# undef USE_ISOC_THREADS
+# undef USE_POSIX_THREADS
+# undef USE_WINDOWS_THREADS
+#endif
+
 /* Specification.  */
 #include "getlocalename_l-unsafe.h"
 
index 140916ceb96c8af0a97f312fe9da87dd1875f357..989ba2658d4debffea2c7c0252144da5bf5ecb31 100644 (file)
 
 #include <config.h>
 
+#if GNULIB_LOCALENAME_SINGLE_THREAD
+# undef USE_ISOC_AND_POSIX_THREADS
+# undef USE_ISOC_THREADS
+# undef USE_POSIX_THREADS
+# undef USE_WINDOWS_THREADS
+#endif
+
 /* Specification.  */
 #include <locale.h>
 
index b9fb907ead020b76327ab19a57b8878c279e909e..8473c4dbed0bf1942ff3802416ebd3ee1f0fa90e 100644 (file)
@@ -73,6 +73,8 @@
 /* This file uses HAVE_THREADS_H, HAVE_PTHREAD_RWLOCK,
    HAVE_PTHREAD_RWLOCK_RDLOCK_PREFER_WRITER,
    PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP,
+   USE_ISOC_THREADS, USE_POSIX_THREADS, USE_ISOC_AND_POSIX_THREADS,
+   USE_WINDOWS_THREADS,
    HAVE_PTHREAD_MUTEX_RECURSIVE.  */
 #if !_GL_CONFIG_H_INCLUDED
  #error "Please include config.h first."
index aac0f7ce9007e51ed3f8740ea0c9dff8a857a45e..f355013171f103b2dbcef390e46b9b75078c9018 100644 (file)
 
 #include <config.h>
 
+#if GNULIB_LOCALENAME_SINGLE_THREAD
+# undef USE_ISOC_AND_POSIX_THREADS
+# undef USE_ISOC_THREADS
+# undef USE_POSIX_THREADS
+# undef USE_WINDOWS_THREADS
+#endif
+
 /* Specification.  */
 #include "localename.h"