>From ede75ad3eeeafe72d1af9de84897905edf76bd70 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 7 Mar 2021 02:47:03 +0100 Subject: [PATCH 7/9] regex: Allow locking optimization independently of 'unlocked-io'. * lib/regex_internal.h: Test GNULIB_REGEX_SINGLE_THREAD instead of USE_UNLOCKED_IO. * doc/multithread.texi: Document GNULIB_REGEX_SINGLE_THREAD. --- ChangeLog | 7 +++++++ doc/multithread.texi | 4 ++++ lib/regex_internal.h | 4 ++-- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d2ffff0..f9bdb94 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,12 @@ 2021-03-06 Bruno Haible + regex: Allow locking optimization independently of 'unlocked-io'. + * lib/regex_internal.h: Test GNULIB_REGEX_SINGLE_THREAD instead of + USE_UNLOCKED_IO. + * doc/multithread.texi: Document GNULIB_REGEX_SINGLE_THREAD. + +2021-03-06 Bruno Haible + exclude: Allow stdio optimization independently of 'unlocked-io'. * lib/exclude.c: Test GNULIB_EXCLUDE_SINGLE_THREAD instead of USE_UNLOCKED_IO. diff --git a/doc/multithread.texi b/doc/multithread.texi index 082ccb0..cb0c620 100644 --- a/doc/multithread.texi +++ b/doc/multithread.texi @@ -270,6 +270,10 @@ You need extra code for this optimization to be effective: include the @code{"unlocked-io.h"} header file. Some Gnulib modules that do operations on @code{FILE} streams have these preparations already included. @item +You may define the C macro @code{GNULIB_REGEX_SINGLE_THREAD}, if all the +programs in your package invoke the functions of the @code{regex} module +only from a single thread. +@item You may define the C macro @code{GNULIB_WCHAR_SINGLE}, if all the programs in your package are single-threaded and won't change the locale after it has been initialized. This macro optimizes the functions @code{mbrtowc} and diff --git a/lib/regex_internal.h b/lib/regex_internal.h index 4b0a3ef..1245e78 100644 --- a/lib/regex_internal.h +++ b/lib/regex_internal.h @@ -53,14 +53,14 @@ # define lock_fini(lock) ((void) 0) # define lock_lock(lock) __libc_lock_lock (lock) # define lock_unlock(lock) __libc_lock_unlock (lock) -#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO +#elif defined GNULIB_LOCK && !defined GNULIB_REGEX_SINGLE_THREAD # include "glthread/lock.h" # define lock_define(name) gl_lock_define (, name) # define lock_init(lock) glthread_lock_init (&(lock)) # define lock_fini(lock) glthread_lock_destroy (&(lock)) # define lock_lock(lock) glthread_lock_lock (&(lock)) # define lock_unlock(lock) glthread_lock_unlock (&(lock)) -#elif defined GNULIB_PTHREAD && !defined USE_UNLOCKED_IO +#elif defined GNULIB_PTHREAD && !defined GNULIB_REGEX_SINGLE_THREAD # include # define lock_define(name) pthread_mutex_t name; # define lock_init(lock) pthread_mutex_init (&(lock), 0) -- 2.7.4