From cd057fa80c74dcf1d0a74290cb5ad6cdc3136428 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 7 Mar 2021 02:57:46 +0100 Subject: [PATCH] mbrtowc: Allow locking optimization independently of 'unlocked-io'. * lib/mbtowc-lock.h: Test GNULIB_MBRTOWC_SINGLE_THREAD instead of USE_UNLOCKED_IO. * doc/multithread.texi: Document GNULIB_MBRTOWC_SINGLE_THREAD. --- ChangeLog | 7 +++++++ doc/multithread.texi | 5 +++++ lib/mbtowc-lock.h | 4 +++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index f9bdb94845..80590b1f03 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2021-03-06 Bruno Haible + + mbrtowc: Allow locking optimization independently of 'unlocked-io'. + * lib/mbtowc-lock.h: Test GNULIB_MBRTOWC_SINGLE_THREAD instead of + USE_UNLOCKED_IO. + * doc/multithread.texi: Document GNULIB_MBRTOWC_SINGLE_THREAD. + 2021-03-06 Bruno Haible regex: Allow locking optimization independently of 'unlocked-io'. diff --git a/doc/multithread.texi b/doc/multithread.texi index cb0c620ff9..b28d1de73c 100644 --- a/doc/multithread.texi +++ b/doc/multithread.texi @@ -274,6 +274,11 @@ 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_MBRTOWC_SINGLE_THREAD}, if all the +programs in your package invoke the functions @code{mbrtowc}, @code{mbrtoc32}, +and the functions of the @code{regex} module only from a single thread. (The +@code{regex} module uses @code{mbrtowc} under the hood.) +@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/mbtowc-lock.h b/lib/mbtowc-lock.h index b7c5ba8a08..3b6f5f9696 100644 --- a/lib/mbtowc-lock.h +++ b/lib/mbtowc-lock.h @@ -32,7 +32,9 @@ mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m) /* Prohibit renaming this symbol. */ #undef gl_get_mbtowc_lock -#ifdef USE_UNLOCKED_IO +#if GNULIB_MBRTOWC_SINGLE_THREAD + +/* All uses of this function are in a single thread. No locking needed. */ static int mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m) -- 2.39.5