aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2019-03-17 09:50:36 -0400
committerZack Weinberg <zackw@panix.com>2020-01-08 13:04:43 -0500
commit89cbc039a98f6bfc7e27c98a7e3799cf190c11f1 (patch)
tree9fe3176363b01537b7b119c7bd9fdbde552a25dc
parent5ad1fcd032064772025675690dea8e6335592c18 (diff)
downloadglibc-89cbc039a98f6bfc7e27c98a7e3799cf190c11f1.zip
glibc-89cbc039a98f6bfc7e27c98a7e3799cf190c11f1.tar.gz
glibc-89cbc039a98f6bfc7e27c98a7e3799cf190c11f1.tar.bz2
Swap sys/poll.h with poll.h.
Similarly to (sys/)syslog.h, poll.h is the header standardized by POSIX, but we had all of its contents in sys/, for historical reasons. This patch exchanges the contents of the two headers, and adds multiple-include guards to all of poll.h’s bits headers. * io/poll.h: Exchange contents with... * io/sys/poll.h: ...this file. Adjust guard macros. * include/poll.h: Exchange contents with... * include/sys/poll.h: ...this file. Adjust guard macros. * bits/poll.h, io/bits/poll2.h * sysdeps/unix/sysv/linux/bits/poll.h * sysdeps/unix/sysv/linux/m68k/bits/poll.h * sysdeps/unix/sysv/linux/mips/bits/poll.h * sysdeps/unix/sysv/linux/sparc/bits/poll.h: Allow inclusion by poll.h, not sys/poll.h. Add multiple- include guards where not already present. * scripts/check-obsolete-constructs.py (HEADER_ALLOWED_INCLUDES): Update.
-rw-r--r--bits/poll.h9
-rw-r--r--include/poll.h24
-rw-r--r--include/sys/poll.h21
-rw-r--r--io/bits/poll2.h9
-rw-r--r--io/poll.h77
-rw-r--r--io/sys/poll.h77
-rwxr-xr-xscripts/check-obsolete-constructs.py3
-rw-r--r--sysdeps/unix/sysv/linux/bits/poll.h9
-rw-r--r--sysdeps/unix/sysv/linux/m68k/bits/poll.h9
-rw-r--r--sysdeps/unix/sysv/linux/mips/bits/poll.h9
-rw-r--r--sysdeps/unix/sysv/linux/sparc/bits/poll.h9
11 files changed, 145 insertions, 111 deletions
diff --git a/bits/poll.h b/bits/poll.h
index 3fe34d7..177fa4e 100644
--- a/bits/poll.h
+++ b/bits/poll.h
@@ -15,8 +15,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#ifndef _SYS_POLL_H
-# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#ifndef _BITS_POLL_H
+#define _BITS_POLL_H 1
+
+#ifndef _POLL_H
+# error "Never use <bits/poll.h> directly; include <poll.h> instead."
#endif
/* Event types that can be polled for. These bits may be set in `events'
@@ -40,3 +43,5 @@
#define POLLERR 010 /* Error condition. */
#define POLLHUP 020 /* Hung up. */
#define POLLNVAL 040 /* Invalid polling request. */
+
+#endif /* bits/poll.h */
diff --git a/include/poll.h b/include/poll.h
index 7518192..f6a0630 100644
--- a/include/poll.h
+++ b/include/poll.h
@@ -1 +1,23 @@
-#include <include/sys/poll.h>
+#ifndef _POLL_H
+# include <io/poll.h>
+# ifndef _ISOMAC
+
+extern int __poll (struct pollfd *__fds, unsigned long int __nfds,
+ int __timeout);
+libc_hidden_proto (__poll)
+libc_hidden_proto (ppoll)
+
+# if __TIMESIZE == 64
+# define __ppoll64 __ppoll
+# else
+# include <time.h>
+# include <signal.h>
+
+extern int __ppoll64 (struct pollfd *fds, nfds_t nfds,
+ const struct __timespec64 *timeout,
+ const sigset_t *sigmask);
+libc_hidden_proto (__ppoll64)
+
+# endif
+# endif
+#endif
diff --git a/include/sys/poll.h b/include/sys/poll.h
index f904e21..5365742 100644
--- a/include/sys/poll.h
+++ b/include/sys/poll.h
@@ -1,22 +1,3 @@
-#ifndef _SYS_POLL_H
+#ifndef _POLL_H
# include <io/sys/poll.h>
-
-#ifndef _ISOMAC
-extern int __poll (struct pollfd *__fds, unsigned long int __nfds,
- int __timeout);
-libc_hidden_proto (__poll)
-libc_hidden_proto (ppoll)
-
-# if __TIMESIZE == 64
-# define __ppoll64 __ppoll
-# else
-# include <time.h>
-# include <signal.h>
-
-extern int __ppoll64 (struct pollfd *fds, nfds_t nfds,
- const struct __timespec64 *timeout,
- const sigset_t *sigmask);
-libc_hidden_proto (__ppoll64)
-# endif
-#endif
#endif
diff --git a/io/bits/poll2.h b/io/bits/poll2.h
index dca4971..12c23c4 100644
--- a/io/bits/poll2.h
+++ b/io/bits/poll2.h
@@ -16,8 +16,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#ifndef _SYS_POLL_H
-# error "Never include <bits/poll2.h> directly; use <sys/poll.h> instead."
+#ifndef _BITS_POLL2_H
+#define _BITS_POLL2_H 1
+
+#ifndef _POLL_H
+# error "Never include <bits/poll2.h> directly; use <poll.h> instead."
#endif
@@ -79,3 +82,5 @@ ppoll (struct pollfd *__fds, nfds_t __nfds, const struct timespec *__timeout,
#endif
__END_DECLS
+
+#endif /* bits/poll2.h */
diff --git a/io/poll.h b/io/poll.h
index 06fb41a..425f4f0 100644
--- a/io/poll.h
+++ b/io/poll.h
@@ -1 +1,76 @@
-#include <sys/poll.h>
+/* System V `poll' interface.
+ Copyright (C) 1994-2020 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
+ <https://www.gnu.org/licenses/>. */
+
+#ifndef _POLL_H
+#define _POLL_H 1
+
+#include <features.h>
+
+/* Get the platform dependent bits of `poll'. */
+#include <bits/poll.h>
+#ifdef __USE_GNU
+# include <bits/types/__sigset_t.h>
+# include <bits/types/struct_timespec.h>
+#endif
+
+
+/* Type used for the number of file descriptors. */
+typedef unsigned long int nfds_t;
+
+/* Data structure describing a polling request. */
+struct pollfd
+ {
+ int fd; /* File descriptor to poll. */
+ short int events; /* Types of events poller cares about. */
+ short int revents; /* Types of events that actually occurred. */
+ };
+
+
+__BEGIN_DECLS
+
+/* Poll the file descriptors described by the NFDS structures starting at
+ FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
+ an event to occur; if TIMEOUT is -1, block until an event occurs.
+ Returns the number of file descriptors with events, zero if timed out,
+ or -1 for errors.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
+
+#ifdef __USE_GNU
+/* Like poll, but before waiting the threads signal mask is replaced
+ with that specified in the fourth parameter. For better usability,
+ the timeout value is specified using a TIMESPEC object.
+
+ This function is a cancellation point and therefore not marked with
+ __THROW. */
+extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
+ const struct timespec *__timeout,
+ const __sigset_t *__ss);
+#endif
+
+__END_DECLS
+
+
+/* Define some inlines helping to catch common problems. */
+#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
+# include <bits/poll2.h>
+#endif
+
+#endif /* sys/poll.h */
diff --git a/io/sys/poll.h b/io/sys/poll.h
index 857be0f..43ee82d 100644
--- a/io/sys/poll.h
+++ b/io/sys/poll.h
@@ -1,76 +1,3 @@
-/* Compatibility definitions for System V `poll' interface.
- Copyright (C) 1994-2020 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
- <https://www.gnu.org/licenses/>. */
-
-#ifndef _SYS_POLL_H
-#define _SYS_POLL_H 1
-
-#include <features.h>
-
-/* Get the platform dependent bits of `poll'. */
-#include <bits/poll.h>
-#ifdef __USE_GNU
-# include <bits/types/__sigset_t.h>
-# include <bits/types/struct_timespec.h>
+#ifndef _POLL_H
+# include <poll.h>
#endif
-
-
-/* Type used for the number of file descriptors. */
-typedef unsigned long int nfds_t;
-
-/* Data structure describing a polling request. */
-struct pollfd
- {
- int fd; /* File descriptor to poll. */
- short int events; /* Types of events poller cares about. */
- short int revents; /* Types of events that actually occurred. */
- };
-
-
-__BEGIN_DECLS
-
-/* Poll the file descriptors described by the NFDS structures starting at
- FDS. If TIMEOUT is nonzero and not -1, allow TIMEOUT milliseconds for
- an event to occur; if TIMEOUT is -1, block until an event occurs.
- Returns the number of file descriptors with events, zero if timed out,
- or -1 for errors.
-
- This function is a cancellation point and therefore not marked with
- __THROW. */
-extern int poll (struct pollfd *__fds, nfds_t __nfds, int __timeout);
-
-#ifdef __USE_GNU
-/* Like poll, but before waiting the threads signal mask is replaced
- with that specified in the fourth parameter. For better usability,
- the timeout value is specified using a TIMESPEC object.
-
- This function is a cancellation point and therefore not marked with
- __THROW. */
-extern int ppoll (struct pollfd *__fds, nfds_t __nfds,
- const struct timespec *__timeout,
- const __sigset_t *__ss);
-#endif
-
-__END_DECLS
-
-
-/* Define some inlines helping to catch common problems. */
-#if __USE_FORTIFY_LEVEL > 0 && defined __fortify_function
-# include <bits/poll2.h>
-#endif
-
-#endif /* sys/poll.h */
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index 6f5d21c..1d9eec5 100755
--- a/scripts/check-obsolete-constructs.py
+++ b/scripts/check-obsolete-constructs.py
@@ -530,7 +530,6 @@ HEADER_ALLOWED_INCLUDES = {
"glob.h": [ "sys/cdefs.h" ],
"langinfo.h": [ "nl_types.h" ],
"mqueue.h": [ "fcntl.h", "sys/types.h" ],
- "poll.h": [ "sys/poll.h" ],
"pthread.h": [ "endian.h", "sched.h", "time.h",
"sys/cdefs.h" ],
"regex.h": [ "limits.h", "sys/types.h" ],
@@ -633,12 +632,12 @@ HEADER_ALLOWED_INCLUDES = {
# the included header did not exist or didn't provide all the
# necessary definitions.
"memory.h": [ "string.h" ],
- "poll.h": [ "sys/poll.h" ],
"re_comp.h": [ "regex.h" ],
"sys/bitypes.h": [ "sys/types.h" ],
"sys/dir.h": [ "dirent.h" ],
"sys/errno.h": [ "errno.h" ],
"sys/fcntl.h": [ "fcntl.h" ],
+ "sys/poll.h": [ "poll.h" ],
"sys/signal.h": [ "signal.h" ],
"sys/syslog.h": [ "syslog.h" ],
"sys/termios.h": [ "termios.h" ],
diff --git a/sysdeps/unix/sysv/linux/bits/poll.h b/sysdeps/unix/sysv/linux/bits/poll.h
index 40ca6eb..3cf2e56 100644
--- a/sysdeps/unix/sysv/linux/bits/poll.h
+++ b/sysdeps/unix/sysv/linux/bits/poll.h
@@ -15,8 +15,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#ifndef _SYS_POLL_H
-# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#ifndef _BITS_POLL_H
+#define _BITS_POLL_H 1
+
+#ifndef _POLL_H
+# error "Never use <bits/poll.h> directly; include <poll.h> instead."
#endif
/* Event types that can be polled for. These bits may be set in `events'
@@ -47,3 +50,5 @@
#define POLLERR 0x008 /* Error condition. */
#define POLLHUP 0x010 /* Hung up. */
#define POLLNVAL 0x020 /* Invalid polling request. */
+
+#endif /* bits/poll.h */
diff --git a/sysdeps/unix/sysv/linux/m68k/bits/poll.h b/sysdeps/unix/sysv/linux/m68k/bits/poll.h
index 8384efb..42873d1 100644
--- a/sysdeps/unix/sysv/linux/m68k/bits/poll.h
+++ b/sysdeps/unix/sysv/linux/m68k/bits/poll.h
@@ -15,8 +15,11 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
-#ifndef _SYS_POLL_H
-# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#ifndef _BITS_POLL_H
+#define _BITS_POLL_H 1
+
+#ifndef _POLL_H
+# error "Never use <bits/poll.h> directly; include <poll.h> instead."
#endif
/* Event types that can be polled for. These bits may be set in `events'
@@ -47,3 +50,5 @@
#define POLLERR 0x008 /* Error condition. */
#define POLLHUP 0x010 /* Hung up. */
#define POLLNVAL 0x020 /* Invalid polling request. */
+
+#endif /* bits/poll.h */
diff --git a/sysdeps/unix/sysv/linux/mips/bits/poll.h b/sysdeps/unix/sysv/linux/mips/bits/poll.h
index 8384efb..42873d1 100644
--- a/sysdeps/unix/sysv/linux/mips/bits/poll.h
+++ b/sysdeps/unix/sysv/linux/mips/bits/poll.h
@@ -15,8 +15,11 @@
License along with the GNU C Library. If not, see
<https://www.gnu.org/licenses/>. */
-#ifndef _SYS_POLL_H
-# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#ifndef _BITS_POLL_H
+#define _BITS_POLL_H 1
+
+#ifndef _POLL_H
+# error "Never use <bits/poll.h> directly; include <poll.h> instead."
#endif
/* Event types that can be polled for. These bits may be set in `events'
@@ -47,3 +50,5 @@
#define POLLERR 0x008 /* Error condition. */
#define POLLHUP 0x010 /* Hung up. */
#define POLLNVAL 0x020 /* Invalid polling request. */
+
+#endif /* bits/poll.h */
diff --git a/sysdeps/unix/sysv/linux/sparc/bits/poll.h b/sysdeps/unix/sysv/linux/sparc/bits/poll.h
index f83374d..6b10f07 100644
--- a/sysdeps/unix/sysv/linux/sparc/bits/poll.h
+++ b/sysdeps/unix/sysv/linux/sparc/bits/poll.h
@@ -15,8 +15,11 @@
License along with the GNU C Library; if not, see
<https://www.gnu.org/licenses/>. */
-#ifndef _SYS_POLL_H
-# error "Never use <bits/poll.h> directly; include <sys/poll.h> instead."
+#ifndef _BITS_POLL_H
+#define _BITS_POLL_H 1
+
+#ifndef _POLL_H
+# error "Never use <bits/poll.h> directly; include <poll.h> instead."
#endif
/* Event types that can be polled for. These bits may be set in `events'
@@ -47,3 +50,5 @@
#define POLLERR 0x008 /* Error condition. */
#define POLLHUP 0x010 /* Hung up. */
#define POLLNVAL 0x020 /* Invalid polling request. */
+
+#endif /* bits/poll.h */