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.

Reply via email to