Discussion:
_REENTRANT and _THREAD_SAFE
(too old to reply)
Bruno Haible
2017-02-27 22:34:52 UTC
Permalink
Raw Message
Hi all,

gnulib uses the _REENTRANT and _THREAD_SAFE macros in a couple of modules:
m4/threadlib.m4
m4/readutmp.m4

Does anyone know in detail what this glibc change [1] means in detail?

* The nonstandard feature selection macros _REENTRANT and _THREAD_SAFE
are now treated as compatibility synonyms for _POSIX_C_SOURCE=199506L.
Since the GNU C Library defaults to a much newer revision of POSIX,
this will only affect programs that specifically request an old
conformance mode. For instance, a program compiled with -std=c89
-D_REENTRANT will see a change in the visible declarations, but a
program compiled with just -D_REENTRANT, or -std=c99
-D_POSIX_C_SOURCE=200809L -D_REENTRANT, will not.

Some C libraries once required _REENTRANT and/or _THREAD_SAFE to be
defined by all multithreaded code, but glibc has not required this for
many years.

Does it mean that _REENTRANT and _THREAD_SAFE now prevent some symbols
from being declared?

My perspective is not "what has changed between glibc 2.24 and 2.25" but
"In glibc 2.25, what is the effect of defining _REENTRANT or _THREAD_SAFE?".

May it cause harm to add _REENTRANT or _THREAD_SAFE to the CPPFLAGS?

Bruno

[1] https://lists.gnu.org/archive/html/info-gnu/2017-02/msg00002.html
Joseph Myers
2017-02-27 22:41:57 UTC
Permalink
Raw Message
Post by Bruno Haible
Does it mean that _REENTRANT and _THREAD_SAFE now prevent some symbols
from being declared?
No.

The effect of those macros used to be: declare getlogin_r. Because
getlogin_r is part of POSIX.1 (199506) and the default POSIX version in
the glibc headers is 200809, this had no effect (getlogin_r was already
declared) unless you defined _POSIX_SOURCE, or defined _POSIX_C_SOURCE to
a value smaller than 199506, or defined another feature test macro for
another such old standard version without getlogin_r, or used -ansi /
-std=c89 / -std=c99 / -std=c11 without defining any feature test macro
implying a 199506 or later value for _POSIX_C_SOURCE.

Now, the effect is to declare all POSIX.1 (199506) symbols rather than
just getlogin_r. They still have no effect unless you define feature test
macros for an older standard, or select an ISO C conformance mode without
defining feature test macros for a newer standard. They still do not
cause any functions not to be declared.
--
Joseph S. Myers
***@codesourcery.com
Bruno Haible
2017-02-27 23:52:46 UTC
Permalink
Raw Message
Post by Joseph Myers
Now, the effect is to declare all POSIX.1 (199506) symbols rather than
just getlogin_r. They still have no effect unless you define feature test
macros for an older standard, or select an ISO C conformance mode without
defining feature test macros for a newer standard. They still do not
cause any functions not to be declared.
Thanks for the explanations, Joseph!

Regarding gnulib, I don't think any change is needed.

Bruno

Loading...