bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
* [PATCH] mbrtowc: port to AIX 7.1 with xlc 12.1
@ 2021-03-03  0:28 Paul Eggert
  2021-03-03  3:27 ` single-threaded optimizations Bruno Haible
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Eggert @ 2021-03-03  0:28 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

Fix a problem with locks when building GNU Tar (Savannah commit
55f2a0772e08b9febac3ac0de5cb048d4c60d2f5) on AIX 7.1 with IBM XL
C/C++ V12.1 using ‘./configure CC=xlc’.  The link fails due to
missing definitions of pthread_mutex_lock and
pthread_mutex_unlock.  GNU Tar uses unlocked-io and so
should not need to worry about multithreading or locks.
* lib/mbtowc-lock.h (mbtowc_with_lock) [USE_UNLOCKED_IO]:
Don’t bother with locks, since this app is single-threaded.
There may be similar linking problems with lib/nl_langinfo.c and
lib/setlocale_null.c but my GNU Tar build didn’t run into them, so
I left them alone for now.
---
 ChangeLog         | 15 +++++++++++++++
 lib/mbtowc-lock.h | 10 +++++++++-
 2 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 0304f6958..7ba436925 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+2021-03-02  Paul Eggert  <eggert@cs.ucla.edu>
+
+	mbrtowc: port to AIX 7.1 with xlc 12.1
+	Fix a problem with locks when building GNU Tar (Savannah commit
+	55f2a0772e08b9febac3ac0de5cb048d4c60d2f5) on AIX 7.1 with IBM XL
+	C/C++ V12.1 using ‘./configure CC=xlc’.  The link fails due to
+	missing definitions of pthread_mutex_lock and
+	pthread_mutex_unlock.  GNU Tar uses unlocked-io and so
+	should not need to worry about multithreading or locks.
+	* lib/mbtowc-lock.h (mbtowc_with_lock) [USE_UNLOCKED_IO]:
+	Don’t bother with locks, since this app is single-threaded.
+	There may be similar linking problems with lib/nl_langinfo.c and
+	lib/setlocale_null.c but my GNU Tar build didn’t run into them, so
+	I left them alone for now.
+
 2021-03-01  Paul Eggert  <eggert@cs.ucla.edu>
 
 	unlocked-io: do not redefine getc_unlocked etc.
diff --git a/lib/mbtowc-lock.h b/lib/mbtowc-lock.h
index 696b12c58..b7c5ba8a0 100644
--- a/lib/mbtowc-lock.h
+++ b/lib/mbtowc-lock.h
@@ -32,7 +32,15 @@ mbtowc_unlocked (wchar_t *pwc, const char *p, size_t m)
 /* Prohibit renaming this symbol.  */
 #undef gl_get_mbtowc_lock
 
-#if defined _WIN32 && !defined __CYGWIN__
+#ifdef USE_UNLOCKED_IO
+
+static int
+mbtowc_with_lock (wchar_t *pwc, const char *p, size_t m)
+{
+  return mbtowc_unlocked (pwc, p, m);
+}
+
+#elif defined _WIN32 && !defined __CYGWIN__
 
 extern __declspec(dllimport) CRITICAL_SECTION *gl_get_mbtowc_lock (void);
 
-- 
2.29.2



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* single-threaded optimizations
  2021-03-03  0:28 [PATCH] mbrtowc: port to AIX 7.1 with xlc 12.1 Paul Eggert
@ 2021-03-03  3:27 ` Bruno Haible
  2021-03-06 16:56   ` Paul Eggert
  0 siblings, 1 reply; 6+ messages in thread
From: Bruno Haible @ 2021-03-03  3:27 UTC (permalink / raw)
  To: bug-gnulib; +Cc: Paul Eggert

Hi Paul,

Paul Eggert wrote:
> +       * lib/mbtowc-lock.h (mbtowc_with_lock) [USE_UNLOCKED_IO]:
> +       Don’t bother with locks, since this app is single-threaded.

We now have two C macros which indicate a single-threaded application:

* USE_UNLOCKED_IO, used
    - for unlocked <stdio.h>
    - in regex
    - in mbrtowc
* GNULIB_WCHAR_SINGLE, used in wcwidth.

This gets weirder over time.

Should we have one macro for each of gnulib's facilities (stdio, regex,
multibyte/wchar)?

Or should we have one macro in general? In this case I would suggest
to choose a more generic name, instead of USE_UNLOCKED_IO.

Recall that a general macro won't cut it e.g. for coreutils. coreutils
has multithreaded programs ('sort') next to single-threaded programs.
But coreutils wants to optimize wcwidth. GNULIB_WCHAR_SINGLE actually
means "assume that the locale has been set before the program becomes
multithreaded, and won't change afterwards". Similarly,
'#include "unlocked-io.h"' does not mean that the program is single-
threaded; it means that no FILE object is being accessed in more than
one thread.

What do you think?

Bruno



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: single-threaded optimizations
  2021-03-03  3:27 ` single-threaded optimizations Bruno Haible
@ 2021-03-06 16:56   ` Paul Eggert
  2021-03-07  9:58     ` Bruno Haible
  0 siblings, 1 reply; 6+ messages in thread
From: Paul Eggert @ 2021-03-06 16:56 UTC (permalink / raw)
  To: Bruno Haible; +Cc: Gnulib bugs

On 3/2/21 7:27 PM, Bruno Haible wrote:

> a general macro won't cut it e.g. for coreutils. coreutils
> has multithreaded programs ('sort') next to single-threaded programs.
> But coreutils wants to optimize wcwidth. GNULIB_WCHAR_SINGLE actually
> means "assume that the locale has been set before the program becomes
> multithreaded, and won't change afterwards". Similarly,
> '#include "unlocked-io.h"' does not mean that the program is single-
> threaded; it means that no FILE object is being accessed in more than
> one thread.

Good point. How about this idea?

* We establish a new macro GNULIB_MBTOWC_SINGLE which means "assume that 
at most one thread invokes mbtowc-like functions". The mbtowc 
replacement uses this instead of using USE_UNLOCKED_IO. Tar can #define 
this new macro.

* If macros like GNLIB_MBTOWC_SINGLE proliferate, we can have a single 
macro GNULIB_SINGLE_THREADED that implies all the other macros. For now 
I'm not sure it's worth the bother to do this.

* If someone has the time, fix the underlying problem that the Gnulib 
mbrtowc replacement doesn't link under AIX in some circumstances, unless 
you #define GNULIB_MBTOWC_SINGLE. I'm not sure exactly what these 
circumstances are, and anyway if I were to delve into that, I think I 
might want to investigate the possibility of having the mbrtowc 
replacement use AIX mbrtowc instead of a lock around AIX mbtowc, as that 
should perform better anyway. But I'm not sure AIX is worth the time for 
this sort of thing.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: single-threaded optimizations
  2021-03-06 16:56   ` Paul Eggert
@ 2021-03-07  9:58     ` Bruno Haible
  2021-03-07 10:03       ` Bruno Haible
  2021-03-08  2:46       ` Paul Eggert
  0 siblings, 2 replies; 6+ messages in thread
From: Bruno Haible @ 2021-03-07  9:58 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib

Hi Paul,

> > a general macro won't cut it e.g. for coreutils. coreutils
> > has multithreaded programs ('sort') next to single-threaded programs.
> > But coreutils wants to optimize wcwidth. GNULIB_WCHAR_SINGLE actually
> > means "assume that the locale has been set before the program becomes
> > multithreaded, and won't change afterwards". Similarly,
> > '#include "unlocked-io.h"' does not mean that the program is single-
> > threaded; it means that no FILE object is being accessed in more than
> > one thread.
> 
> Good point. How about this idea?
> 
> * We establish a new macro GNULIB_MBTOWC_SINGLE which means "assume that 
> at most one thread invokes mbtowc-like functions". The mbtowc 
> replacement uses this instead of using USE_UNLOCKED_IO. Tar can #define 
> this new macro.

I like this idea. The packages can then define or not define each such
macro individually.

> * If macros like GNLIB_MBTOWC_SINGLE proliferate, we can have a single 
> macro GNULIB_SINGLE_THREADED that implies all the other macros. For now 
> I'm not sure it's worth the bother to do this.

I agree, it doesn't seem worth to have such a GNULIB_SINGLE_THREADED
macro because
  - more code becomes multithreaded over time,
  - the documentation clearly states what each of the individual macros
    imply.

> * If someone has the time, fix the underlying problem that the Gnulib 
> mbrtowc replacement doesn't link under AIX in some circumstances, unless 
> you #define GNULIB_MBTOWC_SINGLE.

The mbrtowc modules states:

  Link:
  $(LIB_MBRTOWC)

This link dependency (which expands to -lpthread on AIX) is needed because
we document that

  This function does not put the state into non-initial state when parsing an
  incomplete multibyte character on some platforms:
  AIX 7.2.

and
  - Since the state of mbrtowc is hidden, we cannot work around this without
    reimplementing mbrtowc from scratch.
  - Since the wide character representation on AIX is locale dependent and
    undocumented, we cannot roll our own mbrtowc implementation, but must use
    mbtowc().
  - mbtowc() uses global state and is therefore not multithread-safe.

> I think I 
> might want to investigate the possibility of having the mbrtowc 
> replacement use AIX mbrtowc instead of a lock around AIX mbtowc, as that 
> should perform better anyway. But I'm not sure AIX is worth the time for 
> this sort of thing.

I don't know what the solution could look like.

Bruno



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: single-threaded optimizations
  2021-03-07  9:58     ` Bruno Haible
@ 2021-03-07 10:03       ` Bruno Haible
  2021-03-08  2:46       ` Paul Eggert
  1 sibling, 0 replies; 6+ messages in thread
From: Bruno Haible @ 2021-03-07 10:03 UTC (permalink / raw)
  To: Paul Eggert; +Cc: bug-gnulib

[-- Attachment #1: Type: text/plain, Size: 3011 bytes --]

> > * We establish a new macro GNULIB_MBTOWC_SINGLE which means "assume that 
> > at most one thread invokes mbtowc-like functions". The mbtowc 
> > replacement uses this instead of using USE_UNLOCKED_IO. Tar can #define 
> > this new macro.
> 
> I like this idea. The packages can then define or not define each such
> macro individually.

Implemented through the following series of patches.


2021-03-07  Bruno Haible  <bruno@clisp.org>

	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  <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'.
	* lib/regex_internal.h: Test GNULIB_REGEX_SINGLE_THREAD instead of
	USE_UNLOCKED_IO.
	* doc/multithread.texi: Document GNULIB_REGEX_SINGLE_THREAD.

2021-03-06  Bruno Haible  <bruno@clisp.org>

	exclude: Allow stdio optimization independently of 'unlocked-io'.
	* lib/exclude.c: Test GNULIB_EXCLUDE_SINGLE_THREAD instead of
	USE_UNLOCKED_IO.
	* modules/exclude (Depends-on): Add unlocked-io-internal.
	* doc/multithread.texi: Document GNULIB_EXCLUDE_SINGLE_THREAD.

2021-03-06  Bruno Haible  <bruno@clisp.org>

	readutmp: Optimize stdio accesses.
	* lib/readutmp.c: Include unlocked-io.h unconditionally.
	* modules/readutmp (Depends-on): Add unlocked-io-internal.

2021-03-06  Bruno Haible  <bruno@clisp.org>

	mountlist: Optimize stdio accesses.
	* lib/mountlist.c: Include unlocked-io.h unconditionally.
	* modules/mountlist (Depends-on): Add unlocked-io-internal.

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.
	* modules/unlocked-io-internal: New file, based on modules/unlocked-io.
	* modules/unlocked-io (Description): Clarify.
	(Files, Depends-on): Just use the unlocked-io-internal module.
	(configure.ac): Define GNULIB_STDIO_SINGLE_THREAD and USE_UNLOCKED_IO
	here.
	* doc/multithread.texi: Clarify when the 'unlocked-io' module can be
	used.

2021-03-06  Bruno Haible  <bruno@clisp.org>

	posixtm: Remove unused includes.
	* lib/posixtm.c: Don't include <stdio.h>, <sys/types.h>, unlocked-io.h.


[-- Attachment #2: 0001-posixtm-Remove-unused-includes.patch --]
[-- Type: text/x-patch, Size: 1248 bytes --]

From 7ea7c3e27964aaf699ca737b11e2edea289f9ed2 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 7 Mar 2021 01:39:16 +0100
Subject: [PATCH 1/9] posixtm: Remove unused includes.

* lib/posixtm.c: Don't include <stdio.h>, <sys/types.h>, unlocked-io.h.
---
 ChangeLog     | 5 +++++
 lib/posixtm.c | 6 ------
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 5a100d7..cfa60e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 2021-03-06  Bruno Haible  <bruno@clisp.org>
 
+	posixtm: Remove unused includes.
+	* lib/posixtm.c: Don't include <stdio.h>, <sys/types.h>, unlocked-io.h.
+
+2021-03-06  Bruno Haible  <bruno@clisp.org>
+
 	dynarray: Add tests.
 	* tests/test-dynarray.c: New file.
 	* modules/dynarray-tests: New file.
diff --git a/lib/posixtm.c b/lib/posixtm.c
index dd89330..d142484 100644
--- a/lib/posixtm.c
+++ b/lib/posixtm.c
@@ -22,15 +22,9 @@
 
 #include "posixtm.h"
 
-#include <stdio.h>
 #include <stdlib.h>
-#include <sys/types.h>
 #include <string.h>
 
-#if USE_UNLOCKED_IO
-# include "unlocked-io.h"
-#endif
-
 /* ISDIGIT differs from isdigit, as follows:
    - Its arg may be any int or unsigned int; it need not be an unsigned char
      or EOF.
-- 
2.7.4


[-- Attachment #3: 0002-unlocked-io-internal-New-module.patch --]
[-- Type: text/x-patch, Size: 5560 bytes --]

From 212f0b69ab67a4d6230c2ab85e28c2f54b31060c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 7 Mar 2021 01:58:10 +0100
Subject: [PATCH 2/9] unlocked-io-internal: New module.

* m4/unlocked-io.m4 (gl_FUNC_GLIBC_UNLOCKED_IO): Don't define
USE_UNLOCKED_IO here.
* modules/unlocked-io-internal: New file, based on modules/unlocked-io.
* modules/unlocked-io (Description): Clarify.
(Files, Depends-on): Just use the unlocked-io-internal module.
(configure.ac): Define GNULIB_STDIO_SINGLE_THREAD and USE_UNLOCKED_IO
here.
* doc/multithread.texi: Clarify when the 'unlocked-io' module can be
used.
---
 ChangeLog                    | 13 +++++++++++++
 doc/multithread.texi         | 16 +++++++++++-----
 m4/unlocked-io.m4            |  7 +------
 modules/unlocked-io          | 19 ++++++++++++++-----
 modules/unlocked-io-internal | 24 ++++++++++++++++++++++++
 5 files changed, 63 insertions(+), 16 deletions(-)
 create mode 100644 modules/unlocked-io-internal

diff --git a/ChangeLog b/ChangeLog
index cfa60e0..80d97a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 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.
+	* modules/unlocked-io-internal: New file, based on modules/unlocked-io.
+	* modules/unlocked-io (Description): Clarify.
+	(Files, Depends-on): Just use the unlocked-io-internal module.
+	(configure.ac): Define GNULIB_STDIO_SINGLE_THREAD and USE_UNLOCKED_IO
+	here.
+	* doc/multithread.texi: Clarify when the 'unlocked-io' module can be
+	used.
+
+2021-03-06  Bruno Haible  <bruno@clisp.org>
+
 	posixtm: Remove unused includes.
 	* lib/posixtm.c: Don't include <stdio.h>, <sys/types.h>, unlocked-io.h.
 
diff --git a/doc/multithread.texi b/doc/multithread.texi
index 9b1bc2e..7fe19a7 100644
--- a/doc/multithread.texi
+++ b/doc/multithread.texi
@@ -258,11 +258,17 @@ if (mt) gl_lock_lock (some_lock);
 if (mt) gl_lock_unlock (some_lock);
 @end smallexample
 @item
-The @code{unlocked-io} module is applicable only if all the programs in your
-package are single-threaded.  It optimizes the operations on @code{FILE}
-streams.  You need extra code for this: include the @code{"unlocked-io.h"}
-header file.  Some Gnulib modules that do operations on @code{FILE} streams
-have these preparations already included.
+You may use the @code{unlocked-io} module if you want the @code{FILE} stream
+functions @code{getc}, @code{putc}, etc.@: to use unlocked I/O if available,
+throughout the package.  Unlocked I/O can improve performance, sometimes
+dramatically.  But unlocked I/O is safe only in single-threaded programs,
+as well as in multithreaded programs for which you can guarantee that
+every @code{FILE} stream, including @code{stdin}, @code{stdout}, @code{stderr},
+is used only in a single thread.
+
+You need extra code for this optimization to be effective: include the
+@code{"unlocked-io.h"} header file.  Some Gnulib modules that do operations
+on @code{FILE} streams have these preparations already included.
 @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
diff --git a/m4/unlocked-io.m4 b/m4/unlocked-io.m4
index a2dc8a1..b689020 100644
--- a/m4/unlocked-io.m4
+++ b/m4/unlocked-io.m4
@@ -1,4 +1,4 @@
-# unlocked-io.m4 serial 15
+# unlocked-io.m4 serial 16
 
 # Copyright (C) 1998-2006, 2009-2021 Free Software Foundation, Inc.
 #
@@ -16,11 +16,6 @@ dnl on Solaris 2.6).
 
 AC_DEFUN([gl_FUNC_GLIBC_UNLOCKED_IO],
 [
-  AC_DEFINE([USE_UNLOCKED_IO], [1],
-    [Define to 1 if you want getc etc. to use unlocked I/O if available.
-     Unlocked I/O can improve performance in unithreaded apps,
-     but it is not safe for multithreaded apps.])
-
   dnl Persuade glibc and Solaris <stdio.h> to declare
   dnl fgets_unlocked(), fputs_unlocked() etc.
   AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
diff --git a/modules/unlocked-io b/modules/unlocked-io
index 000fe32..2ed3417 100644
--- a/modules/unlocked-io
+++ b/modules/unlocked-io
@@ -1,15 +1,24 @@
 Description:
-Enable faster, non-thread-safe stdio functions if available.
+Enable faster, non-thread-safe stdio functions if available,
+globally throughout the package.
 
 Files:
-lib/unlocked-io.h
-m4/unlocked-io.m4
 
 Depends-on:
-extensions
+unlocked-io-internal
 
 configure.ac:
-gl_FUNC_GLIBC_UNLOCKED_IO
+AC_DEFINE([GNULIB_STDIO_SINGLE_THREAD], [1],
+  [Define to 1 if you want the FILE stream functions getc, putc, etc.
+   to use unlocked I/O if available, throughout the package.
+   Unlocked I/O can improve performance, sometimes dramatically.
+   But unlocked I/O is safe only in single-threaded programs,
+   as well as in multithreaded programs for which you can guarantee that
+   every FILE stream, including stdin, stdout, stderr, is used only
+   in a single thread.])
+
+AC_DEFINE([USE_UNLOCKED_IO], [GNULIB_STDIO_SINGLE_THREAD],
+  [An alias of GNULIB_STDIO_SINGLE_THREAD.])
 
 Makefile.am:
 
diff --git a/modules/unlocked-io-internal b/modules/unlocked-io-internal
new file mode 100644
index 0000000..b78944c
--- /dev/null
+++ b/modules/unlocked-io-internal
@@ -0,0 +1,24 @@
+Description:
+Allow use of faster, non-thread-safe stdio functions if available,
+in specific modules.
+
+Files:
+lib/unlocked-io.h
+m4/unlocked-io.m4
+
+Depends-on:
+extensions
+
+configure.ac:
+gl_FUNC_GLIBC_UNLOCKED_IO
+
+Makefile.am:
+
+Include:
+"unlocked-io.h"
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering
-- 
2.7.4


[-- Attachment #4: 0003-getusershell-Optimize-stdio-accesses-when-possible.patch --]
[-- Type: text/x-patch, Size: 2686 bytes --]

From 92052c44910568ef6012584a344edcb736949d2c Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
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  <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 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


[-- Attachment #5: 0004-mountlist-Optimize-stdio-accesses.patch --]
[-- Type: text/x-patch, Size: 1704 bytes --]

From 895c6f0664d19f754fe3905bae1bae83aee46bd0 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 7 Mar 2021 02:31:45 +0100
Subject: [PATCH 4/9] mountlist: Optimize stdio accesses.

* lib/mountlist.c: Include unlocked-io.h unconditionally.
* modules/mountlist (Depends-on): Add unlocked-io-internal.
---
 ChangeLog         | 6 ++++++
 lib/mountlist.c   | 5 ++---
 modules/mountlist | 1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d6e8d54..1159ee8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2021-03-06  Bruno Haible  <bruno@clisp.org>
 
+	mountlist: Optimize stdio accesses.
+	* lib/mountlist.c: Include unlocked-io.h unconditionally.
+	* modules/mountlist (Depends-on): Add unlocked-io-internal.
+
+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.
diff --git a/lib/mountlist.c b/lib/mountlist.c
index fae5b60..27989d2 100644
--- a/lib/mountlist.c
+++ b/lib/mountlist.c
@@ -149,9 +149,8 @@
 # define MNT_IGNORE(M) 0
 #endif
 
-#if USE_UNLOCKED_IO
-# include "unlocked-io.h"
-#endif
+/* Each of the FILE streams in this file is only used in a single thread.  */
+#include "unlocked-io.h"
 
 /* The results of opendir() in this file are not used with dirfd and fchdir,
    therefore save some unnecessary work in fchdir.c.  */
diff --git a/modules/mountlist b/modules/mountlist
index 7542048..8ec4793 100644
--- a/modules/mountlist
+++ b/modules/mountlist
@@ -11,6 +11,7 @@ Depends-on:
 fopen-gnu
 getline
 open
+unlocked-io-internal
 stdbool
 stdint
 strstr-simple
-- 
2.7.4


[-- Attachment #6: 0005-readutmp-Optimize-stdio-accesses.patch --]
[-- Type: text/x-patch, Size: 1626 bytes --]

From d26b0a2672f5adec9658ac606661b2f3b24c0336 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 7 Mar 2021 02:36:31 +0100
Subject: [PATCH 5/9] readutmp: Optimize stdio accesses.

* lib/readutmp.c: Include unlocked-io.h unconditionally.
* modules/readutmp (Depends-on): Add unlocked-io-internal.
---
 ChangeLog        | 6 ++++++
 lib/readutmp.c   | 5 ++---
 modules/readutmp | 1 +
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1159ee8..47f6807 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2021-03-06  Bruno Haible  <bruno@clisp.org>
 
+	readutmp: Optimize stdio accesses.
+	* lib/readutmp.c: Include unlocked-io.h unconditionally.
+	* modules/readutmp (Depends-on): Add unlocked-io-internal.
+
+2021-03-06  Bruno Haible  <bruno@clisp.org>
+
 	mountlist: Optimize stdio accesses.
 	* lib/mountlist.c: Include unlocked-io.h unconditionally.
 	* modules/mountlist (Depends-on): Add unlocked-io-internal.
diff --git a/lib/readutmp.c b/lib/readutmp.c
index 26ad815..73db856 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -34,9 +34,8 @@
 
 #include "xalloc.h"
 
-#if USE_UNLOCKED_IO
-# include "unlocked-io.h"
-#endif
+/* Each of the FILE streams in this file is only used in a single thread.  */
+#include "unlocked-io.h"
 
 #if 8 <= __GNUC__
 # pragma GCC diagnostic ignored "-Wsizeof-pointer-memaccess"
diff --git a/modules/readutmp b/modules/readutmp
index e88897c..18cdad1 100644
--- a/modules/readutmp
+++ b/modules/readutmp
@@ -12,6 +12,7 @@ xalloc
 stdbool
 stdint
 fopen-gnu
+unlocked-io-internal
 
 configure.ac:
 gl_READUTMP
-- 
2.7.4


[-- Attachment #7: 0006-exclude-Allow-stdio-optimization-independently-of-un.patch --]
[-- Type: text/x-patch, Size: 2403 bytes --]

From f4bf3936b988eb65361e04b0ca3898681b787c58 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 7 Mar 2021 02:42:24 +0100
Subject: [PATCH 6/9] exclude: Allow stdio optimization independently of
 'unlocked-io'.

* lib/exclude.c: Test GNULIB_EXCLUDE_SINGLE_THREAD instead of
USE_UNLOCKED_IO.
* modules/exclude (Depends-on): Add unlocked-io-internal.
* doc/multithread.texi: Document GNULIB_EXCLUDE_SINGLE_THREAD.
---
 ChangeLog            | 8 ++++++++
 doc/multithread.texi | 4 ++++
 lib/exclude.c        | 2 +-
 modules/exclude      | 1 +
 4 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 47f6807..d2ffff0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2021-03-06  Bruno Haible  <bruno@clisp.org>
 
+	exclude: Allow stdio optimization independently of 'unlocked-io'.
+	* lib/exclude.c: Test GNULIB_EXCLUDE_SINGLE_THREAD instead of
+	USE_UNLOCKED_IO.
+	* modules/exclude (Depends-on): Add unlocked-io-internal.
+	* doc/multithread.texi: Document GNULIB_EXCLUDE_SINGLE_THREAD.
+
+2021-03-06  Bruno Haible  <bruno@clisp.org>
+
 	readutmp: Optimize stdio accesses.
 	* lib/readutmp.c: Include unlocked-io.h unconditionally.
 	* modules/readutmp (Depends-on): Add unlocked-io-internal.
diff --git a/doc/multithread.texi b/doc/multithread.texi
index a63d3ee..082ccb0 100644
--- a/doc/multithread.texi
+++ b/doc/multithread.texi
@@ -278,4 +278,8 @@ been initialized.  This macro optimizes the functions @code{mbrtowc} and
 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.
+@item
+You may define the C macro @code{GNULIB_EXCLUDE_SINGLE_THREAD}, if all the
+programs in your package invoke the functions of the @code{exclude} module
+only from a single thread.
 @end itemize
diff --git a/lib/exclude.c b/lib/exclude.c
index a9c4e68..4ef4e08 100644
--- a/lib/exclude.c
+++ b/lib/exclude.c
@@ -42,7 +42,7 @@
 #include "verify.h"
 #include "filename.h"
 
-#if USE_UNLOCKED_IO
+#if GNULIB_EXCLUDE_SINGLE_THREAD
 # include "unlocked-io.h"
 #endif
 
diff --git a/modules/exclude b/modules/exclude
index 2529027..13871bd 100644
--- a/modules/exclude
+++ b/modules/exclude
@@ -14,6 +14,7 @@ mbscasecmp
 mbuiter
 regex
 stdbool
+unlocked-io-internal
 verify
 xalloc
 
-- 
2.7.4


[-- Attachment #8: 0007-regex-Allow-locking-optimization-independently-of-un.patch --]
[-- Type: text/x-patch, Size: 2905 bytes --]

From ede75ad3eeeafe72d1af9de84897905edf76bd70 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 7 Mar 2021 02:47:03 +0100
Subject: [PATCH 7/9] regex: Allow locking optimization independently of
 'unlocked-io'.

* lib/regex_internal.h: Test GNULIB_REGEX_SINGLE_THREAD instead of
USE_UNLOCKED_IO.
* doc/multithread.texi: Document GNULIB_REGEX_SINGLE_THREAD.
---
 ChangeLog            | 7 +++++++
 doc/multithread.texi | 4 ++++
 lib/regex_internal.h | 4 ++--
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index d2ffff0..f9bdb94 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2021-03-06  Bruno Haible  <bruno@clisp.org>
 
+	regex: Allow locking optimization independently of 'unlocked-io'.
+	* lib/regex_internal.h: Test GNULIB_REGEX_SINGLE_THREAD instead of
+	USE_UNLOCKED_IO.
+	* doc/multithread.texi: Document GNULIB_REGEX_SINGLE_THREAD.
+
+2021-03-06  Bruno Haible  <bruno@clisp.org>
+
 	exclude: Allow stdio optimization independently of 'unlocked-io'.
 	* lib/exclude.c: Test GNULIB_EXCLUDE_SINGLE_THREAD instead of
 	USE_UNLOCKED_IO.
diff --git a/doc/multithread.texi b/doc/multithread.texi
index 082ccb0..cb0c620 100644
--- a/doc/multithread.texi
+++ b/doc/multithread.texi
@@ -270,6 +270,10 @@ You need extra code for this optimization to be effective: include the
 @code{"unlocked-io.h"} header file.  Some Gnulib modules that do operations
 on @code{FILE} streams have these preparations already included.
 @item
+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_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
diff --git a/lib/regex_internal.h b/lib/regex_internal.h
index 4b0a3ef..1245e78 100644
--- a/lib/regex_internal.h
+++ b/lib/regex_internal.h
@@ -53,14 +53,14 @@
 # define lock_fini(lock) ((void) 0)
 # define lock_lock(lock) __libc_lock_lock (lock)
 # define lock_unlock(lock) __libc_lock_unlock (lock)
-#elif defined GNULIB_LOCK && !defined USE_UNLOCKED_IO
+#elif defined GNULIB_LOCK && !defined GNULIB_REGEX_SINGLE_THREAD
 # include "glthread/lock.h"
 # define lock_define(name) gl_lock_define (, name)
 # define lock_init(lock) glthread_lock_init (&(lock))
 # define lock_fini(lock) glthread_lock_destroy (&(lock))
 # define lock_lock(lock) glthread_lock_lock (&(lock))
 # define lock_unlock(lock) glthread_lock_unlock (&(lock))
-#elif defined GNULIB_PTHREAD && !defined USE_UNLOCKED_IO
+#elif defined GNULIB_PTHREAD && !defined GNULIB_REGEX_SINGLE_THREAD
 # include <pthread.h>
 # define lock_define(name) pthread_mutex_t name;
 # define lock_init(lock) pthread_mutex_init (&(lock), 0)
-- 
2.7.4


[-- Attachment #9: 0008-mbrtowc-Allow-locking-optimization-independently-of-.patch --]
[-- Type: text/x-patch, Size: 2486 bytes --]

From cd057fa80c74dcf1d0a74290cb5ad6cdc3136428 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Sun, 7 Mar 2021 02:57:46 +0100
Subject: [PATCH 8/9] 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.
---
 ChangeLog            | 7 +++++++
 doc/multithread.texi | 5 +++++
 lib/mbtowc-lock.h    | 4 +++-
 3 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index f9bdb94..80590b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 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'.
 	* lib/regex_internal.h: Test GNULIB_REGEX_SINGLE_THREAD instead of
 	USE_UNLOCKED_IO.
diff --git a/doc/multithread.texi b/doc/multithread.texi
index cb0c620..b28d1de 100644
--- a/doc/multithread.texi
+++ b/doc/multithread.texi
@@ -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
diff --git a/lib/mbtowc-lock.h b/lib/mbtowc-lock.h
index b7c5ba8..3b6f5f9 100644
--- a/lib/mbtowc-lock.h
+++ b/lib/mbtowc-lock.h
@@ -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)
-- 
2.7.4


[-- Attachment #10: 0009-Rename-GNULIB_WCHAR_SINGLE-to-GNULIB_WCHAR_SINGLE_LO.patch --]
[-- Type: text/x-patch, Size: 4848 bytes --]

From 2a200f4eb4754823c5674580bb0b68a88fd35077 Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
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  <bruno@clisp.org>
+
+	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  <bruno@clisp.org>
 
 	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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: single-threaded optimizations
  2021-03-07  9:58     ` Bruno Haible
  2021-03-07 10:03       ` Bruno Haible
@ 2021-03-08  2:46       ` Paul Eggert
  1 sibling, 0 replies; 6+ messages in thread
From: Paul Eggert @ 2021-03-08  2:46 UTC (permalink / raw)
  To: Bruno Haible; +Cc: Gnulib bugs

On 3/7/21 1:58 AM, Bruno Haible wrote:
> The mbrtowc modules states:
> 
>    Link:
>    $(LIB_MBRTOWC)

Thanks for explaining that. Over time Gnulib has evolved and 'tar' 
hadn't caught up with all those Link: lines. So I just now added 
$(LIB_ACL), $(LIB_GETRANDOM), $(LIB_HARD_LOCALE), $(LIB_HAS_ACL), 
$(LIB_MBRTOWC), and $(LIB_SETLOCALE_NULL) to the tar linking instructions.

However, I have a new problem now. Even though 'tar' now defines 
GNULIB_EXCLUDE_SINGLE_THREAD, GNULIB_MBRTOWC_SINGLE_THREAD, 
GNULIB_REGEX_SINGLE_THREAD, and GNULIB_WCHAR_SINGLE_LOCALE, 'configure' 
still unnecessarily arranges for GNU Tar to be linked with -lpthread, 
because of these lines in src/Makefile:

LIB_HARD_LOCALE = -lpthread
LIB_MBRTOWC = -lpthread
LIB_SETLOCALE_NULL = -lpthread

I can work around this unnecessary dynamic dependency for GNU Tar by 
removing $(LIB_HARD_LOCALE), $(LIB_MBRTOWC) and $(LIB_SETLOCALE_NULL) 
from the tar linking instructions. But this seems brittle, as these 
$(LIB_...) macros might expand to something other than a threading 
library in the future. Is there a better way?


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-03-08  2:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-03  0:28 [PATCH] mbrtowc: port to AIX 7.1 with xlc 12.1 Paul Eggert
2021-03-03  3:27 ` single-threaded optimizations Bruno Haible
2021-03-06 16:56   ` Paul Eggert
2021-03-07  9:58     ` Bruno Haible
2021-03-07 10:03       ` Bruno Haible
2021-03-08  2:46       ` Paul Eggert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).