bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

single-threaded optimizations


From: Bruno Haible
Subject: single-threaded optimizations
Date: Wed, 03 Mar 2021 04:27:56 +0100
User-agent: KMail/5.1.3 (Linux/4.4.0-203-generic; KDE/5.18.0; x86_64; ; )

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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]