]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Swap sys/poll.h with poll.h.
authorZack Weinberg <zackw@panix.com>
Sun, 17 Mar 2019 13:50:36 +0000 (09:50 -0400)
committerZack Weinberg <zackw@panix.com>
Wed, 8 Jan 2020 18:04:43 +0000 (13:04 -0500)
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
include/poll.h
include/sys/poll.h
io/bits/poll2.h
io/poll.h
io/sys/poll.h
scripts/check-obsolete-constructs.py
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

index 3fe34d7512aeabc9d192678d3e298dcfb2dac4e8..177fa4e7aa91f03145717ab7c4abbcd3c8aaf322 100644 (file)
    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 */
index 75181925aa7a59c51e64c1d0346cca1973fcca8d..f6a0630a188548a5045ba63efecde51eb9e7f977 100644 (file)
@@ -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
index f904e21f89ab8e35ef9090edb7d16417d87551bd..5365742a4bc9c98105b245f6993c2f08afd326b7 100644 (file)
@@ -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
index dca49717db6cbc36c034d92609b3c469cd59f0da..12c23c469e601229312ea4742d27de283b441b24 100644 (file)
    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 */
index 06fb41ab89c25edccf690de103ddee61143bf7f4..425f4f0c7c6eb94c570abcae8191a0a2cb90c9c9 100644 (file)
--- 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 */
index 857be0f5ac65a694bd62a4b52676a69b214b1789..43ee82dcbcfb9c4e402ff6b3a15aeab535394be2 100644 (file)
@@ -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 */
index 6f5d21c2bb12bbdebb0c97faed7371f3c124af24..1d9eec5d0ebec5993f8da314778039d6515748c8 100755 (executable)
@@ -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" ],
index 40ca6ebba750dc60cad27da46900341e4c2cee4e..3cf2e56ae9ae9a0c05d3a8acb6d2d770ddf93c76 100644 (file)
    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 */
index 8384efbbade44d95f33d9d8f94577e838e6c4f56..42873d11f77d28676d3be5550e7364c635893934 100644 (file)
    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 */
index 8384efbbade44d95f33d9d8f94577e838e6c4f56..42873d11f77d28676d3be5550e7364c635893934 100644 (file)
    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 */
index f83374dd2a606036d57cc12174e1ec0ff34bdc8f..6b10f07b025f1d6dee0c909edc03a5834659ecf9 100644 (file)
    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 */