+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'.
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
/* 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)