>From 2a200f4eb4754823c5674580bb0b68a88fd35077 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 7 Mar 2021 10:45:58 +0100 Subject: [PATCH 9/9] Rename GNULIB_WCHAR_SINGLE to GNULIB_WCHAR_SINGLE_LOCALE. * lib/lc-charset-dispatch.c: Test GNULIB_WCHAR_SINGLE_LOCALE instead of GNULIB_WCHAR_SINGLE. * lib/wcwidth.c: Likewise. * tests/test-wcwidth.c: Likewise. * doc/multithread.texi: Document GNULIB_WCHAR_SINGLE_LOCALE instead of GNULIB_WCHAR_SINGLE. * NEWS: Document the change. --- ChangeLog | 11 +++++++++++ NEWS | 4 ++++ doc/multithread.texi | 13 ++++++++++--- lib/lc-charset-dispatch.c | 6 +++--- lib/wcwidth.c | 2 +- tests/test-wcwidth.c | 2 +- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80590b1..8b5ed00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2021-03-07 Bruno Haible + + Rename GNULIB_WCHAR_SINGLE to GNULIB_WCHAR_SINGLE_LOCALE. + * lib/lc-charset-dispatch.c: Test GNULIB_WCHAR_SINGLE_LOCALE instead of + GNULIB_WCHAR_SINGLE. + * lib/wcwidth.c: Likewise. + * tests/test-wcwidth.c: Likewise. + * doc/multithread.texi: Document GNULIB_WCHAR_SINGLE_LOCALE instead of + GNULIB_WCHAR_SINGLE. + * NEWS: Document the change. + 2021-03-06 Bruno Haible mbrtowc: Allow locking optimization independently of 'unlocked-io'. diff --git a/NEWS b/NEWS index 318055a..ba89881 100644 --- a/NEWS +++ b/NEWS @@ -60,6 +60,10 @@ User visible incompatible changes Date Modules Changes +2021-03-07 mbrtowc For single-locale optimizations, you now need to + mbrtoc32 define GNULIB_WCHAR_SINGLE_LOCALE instead of + wcwidth GNULIB_WCHAR_SINGLE. + 2021-02-28 parse-datetime The parse_datetime2 function has been moved to the new parse-datetime2 module, so that programs that need just parse_datetime need diff --git a/doc/multithread.texi b/doc/multithread.texi index b28d1de..eef724d 100644 --- a/doc/multithread.texi +++ b/doc/multithread.texi @@ -279,9 +279,16 @@ 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 +You may define the C macro @code{GNULIB_WCHAR_SINGLE_LOCALE}, if all the +programs in your package set the locale early and +@itemize +@item +don't change the locale after it has been initialized, and +@item +don't call locale sensitive functions (@code{mbrtowc}, @code{wcwidth}, etc.@:) +before the locale has been initialized. +@end itemize +This macro optimizes the functions @code{mbrtowc}, @code{mbrtoc32}, and @code{wcwidth}. @item You may define the C macro @code{GNULIB_GETUSERSHELL_SINGLE_THREAD}, if all the diff --git a/lib/lc-charset-dispatch.c b/lib/lc-charset-dispatch.c index 879f71a..5c63c4b 100644 --- a/lib/lc-charset-dispatch.c +++ b/lib/lc-charset-dispatch.c @@ -26,7 +26,7 @@ # include "localcharset.h" # include "streq.h" -# if GNULIB_WCHAR_SINGLE +# if GNULIB_WCHAR_SINGLE_LOCALE /* When we know that the locale does not change, provide a speedup by caching the value of locale_encoding_classification. */ # define locale_encoding_classification_cached locale_encoding_classification @@ -35,7 +35,7 @@ # define locale_encoding_classification_uncached locale_encoding_classification # endif -# if GNULIB_WCHAR_SINGLE +# if GNULIB_WCHAR_SINGLE_LOCALE static inline # endif enc_t @@ -59,7 +59,7 @@ locale_encoding_classification_uncached (void) return enc_other; } -# if GNULIB_WCHAR_SINGLE +# if GNULIB_WCHAR_SINGLE_LOCALE static int cached_locale_enc = -1; diff --git a/lib/wcwidth.c b/lib/wcwidth.c index 9009ebc..8d85082 100644 --- a/lib/wcwidth.c +++ b/lib/wcwidth.c @@ -34,7 +34,7 @@ is_locale_utf8 (void) return STREQ_OPT (encoding, "UTF-8", 'U', 'T', 'F', '-', '8', 0, 0, 0, 0); } -#if GNULIB_WCHAR_SINGLE +#if GNULIB_WCHAR_SINGLE_LOCALE /* When we know that the locale does not change, provide a speedup by caching the value of is_locale_utf8. */ static int cached_is_locale_utf8 = -1; diff --git a/tests/test-wcwidth.c b/tests/test-wcwidth.c index 16c6837..e5e3a54 100644 --- a/tests/test-wcwidth.c +++ b/tests/test-wcwidth.c @@ -35,7 +35,7 @@ main () { wchar_t wc; -#if !GNULIB_WCHAR_SINGLE +#if !GNULIB_WCHAR_SINGLE_LOCALE # ifdef C_CTYPE_ASCII /* Test width of ASCII characters. */ for (wc = 0x20; wc < 0x7F; wc++) -- 2.7.4