+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.
-- 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
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
#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"
#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>
/* 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."
#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"