On 2021-12-18, John Scott <[email protected]> wrote:
> I don't use OpenBSD, but I've played with it and am interested in making
> my code portable to it. A trend which the GNU C Library recently got on
> board with is to use a thread-local storage buffer for strerror() which
> makes it safe to use across multiple threads. I was wondering if there
> is a particular reason OpenBSD has not taken this approach, perhaps just
> because it hasn't been raised, or if it doesn't support thread-local
> storage.

There isn't native support for TLS in OpenBSD. There is emulated support
on architectures using clang as the system compiler but there are also
a few architectures stilli using gcc (emutls was added in newer versions,
but the base OS sticks with an older GPLv2 version for those arches
still using gcc - newer versions are available in ports but obviously
that's no good for system libraries).

> From the strerror() code [1] it seems that, if OpenBSD supports a C11
> compiler, it should be as easy as adding the _Thread_local (or otherwise
> the GCC/Clang-specific __thread) keyword to the static buffer.

Perhaps it could be added for clang architectures easily enough, but
it's often better to reduce differences between arches where possible
to reduce the chance of code working on the more common archs but
failing (perhaps in a bad way) on others.


Reply via email to