>From 92052c44910568ef6012584a344edcb736949d2c Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 7 Mar 2021 02:21:49 +0100 Subject: [PATCH 3/9] 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. --- ChangeLog | 8 ++++++++ doc/multithread.texi | 4 ++++ lib/getusershell.c | 2 +- modules/getusershell | 5 +++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 80d97a0..d6e8d54 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2021-03-06 Bruno Haible + 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 + 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 7fe19a7..a63d3ee 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 6ae9410..be8a068 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 26f99e5..ed2f30f 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 -- 2.7.4