summaryrefslogtreecommitdiff
path: root/misc
diff options
context:
space:
mode:
Diffstat (limited to 'misc')
-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
4 files changed, 93 insertions, 58 deletions
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 */