[11/25] Swap sys/poll.h with poll.h.
diff mbox series

Message ID 20190626175029.4699-2-zackw@panix.com
State New
Headers show
Series
  • Public header file hygiene improvements for 2.30
Related show

Commit Message

Zack Weinberg June 26, 2019, 5:50 p.m. UTC
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.
---
 bits/poll.h                               |  9 ++-
 include/poll.h                            | 12 +++-
 include/sys/poll.h                        | 10 +--
 io/bits/poll2.h                           |  9 ++-
 io/{sys => }/poll.h                       |  6 +-
 io/sys/poll.h                             | 79 +----------------------
 scripts/check-obsolete-constructs.py      |  3 +-
 sysdeps/unix/sysv/linux/bits/poll.h       |  9 ++-
 sysdeps/unix/sysv/linux/m68k/bits/poll.h  |  9 ++-
 sysdeps/unix/sysv/linux/mips/bits/poll.h  |  9 ++-
 sysdeps/unix/sysv/linux/sparc/bits/poll.h |  9 ++-
 11 files changed, 61 insertions(+), 103 deletions(-)
 copy io/{sys => }/poll.h (95%)
 rewrite io/sys/poll.h (99%)

Patch
diff mbox series

diff --git a/bits/poll.h b/bits/poll.h
index c0d8e82a88..a00ede717e 100644
--- a/bits/poll.h
+++ b/bits/poll.h
@@ -15,8 +15,11 @@ 
    License along with the GNU C Library; if not, see
    <http://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 75181925aa..c1d6bbbdee 100644
--- a/include/poll.h
+++ b/include/poll.h
@@ -1 +1,11 @@ 
-#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)
+#endif
+
+#endif
diff --git a/include/sys/poll.h b/include/sys/poll.h
index a42bc93873..5365742a4b 100644
--- a/include/sys/poll.h
+++ b/include/sys/poll.h
@@ -1,11 +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)
-#endif
-
 #endif
diff --git a/io/bits/poll2.h b/io/bits/poll2.h
index ff38ef7ae1..335953e21e 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
    <http://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/sys/poll.h b/io/poll.h
similarity index 95%
copy from io/sys/poll.h
copy to io/poll.h
index 6711a1518d..2e18206c75 100644
--- a/io/sys/poll.h
+++ b/io/poll.h
@@ -1,4 +1,4 @@ 
-/* Compatibility definitions for System V `poll' interface.
+/* System V `poll' interface.
    Copyright (C) 1994-2019 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
@@ -16,8 +16,8 @@ 
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#ifndef	_SYS_POLL_H
-#define	_SYS_POLL_H	1
+#ifndef	_POLL_H
+#define	_POLL_H	1
 
 #include <features.h>
 
diff --git a/io/sys/poll.h b/io/sys/poll.h
dissimilarity index 99%
index 6711a1518d..43ee82dcbc 100644
--- a/io/sys/poll.h
+++ b/io/sys/poll.h
@@ -?,? +1,3 @@
+#ifndef _POLL_H
+# include <poll.h>
+#endif
diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py
index c437c8e00b..08534348d7 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 50f0111fe5..6ea656a488 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
    <http://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 8833255c20..f3713d2ede 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
    <http://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 8833255c20..f3713d2ede 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
    <http://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 c2c0da927f..5070cf4a55 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
    <http://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 */