This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[glibc/zack/no-nested-includes] Swap sys/poll.h with poll.h.


https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7b9c6f47ba88c3e558d798fb64c5451b2719cdfd

commit 7b9c6f47ba88c3e558d798fb64c5451b2719cdfd
Author: Zack Weinberg <zackw@panix.com>
Date:   Sun Mar 17 09:50:36 2019 -0400

    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):
            Remove entry for poll.h; add entry for sys/poll.h.

Diff:
---
 bits/poll.h                               |  9 +++-
 include/poll.h                            | 12 ++++-
 include/sys/poll.h                        | 10 +---
 io/bits/poll2.h                           |  9 +++-
 io/poll.h                                 | 77 ++++++++++++++++++++++++++++++-
 io/sys/poll.h                             | 77 +------------------------------
 scripts/check-obsolete-constructs.py      |  2 +-
 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, 133 insertions(+), 99 deletions(-)

diff --git a/bits/poll.h b/bits/poll.h
index c0d8e82..a00ede7 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 7518192..c1d6bbb 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 a42bc93..5365742 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 ff38ef7..335953e 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/poll.h b/io/poll.h
index 06fb41a..2e18206 100644
--- a/io/poll.h
+++ b/io/poll.h
@@ -1 +1,76 @@
-#include <sys/poll.h>
+/* System V `poll' interface.
+   Copyright (C) 1994-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	_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 6711a15..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-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	_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 a7c4de4..a6ee700 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" ],
@@ -646,6 +645,7 @@ HEADER_ALLOWED_INCLUDES = {
     # Nonstandardized sys/ headers that do nothing but include a
     # top-level header with the same name.  These exist for
     # compatibility with old systems that only had the sys/ name.
+    "sys/poll.h":                  [ "poll.h" ],
     "sys/syslog.h":                [ "syslog.h" ],
 
     # Nonstandardized networking headers
diff --git a/sysdeps/unix/sysv/linux/bits/poll.h b/sysdeps/unix/sysv/linux/bits/poll.h
index 50f0111..6ea656a 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 8833255..f3713d2 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 8833255..f3713d2 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 c2c0da9..5070cf4 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 */


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]