aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-03-01 08:17:07 -0500
committerZack Weinberg <zackw@panix.com>2017-05-11 19:14:11 -0400
commit171199159214f2f548132a98988435f9a450d3ef (patch)
tree8d64c85952231bad3eb928b2c8dba653441aec3e /include
parent31073a53d8ff1e8bac53e34cb626dae5aa6ce69c (diff)
downloadglibc-171199159214f2f548132a98988435f9a450d3ef.tar
glibc-171199159214f2f548132a98988435f9a450d3ef.tar.gz
glibc-171199159214f2f548132a98988435f9a450d3ef.tar.bz2
glibc-171199159214f2f548132a98988435f9a450d3ef.zip
Remove _IO_MTSAFE_IO from public headers.
_IO_MTSAFE_IO controls whether stdio is *built* with support for multithreading. In the distant past it might also have worked as a feature selection macro, allowing library *users* to select thread-safe or lock-free stdio at application build time, I haven't done the archaeology. Nowadays, defining _IO_MTSAFE_IO while using the installed headers, or in _ISOMAC mode, will cause libio.h to throw syntax errors. This patch removes _IO_MTSAFE_IO from the public headers (specifically, from libio/libio.h). The most important thing it controlled in there was whether libio.h defines _IO_lock_t itself or expects stdio-lock.h to have done it, and we do still need a inter-header communication macro for that, because stdio-lock.h can only define _IO_lock_t as a typedef. I've invented _IO_lock_t_defined, which is defined by both versions of stdio-lock.h. _IO_MTSAFE_IO also controlled the definitions of a handful of macros that _might_ count as part of the public libio.h interface. They are now unconditionally given their non-_IO_MTSAFE_IO definition in libio/libio.h, and include/libio.h redefines them with the _IO_MTSAFE_IO definition. This should minimize the odds of breaking old software that actually uses those macros. I suspect that this entire mechanism is vestigial, and that glibc won't build anymore if you *don't* define _IO_MTSAFE_IO, but that's another patchset. The bulk of libio.h is internal-use-only stuff that no longer makes sense to expose (libstdc++ gave up on making a FILE the same object as a C++ filebuf *decades* ago) but that, too, is another patchset. * libio/libio.h: Condition dummy definition of _IO_lock_t on _IO_lock_t_defined, not _IO_MTSAFE_IO. Unconditionally use the non-_IO_MTSAFE_IO definitions for _IO_peekc, _IO_flockfile, _IO_funlockfile, and _IO_ftrylockfile. Only define _IO_cleanup_region_start and _IO_cleanup_region_end if not already defined. * include/libio.h: If _IO_MTSAFE_IO is defined, redefine _IO_peekc, _IO_flockfile, _IO_funlockfile, and _IO_ftrylockfile appropriately. * sysdeps/generic/stdio-lock.h, sysdeps/nptl/stdio-lock.h: Define _IO_lock_t_defined after defining _IO_lock_t.
Diffstat (limited to 'include')
-rw-r--r--include/libio.h25
1 files changed, 17 insertions, 8 deletions
diff --git a/include/libio.h b/include/libio.h
index 97fc5b548b..d2fa796758 100644
--- a/include/libio.h
+++ b/include/libio.h
@@ -21,16 +21,25 @@ libc_hidden_proto (_IO_sgetn)
libc_hidden_proto (_IO_vfprintf)
libc_hidden_proto (_IO_vfscanf)
-#if defined _IO_MTSAFE_IO && _IO_lock_inexpensive
+#ifdef _IO_MTSAFE_IO
+# undef _IO_peekc
# undef _IO_flockfile
-# define _IO_flockfile(_fp) \
- if (((_fp)->_flags & _IO_USER_LOCK) == 0) \
- _IO_lock_lock (*(_fp)->_lock)
# undef _IO_funlockfile
-# define _IO_funlockfile(_fp) \
- if (((_fp)->_flags & _IO_USER_LOCK) == 0) \
- _IO_lock_unlock (*(_fp)->_lock)
-#endif
+# undef _IO_ftrylockfile
+
+# define _IO_peekc(_fp) _IO_peekc_locked (_fp)
+# if _IO_lock_inexpensive
+# define _IO_flockfile(_fp) \
+ if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_lock (*(_fp)->_lock)
+# define _IO_funlockfile(_fp) \
+ if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_unlock (*(_fp)->_lock)
+# else
+# define _IO_flockfile(_fp) \
+ if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp)
+# define _IO_funlockfile(_fp) \
+ if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)
+# endif
+#endif /* _IO_MTSAFE_IO */
#endif
#endif