From: Zack Weinberg Date: Sun, 17 Mar 2019 13:50:36 +0000 (-0400) Subject: Swap sys/poll.h with poll.h. X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89cbc039a98f6bfc7e27c98a7e3799cf190c11f1;p=thirdparty%2Fglibc.git 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. --- diff --git a/bits/poll.h b/bits/poll.h index 3fe34d7512a..177fa4e7aa9 100644 --- a/bits/poll.h +++ b/bits/poll.h @@ -15,8 +15,11 @@ License along with the GNU C Library; if not, see . */ -#ifndef _SYS_POLL_H -# error "Never use directly; include instead." +#ifndef _BITS_POLL_H +#define _BITS_POLL_H 1 + +#ifndef _POLL_H +# error "Never use directly; include 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 75181925aa7..f6a0630a188 100644 --- a/include/poll.h +++ b/include/poll.h @@ -1 +1,23 @@ -#include +#ifndef _POLL_H +# include +# 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 +# include + +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 f904e21f89a..5365742a4bc 100644 --- a/include/sys/poll.h +++ b/include/sys/poll.h @@ -1,22 +1,3 @@ -#ifndef _SYS_POLL_H +#ifndef _POLL_H # include - -#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 -# include - -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 dca49717db6..12c23c469e6 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 . */ -#ifndef _SYS_POLL_H -# error "Never include directly; use instead." +#ifndef _BITS_POLL2_H +#define _BITS_POLL2_H 1 + +#ifndef _POLL_H +# error "Never include directly; use 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 06fb41ab89c..425f4f0c7c6 100644 --- a/io/poll.h +++ b/io/poll.h @@ -1 +1,76 @@ -#include +/* 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 + . */ + +#ifndef _POLL_H +#define _POLL_H 1 + +#include + +/* Get the platform dependent bits of `poll'. */ +#include +#ifdef __USE_GNU +# include +# include +#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 +#endif + +#endif /* sys/poll.h */ diff --git a/io/sys/poll.h b/io/sys/poll.h index 857be0f5ac6..43ee82dcbcf 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 - . */ - -#ifndef _SYS_POLL_H -#define _SYS_POLL_H 1 - -#include - -/* Get the platform dependent bits of `poll'. */ -#include -#ifdef __USE_GNU -# include -# include +#ifndef _POLL_H +# include #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 -#endif - -#endif /* sys/poll.h */ diff --git a/scripts/check-obsolete-constructs.py b/scripts/check-obsolete-constructs.py index 6f5d21c2bb1..1d9eec5d0eb 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 40ca6ebba75..3cf2e56ae9a 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 . */ -#ifndef _SYS_POLL_H -# error "Never use directly; include instead." +#ifndef _BITS_POLL_H +#define _BITS_POLL_H 1 + +#ifndef _POLL_H +# error "Never use directly; include 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 8384efbbade..42873d11f77 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 . */ -#ifndef _SYS_POLL_H -# error "Never use directly; include instead." +#ifndef _BITS_POLL_H +#define _BITS_POLL_H 1 + +#ifndef _POLL_H +# error "Never use directly; include 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 8384efbbade..42873d11f77 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 . */ -#ifndef _SYS_POLL_H -# error "Never use directly; include instead." +#ifndef _BITS_POLL_H +#define _BITS_POLL_H 1 + +#ifndef _POLL_H +# error "Never use directly; include 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 f83374dd2a6..6b10f07b025 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 . */ -#ifndef _SYS_POLL_H -# error "Never use directly; include instead." +#ifndef _BITS_POLL_H +#define _BITS_POLL_H 1 + +#ifndef _POLL_H +# error "Never use directly; include 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 */