This is the mail archive of the
glibc-cvs@sourceware.org
mailing list for the glibc project.
GNU C Library master sources branch zack/no-nested-includes created. glibc-2.29.9000-130-g7525297
- From: zack at sourceware dot org
- To: glibc-cvs at sourceware dot org
- Date: 11 Mar 2019 15:01:35 -0000
- Subject: GNU C Library master sources branch zack/no-nested-includes created. glibc-2.29.9000-130-g7525297
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".
The branch, zack/no-nested-includes has been created
at 752529782d3dce8fa5f9e8f87cbff44c2f31968c (commit)
- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=752529782d3dce8fa5f9e8f87cbff44c2f31968c
commit 752529782d3dce8fa5f9e8f87cbff44c2f31968c
Author: Zack Weinberg <zackw@panix.com>
Date: Sun Mar 10 21:10:08 2019 -0400
Donâ??t include sys/types.h from sys/socket.h.
Some, but not all, of our bits/socket.h variants include sys/types.h.
As far as I can tell, this is pure sloppiness and nobody expects it
to, so this patch eliminates that.
* socket/sys/socket.h: Include bits/types/socklen_t.h and
bits/types/ssize_t.h here.
* bits/socket.h: Donâ??t include stddef.h, bits/wordsize.h,
bits/types.h, or bits/types/socklen_t.h.
* sysdeps/mach/hurd/bits/socket.h: Donâ??t include stddef.h,
bits/wordsize.h, sys/types.h, or bits/types/socklen_t.h.
* sysdeps/unix/sysv/linux/bits/socket.h: Donâ??t include stddef.h,
sys/types.h, or socklen_t.h.
(struct ucred): Use __pid_t, __uid_t, and __gid_t.
diff --git a/NEWS b/NEWS
index 40d324a..6ddc76c 100644
--- a/NEWS
+++ b/NEWS
@@ -40,6 +40,9 @@ Deprecated and removed features, and other changes affecting compatibility:
(In strict conformance modes, <sys/types.h> has never included any of
<sys/select.h> and this is unchanged.).
+* On Linux and the Hurd, <sys/socket.h> no longer includes <sys/types.h>.
+ This was not an intentional feature.
+
Changes to build and runtime requirements:
* GCC 6.2 or later is required to build the GNU C Library.
diff --git a/bits/socket.h b/bits/socket.h
index 6687a47..abcc623 100644
--- a/bits/socket.h
+++ b/bits/socket.h
@@ -23,13 +23,6 @@
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
-#define __need_size_t
-#include <stddef.h>
-
-#include <bits/wordsize.h>
-#include <bits/types.h>
-#include <bits/types/socklen_t.h>
-
/* Types of sockets. */
enum __socket_type
{
diff --git a/socket/sys/socket.h b/socket/sys/socket.h
index e9a0b03..49fb098 100644
--- a/socket/sys/socket.h
+++ b/socket/sys/socket.h
@@ -23,6 +23,8 @@
__BEGIN_DECLS
+#include <bits/types/socklen_t.h>
+#include <bits/types/ssize_t.h>
#include <bits/types/struct_iovec.h>
#define __need_size_t
#include <stddef.h>
diff --git a/sysdeps/mach/hurd/bits/socket.h b/sysdeps/mach/hurd/bits/socket.h
index 429e66c..1169ed5 100644
--- a/sysdeps/mach/hurd/bits/socket.h
+++ b/sysdeps/mach/hurd/bits/socket.h
@@ -24,13 +24,6 @@
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
-#define __need_size_t
-#include <stddef.h>
-
-#include <bits/wordsize.h>
-#include <sys/types.h>
-#include <bits/types/socklen_t.h>
-
/* Types of sockets. */
enum __socket_type
{
diff --git a/sysdeps/unix/sysv/linux/bits/socket.h b/sysdeps/unix/sysv/linux/bits/socket.h
index cf3c03a..693c17d 100644
--- a/sysdeps/unix/sysv/linux/bits/socket.h
+++ b/sysdeps/unix/sysv/linux/bits/socket.h
@@ -23,12 +23,6 @@
# error "Never include <bits/socket.h> directly; use <sys/socket.h> instead."
#endif
-#define __need_size_t
-#include <stddef.h>
-
-#include <sys/types.h>
-#include <bits/types/socklen_t.h>
-
/* Get the architecture-dependent definition of enum __socket_type. */
#include <bits/socket_type.h>
@@ -338,9 +332,9 @@ enum
/* User visible structure for SCM_CREDENTIALS message */
struct ucred
{
- pid_t pid; /* PID of sending process. */
- uid_t uid; /* UID of sending process. */
- gid_t gid; /* GID of sending process. */
+ __pid_t pid; /* PID of sending process. */
+ __uid_t uid; /* UID of sending process. */
+ __gid_t gid; /* GID of sending process. */
};
#endif
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d7fb8f296a3b9544a01c473d5e1243031a0beb55
commit d7fb8f296a3b9544a01c473d5e1243031a0beb55
Author: Zack Weinberg <zackw@panix.com>
Date: Sat Mar 9 23:05:37 2019 -0500
Donâ??t include all of sys/select.h from sys/types.h.
For a long time sys/types.h has included sys/select.h under __USE_MISC,
with commentary saying that BSD systems conventionally expose fd_set
and the FD_* macros in sys/types.h. Including all of sys/select.h
means we also expose sigset_t, struct timeval, struct timespec, and
the prototypes for select and pselect here.
The current generation of BSDs are not consistent about how much of
sys/select.h is exposed from sys/types.h. FreeBSD has all of it,
NetBSD only fd_set and the FD_* macros, and OpenBSD none.
This patch aligns us with NetBSD, splitting the definition of fd_set
and associated macros to a new bits header (bits/fd_set.h) which both
sys/select.h (unconditionally) and sys/types.h (when __USE_MISC)
include. Specifically, the select-related public symbols exposed from
sys/types.h will now be fd_set, fd_mask, FD_SET, FD_CLR, FD_ISSET,
FD_ZERO, FD_SETSIZE, and NFDBITS.
Within our own code, there is very little fallout. nptl/tst-cancel4.c
and scripts/check-c++-types.h need to add includes of sys/select.h and
signal.h respectively. The public header socket/sys/socket.h
transitively includes sys/types.h on Linux (for no particularly good
reason, AFAICT), was therefore getting all of sys/select.h as well,
and this caused us not to notice that recvmmsg needs at least a
forward declaration of struct timespec. (Iâ??m having it give the full
declaration under __USE_GNU, but I could see an argument for just the
forward declaration, thoughts?)
* bits/select.h, sysdeps/x86/bits/select.h, misc/bits/select2.h:
Add multiple-inclusion guard. Expect inclusion by bits/fd_set.h,
not directly by sys/select.h.
* misc/bits/fd_set.h: New header split from misc/sys/select.h,
defines public symbols fd_set, fd_mask, FD_SET, FD_CLR, FD_ISSET,
FD_ZERO, FD_SETSIZE, and NFDBITS.
* include/bits/fd_set.h: New wrapper.
* misc/sys/select.h: Donâ??t include bits/select.h or bits/select2.h.
Include bits/fd_set.h rather than defining the above symbols.
* posix/sys/types.h: Include bits/fd_set.h, not sys/select.h.
* socket/sys/socket.h: When __USE_GNU, define struct timespec.
diff --git a/NEWS b/NEWS
index a4d3421..40d324a 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 71b771f..346d1d8 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 0000000..053fbd1
--- /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 e6c7389..ac27732 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 0000000..766ca10
--- /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 dffdd05..1179133 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 84e2ae3..0e4ccd1 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 60a965d..dce93dc 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 8f6d328..72ac7ca 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 a8f3cff..d0617e1 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 6f242d0..e9a0b03 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 1da802a..f9ba48b 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 */
-----------------------------------------------------------------------
hooks/post-receive
--
GNU C Library master sources