]> Savannah Git Hosting - gnulib.git/commitdiff
mbrtowc: Allow locking optimization independently of 'unlocked-io'.
authorBruno Haible <bruno@clisp.org>
Sun, 7 Mar 2021 01:57:46 +0000 (02:57 +0100)
committerBruno Haible <bruno@clisp.org>
Sun, 7 Mar 2021 10:02:00 +0000 (11:02 +0100)
* lib/mbtowc-lock.h: Test GNULIB_MBRTOWC_SINGLE_THREAD instead of
USE_UNLOCKED_IO.
* doc/multithread.texi: Document GNULIB_MBRTOWC_SINGLE_THREAD.

ChangeLog
doc/multithread.texi
lib/mbtowc-lock.h

index f9bdb94845043741abc9cb886736a7781b644430..80590b1f0301a32090e76cdef626c1696e9f2054 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2021-03-06  Bruno Haible  <bruno@clisp.org>
+
+       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  <bruno@clisp.org>
 
        regex: Allow locking optimization independently of 'unlocked-io'.
index cb0c620ff9ac9f80831d341a3d74832793d842e0..b28d1de73c9b19a06526ef4e360cb98f4fa98b6c 100644 (file)
@@ -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
index b7c5ba8a08412b56c03c4da7995ae3fa3be8f579..3b6f5f969661c6619d3f579dafa19d041e164e59 100644 (file)
@@ -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)