summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2019-03-09 23:05:37 -0500
committerZack Weinberg <zackw@panix.com>2019-03-09 23:05:37 -0500
commitdd868cc7b88789af76504a3dff9770c5b953e373 (patch)
treee213a43c715d83cbe002f150808da51b17ab1553
parent5bef1aa7abc2340c0edcb9d1553ae46c57ca2420 (diff)
downloadglibc-zack/more-obsolete-typedefs-2.tar.gz
Don’t include all of sys/select.h from sys/types.h.zack/more-obsolete-typedefs-2
-rw-r--r--NEWS6
-rw-r--r--bits/select.h7
-rw-r--r--include/bits/fd_set.h1
-rw-r--r--misc/Makefile13
-rw-r--r--misc/bits/fd_set.h78
-rw-r--r--misc/bits/select2.h7
-rw-r--r--misc/sys/select.h53
-rw-r--r--nptl/tst-cancel4.c1
-rw-r--r--posix/sys/types.h2
-rwxr-xr-xscripts/check-c++-types.sh1
-rw-r--r--socket/sys/socket.h4
-rw-r--r--sysdeps/x86/bits/select.h7
12 files changed, 119 insertions, 61 deletions
diff --git a/NEWS b/NEWS
index a4d34213b4..40d324a3e3 100644
--- a/NEWS
+++ b/NEWS
@@ -34,6 +34,12 @@ Deprecated and removed features, and other changes affecting compatibility:
named uint8_t, uint16_t, etc. from <stdint.h>. There is no standardized
replacement for register_t.
+* In the default conformance mode, <sys/types.h> no longer includes all of
+ <sys/select.h>; only the types fd_set and fd_mask, and the macros FD_SET,
+ FD_CLR, FD_ISSET, FD_ZERO, FD_SETSIZE, and NFDBITS, are made available.
+ (In strict conformance modes, <sys/types.h> has never included any of
+ <sys/select.h> and this is unchanged.).
+
Changes to build and runtime requirements:
* GCC 6.2 or later is required to build the GNU C Library.
diff --git a/bits/select.h b/bits/select.h
index 71b771f7c9..346d1d8b02 100644
--- a/bits/select.h
+++ b/bits/select.h
@@ -15,7 +15,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#ifndef _SYS_SELECT_H
+#ifndef _BITS_SELECT_H
+#define _BITS_SELECT_H 1
+
+#ifndef _BITS_FD_SET_H
# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
#endif
@@ -35,3 +38,5 @@
((void) (__FDS_BITS (s)[__FD_ELT(d)] &= ~__FD_MASK(d)))
#define __FD_ISSET(d, s) \
((__FDS_BITS (s)[__FD_ELT (d)] & __FD_MASK (d)) != 0)
+
+#endif /* bits/select.h */
diff --git a/include/bits/fd_set.h b/include/bits/fd_set.h
new file mode 100644
index 0000000000..053fbd176a
--- /dev/null
+++ b/include/bits/fd_set.h
@@ -0,0 +1 @@
+#include <misc/bits/fd_set.h>
diff --git a/misc/Makefile b/misc/Makefile
index e6c73896cd..ac27732fb0 100644
--- a/misc/Makefile
+++ b/misc/Makefile
@@ -28,12 +28,13 @@ headers := \
libgen.h limits.h mntent.h paths.h regexp.h search.h sgtty.h \
stab.h stdc-predef.h syscall.h sysexits.h syslog.h ttyent.h \
values.h \
- bits/err-ldbl.h bits/error-ldbl.h bits/error.h bits/hwcap.h \
- bits/ioctl-types.h bits/ioctls.h bits/libc-header-start.h \
- bits/mman.h bits/param.h bits/select.h bits/select2.h \
- bits/stab.def bits/syslog-ldbl.h bits/syslog-path.h \
- bits/syslog.h bits/sysmacros.h bits/types/struct_iovec.h \
- bits/uio-ext.h bits/uio_lim.h bits/xopen_lim.h \
+ bits/err-ldbl.h bits/error-ldbl.h bits/error.h bits/fd_set.h \
+ bits/hwcap.h bits/ioctl-types.h bits/ioctls.h \
+ bits/libc-header-start.h bits/mman.h bits/param.h \
+ bits/select.h bits/select2.h bits/stab.def bits/syslog-ldbl.h \
+ bits/syslog-path.h bits/syslog.h bits/sysmacros.h \
+ bits/types/struct_iovec.h bits/uio-ext.h bits/uio_lim.h \
+ bits/xopen_lim.h \
gnu/libc-version.h \
sys/auxv.h sys/cdefs.h sys/dir.h sys/file.h sys/ioctl.h \
sys/mman.h sys/param.h sys/ptrace.h sys/queue.h sys/reboot.h \
diff --git a/misc/bits/fd_set.h b/misc/bits/fd_set.h
new file mode 100644
index 0000000000..766ca10add
--- /dev/null
+++ b/misc/bits/fd_set.h
@@ -0,0 +1,78 @@
+/* `fd_set' type and related macros.
+ Copyright (C) 2019 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
+
+#ifndef _BITS_FD_SET_H
+#define _BITS_FD_SET_H 1
+
+#if !defined _SYS_SELECT_H && !defined _SYS_TYPES_H
+#error "Never include <bits/fd_set.h> directly; use <sys/select.h> instead."
+#endif
+
+/* Get definition of needed basic types. */
+#include <bits/types.h>
+
+/* Get __FD_* definitions. */
+#include <bits/select.h>
+
+/* The fd_set member is required to be an array of longs. */
+typedef long int __fd_mask;
+
+/* Some versions of <linux/posix_types.h> define this macros. */
+#undef __NFDBITS
+/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
+#define __NFDBITS (8 * (int) sizeof (__fd_mask))
+#define __FD_ELT(d) ((d) / __NFDBITS)
+#define __FD_MASK(d) ((__fd_mask) (1UL << ((d) % __NFDBITS)))
+
+/* When fortification is active, add bounds checking to __FD_ELT. */
+#if __USE_FORTIFY_LEVEL > 0 && defined __GNUC__
+# include <bits/select2.h>
+#endif
+
+/* fd_set for select and pselect. */
+typedef struct
+ {
+ /* XPG4.2 requires this member name. Otherwise avoid the name
+ from the global namespace. */
+#ifdef __USE_XOPEN
+ __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
+# define __FDS_BITS(set) ((set)->fds_bits)
+#else
+ __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
+# define __FDS_BITS(set) ((set)->__fds_bits)
+#endif
+ } fd_set;
+
+/* Maximum number of file descriptors in `fd_set'. */
+#define FD_SETSIZE __FD_SETSIZE
+
+#ifdef __USE_MISC
+/* Sometimes the fd_set member is assumed to have this type. */
+typedef __fd_mask fd_mask;
+
+/* Number of bits per word of `fd_set' (some code assumes this is 32). */
+# define NFDBITS __NFDBITS
+#endif
+
+/* Access macros for `fd_set'. */
+#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
+#define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
+#define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
+#define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
+
+#endif /* bits/fd_set.h */
diff --git a/misc/bits/select2.h b/misc/bits/select2.h
index dffdd054b2..1179133f59 100644
--- a/misc/bits/select2.h
+++ b/misc/bits/select2.h
@@ -16,7 +16,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#ifndef _SYS_SELECT_H
+#ifndef _BITS_SELECT2_H
+#define _BITS_SELECT2_H 1
+
+#ifndef _BITS_FD_SET_H
# error "Never include <bits/select2.h> directly; use <sys/select.h> instead."
#endif
@@ -33,3 +36,5 @@ extern long int __fdelt_warn (long int __d)
? (__d / __NFDBITS) \
: __fdelt_warn (__d)) \
: __fdelt_chk (__d)); })
+
+#endif
diff --git a/misc/sys/select.h b/misc/sys/select.h
index 84e2ae3a66..0e4ccd11e6 100644
--- a/misc/sys/select.h
+++ b/misc/sys/select.h
@@ -26,9 +26,6 @@
/* Get definition of needed basic types. */
#include <bits/types.h>
-/* Get __FD_* definitions. */
-#include <bits/select.h>
-
/* Get sigset_t. */
#include <bits/types/sigset_t.h>
@@ -40,48 +37,8 @@
#endif
#include <bits/types/suseconds_t.h>
-/* The fd_set member is required to be an array of longs. */
-typedef long int __fd_mask;
-
-/* Some versions of <linux/posix_types.h> define this macros. */
-#undef __NFDBITS
-/* It's easier to assume 8-bit bytes than to get CHAR_BIT. */
-#define __NFDBITS (8 * (int) sizeof (__fd_mask))
-#define __FD_ELT(d) ((d) / __NFDBITS)
-#define __FD_MASK(d) ((__fd_mask) (1UL << ((d) % __NFDBITS)))
-
-/* fd_set for select and pselect. */
-typedef struct
- {
- /* XPG4.2 requires this member name. Otherwise avoid the name
- from the global namespace. */
-#ifdef __USE_XOPEN
- __fd_mask fds_bits[__FD_SETSIZE / __NFDBITS];
-# define __FDS_BITS(set) ((set)->fds_bits)
-#else
- __fd_mask __fds_bits[__FD_SETSIZE / __NFDBITS];
-# define __FDS_BITS(set) ((set)->__fds_bits)
-#endif
- } fd_set;
-
-/* Maximum number of file descriptors in `fd_set'. */
-#define FD_SETSIZE __FD_SETSIZE
-
-#ifdef __USE_MISC
-/* Sometimes the fd_set member is assumed to have this type. */
-typedef __fd_mask fd_mask;
-
-/* Number of bits per word of `fd_set' (some code assumes this is 32). */
-# define NFDBITS __NFDBITS
-#endif
-
-
-/* Access macros for `fd_set'. */
-#define FD_SET(fd, fdsetp) __FD_SET (fd, fdsetp)
-#define FD_CLR(fd, fdsetp) __FD_CLR (fd, fdsetp)
-#define FD_ISSET(fd, fdsetp) __FD_ISSET (fd, fdsetp)
-#define FD_ZERO(fdsetp) __FD_ZERO (fdsetp)
-
+/* Get fd_set and its access macros. */
+#include <bits/fd_set.h>
__BEGIN_DECLS
@@ -112,12 +69,6 @@ extern int pselect (int __nfds, fd_set *__restrict __readfds,
const __sigset_t *__restrict __sigmask);
#endif
-
-/* Define some inlines helping to catch common problems. */
-#if __USE_FORTIFY_LEVEL > 0 && defined __GNUC__
-# include <bits/select2.h>
-#endif
-
__END_DECLS
#endif /* sys/select.h */
diff --git a/nptl/tst-cancel4.c b/nptl/tst-cancel4.c
index 60a965d23a..dce93dc03a 100644
--- a/nptl/tst-cancel4.c
+++ b/nptl/tst-cancel4.c
@@ -24,6 +24,7 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/select.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ipc.h>
diff --git a/posix/sys/types.h b/posix/sys/types.h
index 8f6d328692..72ac7ca1c9 100644
--- a/posix/sys/types.h
+++ b/posix/sys/types.h
@@ -97,7 +97,7 @@ __BEGIN_DECLS
# include <endian.h>
/* It also defines `fd_set' and the FD_* macros for `select'. */
-# include <sys/select.h>
+# include <bits/fd_set.h>
#endif /* Use misc. */
__END_DECLS
diff --git a/scripts/check-c++-types.sh b/scripts/check-c++-types.sh
index a8f3cfff7b..d0617e1a70 100755
--- a/scripts/check-c++-types.sh
+++ b/scripts/check-c++-types.sh
@@ -46,6 +46,7 @@ while read t; do
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/resource.h>
+#include <signal.h>
#include <unistd.h>
void foo ($t) { }
EOF
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index 6f242d088b..e9a0b03c24 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -36,6 +36,10 @@ __BEGIN_DECLS
# include <bits/types/struct_osockaddr.h>
#endif
+#ifdef __USE_GNU
+# include <bits/types/struct_timespec.h>
+#endif
+
/* The following constants should be used for the second parameter of
`shutdown'. */
enum
diff --git a/sysdeps/x86/bits/select.h b/sysdeps/x86/bits/select.h
index 1da802af06..f9ba48bd16 100644
--- a/sysdeps/x86/bits/select.h
+++ b/sysdeps/x86/bits/select.h
@@ -15,7 +15,10 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#ifndef _SYS_SELECT_H
+#ifndef _BITS_SELECT_H
+#define _BITS_SELECT_H 1
+
+#ifndef _BITS_FD_SET_H
# error "Never use <bits/select.h> directly; include <sys/select.h> instead."
#endif
@@ -61,3 +64,5 @@
((void) (__FDS_BITS (set)[__FD_ELT (d)] &= ~__FD_MASK (d)))
#define __FD_ISSET(d, set) \
((__FDS_BITS (set)[__FD_ELT (d)] & __FD_MASK (d)) != 0)
+
+#endif /* bits/select.h */