From f71e6a52437d624d52b16d317e60bfb99aa5cbaa Mon Sep 17 00:00:00 2001 From: Mike Barcroft Date: Mon, 8 Jul 2002 16:37:35 +0000 Subject: [PATCH] Bring poll.h up to conformance with POSIX.1-2001 by adding some visibility conditionals, adding the nfds_t type, and changing the poll() prototype a little. Update the manual to match. --- lib/libc/sys/poll.2 | 5 ++--- sys/sys/poll.h | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/libc/sys/poll.2 b/lib/libc/sys/poll.2 index 04a91df4fe3a..df306e793449 100644 --- a/lib/libc/sys/poll.2 +++ b/lib/libc/sys/poll.2 @@ -28,7 +28,7 @@ .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.Dd September 7, 1996 +.Dd July 8, 2002 .Dt POLL 2 .Os .Sh NAME @@ -37,10 +37,9 @@ .Sh LIBRARY .Lb libc .Sh SYNOPSIS -.In sys/types.h .In poll.h .Ft int -.Fn poll "struct pollfd *fds" "unsigned int nfds" "int timeout" +.Fn poll "struct pollfd fds[]" "nfds_t nfds" "int timeout" .Sh DESCRIPTION .Fn Poll examines a set of file descriptors to see if some of them are ready for diff --git a/sys/sys/poll.h b/sys/sys/poll.h index 383cd0dcf0ad..89cadc624ba1 100644 --- a/sys/sys/poll.h +++ b/sys/sys/poll.h @@ -31,10 +31,14 @@ #ifndef _SYS_POLL_H_ #define _SYS_POLL_H_ +#include + /* * This file is intended to be compatible with the traditional poll.h. */ +typedef unsigned int nfds_t; + /* * This structure is passed as an array to poll(2). */ @@ -63,7 +67,9 @@ struct pollfd { #define POLLWRBAND 0x0100 /* OOB/Urgent data can be written */ /* General FreeBSD extension (currently only supported for sockets): */ +#if __BSD_VISIBLE #define POLLINIGNEOF 0x2000 /* like POLLIN, except ignore EOF */ +#endif /* * These events are set if they occur regardless of whether they were @@ -73,6 +79,8 @@ struct pollfd { #define POLLHUP 0x0010 /* file descriptor was "hung up" */ #define POLLNVAL 0x0020 /* requested events "invalid" */ +#if __BSD_VISIBLE + #define POLLSTANDARD (POLLIN|POLLPRI|POLLOUT|POLLRDNORM|POLLRDBAND|\ POLLWRBAND|POLLERR|POLLHUP|POLLNVAL) @@ -83,18 +91,12 @@ struct pollfd { */ #define INFTIM (-1) +#endif + #ifndef _KERNEL -#include - __BEGIN_DECLS -/* - * XXX logically, poll() should be declared in , but SVR4 at - * least has it here in . - * XXX poll() has "unsigned long" nfds on SVR4, not unsigned as on the - * other BSDs. - */ -int poll(struct pollfd *_pfd, unsigned int _nfds, int _timeout); +int poll(struct pollfd _pfd[], nfds_t _nfds, int _timeout); __END_DECLS #endif /* !_KERNEL */