summaryrefslogtreecommitdiff
path: root/gnulib/lib/poll.c
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2012-02-07 13:57:19 +0100
committerGuido Günther <agx@sigxcpu.org>2012-02-07 13:57:19 +0100
commit8f97b0fdf31651c6fde7f5874fd17c8a8d35f6c2 (patch)
treef8011c3e893fb71a592ed38adbdc0c9070b4ccfa /gnulib/lib/poll.c
parentdd5f96f05630e72eea18b14dabf1b8bfd321eda6 (diff)
New upstream version 0.9.10~rc1
Diffstat (limited to 'gnulib/lib/poll.c')
-rw-r--r--gnulib/lib/poll.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/gnulib/lib/poll.c b/gnulib/lib/poll.c
index 69493af4f..f09d25858 100644
--- a/gnulib/lib/poll.c
+++ b/gnulib/lib/poll.c
@@ -1,9 +1,7 @@
-/* -*- buffer-read-only: t -*- vi: set ro: */
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
/* Emulation for poll(2)
Contributed by Paolo Bonzini.
- Copyright 2001-2003, 2006-2011 Free Software Foundation, Inc.
+ Copyright 2001-2003, 2006-2012 Free Software Foundation, Inc.
This file is part of gnulib.
@@ -39,7 +37,7 @@
#include <assert.h>
#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
-# define WIN32_NATIVE
+# define WINDOWS_NATIVE
# include <winsock2.h>
# include <windows.h>
# include <io.h>
@@ -71,9 +69,11 @@
# define MSG_PEEK 0
#endif
-#ifdef WIN32_NATIVE
+#ifdef WINDOWS_NATIVE
-#define IsConsoleHandle(h) (((long) (h) & 3) == 3)
+/* Optimized test whether a HANDLE refers to a console.
+ See <http://lists.gnu.org/archive/html/bug-gnulib/2009-08/msg00065.html>. */
+#define IsConsoleHandle(h) (((intptr_t) (h) & 3) == 3)
static BOOL
IsSocketHandle (HANDLE h)
@@ -128,7 +128,7 @@ typedef DWORD (WINAPI *PNtQueryInformationFile)
for the handle, eliminate them from *P_SOUGHT. */
static int
-win32_compute_revents (HANDLE h, int *p_sought)
+windows_compute_revents (HANDLE h, int *p_sought)
{
int i, ret, happened;
INPUT_RECORD *irbuffer;
@@ -163,11 +163,12 @@ win32_compute_revents (HANDLE h, int *p_sought)
{
/* It was the write-end of the pipe. Check if it is writable.
If NtQueryInformationFile fails, optimistically assume the pipe is
- writable. This could happen on Win9x, where NtQueryInformationFile
- is not available, or if we inherit a pipe that doesn't permit
- FILE_READ_ATTRIBUTES access on the write end (I think this should
- not happen since WinXP SP2; WINE seems fine too). Otherwise,
- ensure that enough space is available for atomic writes. */
+ writable. This could happen on Windows 9x, where
+ NtQueryInformationFile is not available, or if we inherit a pipe
+ that doesn't permit FILE_READ_ATTRIBUTES access on the write end
+ (I think this should not happen since Windows XP SP2; WINE seems
+ fine too). Otherwise, ensure that enough space is available for
+ atomic writes. */
memset (&iosb, 0, sizeof (iosb));
memset (&fpli, 0, sizeof (fpli));
@@ -226,7 +227,7 @@ win32_compute_revents (HANDLE h, int *p_sought)
/* Convert fd_sets returned by select into revents values. */
static int
-win32_compute_revents_socket (SOCKET h, int sought, long lNetworkEvents)
+windows_compute_revents_socket (SOCKET h, int sought, long lNetworkEvents)
{
int happened = 0;
@@ -320,7 +321,7 @@ compute_revents (int fd, int sought, fd_set *rfds, fd_set *wfds, fd_set *efds)
int
poll (struct pollfd *pfd, nfds_t nfd, int timeout)
{
-#ifndef WIN32_NATIVE
+#ifndef WINDOWS_NATIVE
fd_set rfds, wfds, efds;
struct timeval tv;
struct timeval *ptv;
@@ -503,9 +504,9 @@ restart:
{
/* Poll now. If we get an event, do not poll again. Also,
screen buffer handles are waitable, and they'll block until
- a character is available. win32_compute_revents eliminates
+ a character is available. windows_compute_revents eliminates
bits for the "wrong" direction. */
- pfd[i].revents = win32_compute_revents (h, &sought);
+ pfd[i].revents = windows_compute_revents (h, &sought);
if (sought)
handle_array[nhandles++] = h;
if (pfd[i].revents)
@@ -581,14 +582,14 @@ restart:
if (FD_ISSET ((SOCKET) h, &xfds))
ev.lNetworkEvents |= FD_OOB;
- happened = win32_compute_revents_socket ((SOCKET) h, pfd[i].events,
- ev.lNetworkEvents);
+ happened = windows_compute_revents_socket ((SOCKET) h, pfd[i].events,
+ ev.lNetworkEvents);
}
else
{
/* Not a socket. */
int sought = pfd[i].events;
- happened = win32_compute_revents (h, &sought);
+ happened = windows_compute_revents (h, &sought);
nhandles++;
}