[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
proposed simplification for the 'poll' module
From: |
Paul Eggert |
Subject: |
proposed simplification for the 'poll' module |
Date: |
Fri, 19 Jan 2007 12:10:31 -0800 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Here's a proposed simplification to the 'poll' module
to have it use the new sys_time module rather than
rolling its own substitute.
2007-01-19 Paul Eggert <address@hidden>
* m4/poll.m4 (gl_PREREQ_POLL): Don't require AC_HEADER_TIME or
check for sys/time.h; no longer needed.
* modules/poll (Depends-on): Depend on sys_time.
* lib/poll.c: Include sys/time.h and time.h unconditionally,
since we now assume the sys_time module.
Index: m4/poll.m4
===================================================================
RCS file: /cvsroot/gnulib/gnulib/m4/poll.m4,v
retrieving revision 1.8
diff -u -p -r1.8 poll.m4
--- m4/poll.m4 28 Sep 2006 19:58:33 -0000 1.8
+++ m4/poll.m4 19 Jan 2007 20:08:30 -0000
@@ -1,5 +1,5 @@
-# poll.m4 serial 6
-dnl Copyright (c) 2003, 2005, 2006 Free Software Foundation, Inc.
+# poll.m4 serial 7
+dnl Copyright (c) 2003, 2005, 2006, 2007 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
dnl with or without modifications, as long as this notice is preserved.
@@ -67,6 +67,5 @@ This is MacOSX or AIX
# Prerequisites of lib/poll.c.
AC_DEFUN([gl_PREREQ_POLL],
[
- AC_REQUIRE([AC_HEADER_TIME])
- AC_CHECK_HEADERS_ONCE(sys/time.h sys/ioctl.h sys/filio.h)
+ AC_CHECK_HEADERS_ONCE(sys/ioctl.h sys/filio.h)
])
Index: modules/poll
===================================================================
RCS file: /cvsroot/gnulib/gnulib/modules/poll,v
retrieving revision 1.14
diff -u -p -r1.14 poll
--- modules/poll 16 Jan 2007 12:43:13 -0000 1.14
+++ modules/poll 19 Jan 2007 20:08:30 -0000
@@ -8,6 +8,7 @@ m4/poll.m4
Depends-on:
sys_select
+sys_time
configure.ac:
gl_FUNC_POLL
Index: lib/poll.c
===================================================================
RCS file: /cvsroot/gnulib/gnulib/lib/poll.c,v
retrieving revision 1.6
diff -u -p -r1.6 poll.c
--- lib/poll.c 3 Jan 2007 10:51:19 -0000 1.6
+++ lib/poll.c 19 Jan 2007 20:08:30 -0000
@@ -36,16 +36,8 @@
#include <sys/filio.h>
#endif
-#if TIME_WITH_SYS_TIME
-# include <sys/time.h>
-# include <time.h>
-#else
-# if HAVE_SYS_TIME_H
-# include <sys/time.h>
-# else
-# include <time.h>
-# endif
-#endif
+#include <sys/time.h>
+#include <time.h>
#ifndef INFTIM
#define INFTIM (-1)
@@ -157,7 +149,7 @@ poll (pfd, nfd, timeout)
if (FD_ISSET (pfd[i].fd, &rfds))
{
int r;
-
+
#if defined __MACH__ && defined __APPLE__
/* There is a bug in Mac OS X that causes it to ignore MSG_PEEK
for some kinds of descriptors. Detect if this descriptor is a
@@ -172,27 +164,27 @@ poll (pfd, nfd, timeout)
#endif
if (r == 0)
happened |= POLLHUP;
-
+
/* If the event happened on an unconnected server socket,
that's fine. */
else if (r > 0 || ( /* (r == -1) && */ errno == ENOTCONN))
happened |= (POLLIN | POLLRDNORM) & sought;
-
+
/* Distinguish hung-up sockets from other errors. */
else if (errno == ESHUTDOWN || errno == ECONNRESET
|| errno == ECONNABORTED || errno == ENETRESET)
happened |= POLLHUP;
-
+
else
happened |= POLLERR;
}
-
+
if (FD_ISSET (pfd[i].fd, &wfds))
happened |= (POLLOUT | POLLWRNORM | POLLWRBAND) & sought;
-
+
if (FD_ISSET (pfd[i].fd, &efds))
happened |= (POLLPRI | POLLRDBAND) & sought;
-
+
if (happened)
{
pfd[i].revents = happened;
- proposed simplification for the 'poll' module,
Paul Eggert <=