From: Bruno Haible Date: Sun, 7 Mar 2021 01:47:03 +0000 (+0100) Subject: regex: Allow locking optimization independently of 'unlocked-io'. X-Git-Tag: v1.0~3036 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=ede75ad3eeeafe72d1af9de84897905edf76bd70;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index d2ffff05af..f9bdb94845 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +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'. diff --git a/doc/multithread.texi b/doc/multithread.texi index 082ccb05b5..cb0c620ff9 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 4b0a3efb64..1245e782ff 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)