feature_test_macros.7: Improve the text on _REENTRANT/_THREAD_SAFE deprecation

[mtk] I did a little code spelunking and found the following:

1. In glibc 1.09 (tagged 1995-03-02 in the git history),
   __USE_REENTRANT, _THREAD_SAFE, and _REENTRANT do not appear.

2. In glibc-1.93 (tagged 1996-08-29 in the git history),
   __USE_REENTRANT governs the exposure of some "_r()"
   functions from about a dozen header files.  However, it is
   defined in <features.h> via

        #if defined (__USE_GNU) || defined (__USE_MISC)
        #define __USE_REENTRANT 1
        #endif

   _REENTRANT and _THREAD_SAFE solely govern declarations in
   <stdio.h>, where they expose declarations of a few "unlocked"
   stdio functions and use #define to redirect a few stdio
   function names to "locked" versions.

3. THREAD_SAFE and _REENTRANT first appear in the git logs
   1996-05-09.

4. About 9 months later, glibc 2.0.1 arrives on 1997-02-04
   (timestamp and tarball taken from
   https://ftp.gnu.org/gnu/libc/, since there is no tag in the
   git history; casual inspection of the logs suggests the
   glibc 2.0 release was about a week earlier.

   By now we have the following in <features.h>:

        #if defined _REENTRANT || defined _THREAD_SAFE
        #define __USE_REENTRANT 1
        #endif

   And _THREAD_SAFE, and _REENTRANT do not appear appear in
   other headers. However, by now, __USE_REENTRANT governs only
   the declarations of tmpnam_r() and getlogin_r()

In other words, the window of time where _REENTRANT and
_THREAD_SAFE did anything much in glibc was quite short, IIUC.

Cowritten-by: Zack Weinberg <zackw@panix.com>
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2016-12-09 11:22:08 +01:00
parent 790980e004
commit f74991beed
1 changed files with 29 additions and 8 deletions

View File

@ -529,16 +529,37 @@ and
.BR _SVID_SOURCE .
.TP
.B _REENTRANT
Historically,
defining this macro exposed definitions of certain reentrant functions.
However, already for many years this macro has had few effects,
and since glibc 2.3, no effects that were not also achieved by defining
.BR _POSIX_C_SOURCE
with a value of 199606L or greater.
This macro is now deprecated; since glibc 2.25,
defining it has the same effect as defining
Historically, it was necessary to define this macro in all
multithreaded code.
(Some C libraries may still require this.)
In glibc,
this macro also exposed definitions of certain reentrant functions.
However, glibc has been thread-safe by default for many years;
since glibc 2.3, the only effect of defining
.BR _REENTRANT
has been to enable one or two of the same declarations that
are also enabled by defining
.BR _POSIX_C_SOURCE
with a value of 199606L or greater.
In glibc 2.25 and later,
.B _REENTRANT
is deprecated.
Defining it is equivalent to defining
.B _POSIX_C_SOURCE
with the value 199606L.
If a higher POSIX conformance level is
selected by any other means (such as
.B _POSIX_C_SOURCE
itself,
.BR _XOPEN_SOURCE ,
.BR _DEFAULT_SOURCE ,
or
.BR _GNU_SOURCE ),
then
.B _REENTRANT
has no effect.
.TP
.B _THREAD_SAFE
Synonym for the (deprecated)