summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Haible <bruno@clisp.org>2021-03-07 02:21:49 +0100
committerBruno Haible <bruno@clisp.org>2021-03-07 11:01:57 +0100
commit92052c44910568ef6012584a344edcb736949d2c (patch)
treef5a7d07f8d710c448b824401a73f5cb2dd7e1177
parent212f0b69ab67a4d6230c2ab85e28c2f54b31060c (diff)
downloadgnulib-92052c44910568ef6012584a344edcb736949d2c.tar.gz
getusershell: Optimize stdio accesses when possible.
* lib/getusershell.c: Test GNULIB_GETUSERSHELL_SINGLE_THREAD instead of USE_UNLOCKED_IO. * modules/getusershell (Depends-on): Add unlocked-io-internal. * doc/multithread.texi: Document GNULIB_GETUSERSHELL_SINGLE_THREAD.
-rw-r--r--ChangeLog8
-rw-r--r--doc/multithread.texi4
-rw-r--r--lib/getusershell.c2
-rw-r--r--modules/getusershell5
4 files changed, 16 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 80d97a0f05..d6e8d542de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
2021-03-06 Bruno Haible <bruno@clisp.org>
+ getusershell: Optimize stdio accesses when possible.
+ * lib/getusershell.c: Test GNULIB_GETUSERSHELL_SINGLE_THREAD instead of
+ USE_UNLOCKED_IO.
+ * modules/getusershell (Depends-on): Add unlocked-io-internal.
+ * doc/multithread.texi: Document GNULIB_GETUSERSHELL_SINGLE_THREAD.
+
+2021-03-06 Bruno Haible <bruno@clisp.org>
+
unlocked-io-internal: New module.
* m4/unlocked-io.m4 (gl_FUNC_GLIBC_UNLOCKED_IO): Don't define
USE_UNLOCKED_IO here.
diff --git a/doc/multithread.texi b/doc/multithread.texi
index 7fe19a7817..a63d3ee0fa 100644
--- a/doc/multithread.texi
+++ b/doc/multithread.texi
@@ -274,4 +274,8 @@ 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
@code{wcwidth}.
+@item
+You may define the C macro @code{GNULIB_GETUSERSHELL_SINGLE_THREAD}, if all the
+programs in your package invoke the functions @code{setusershell},
+@code{getusershell}, @code{endusershell} only from a single thread.
@end itemize
diff --git a/lib/getusershell.c b/lib/getusershell.c
index 6ae941052d..be8a068455 100644
--- a/lib/getusershell.c
+++ b/lib/getusershell.c
@@ -39,7 +39,7 @@
#include "stdio--.h"
#include "xalloc.h"
-#if USE_UNLOCKED_IO
+#if GNULIB_GETUSERSHELL_SINGLE_THREAD
# include "unlocked-io.h"
#endif
diff --git a/modules/getusershell b/modules/getusershell
index 26f99e58ca..ed2f30f3c5 100644
--- a/modules/getusershell
+++ b/modules/getusershell
@@ -8,8 +8,9 @@ m4/getusershell.m4
Depends-on:
unistd
extensions
-fopen-safer [test $HAVE_GETUSERSHELL = 0]
-xalloc [test $HAVE_GETUSERSHELL = 0]
+fopen-safer [test $HAVE_GETUSERSHELL = 0]
+unlocked-io-internal [test $HAVE_GETUSERSHELL = 0]
+xalloc [test $HAVE_GETUSERSHELL = 0]
configure.ac:
gl_FUNC_GETUSERSHELL