From 29c46330518f4880930d77ee8ded6aa557e9023a Mon Sep 17 00:00:00 2001
From: KO Myung-Hun <komh@chollian.net>
Date: Tue, 18 Oct 2011 20:16:31 +0900
Subject: [PATCH 13/18] Enable vlc_poll() on OS/2

---
 configure.ac     |    2 +-
 src/Makefile.am  |    1 +
 src/win32/poll.c |   15 +++++++++------
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/configure.ac b/configure.ac
index ffc1dee..4687149 100644
--- a/configure.ac
+++ b/configure.ac
@@ -576,7 +576,7 @@ dnl Check for poll
 AC_SEARCH_LIBS(poll, [poll], [
   AC_DEFINE(HAVE_POLL, 1, [Define to 1 if the OS has poll().])
 ], [
-  AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"], [
+  AS_IF([test "${SYS}" != "mingw32" -a "${SYS}" != "mingwce" -a "${SYS}" != "os2"], [
     AC_MSG_ERROR([poll() is required.])
   ])
 ])
diff --git a/src/Makefile.am b/src/Makefile.am
index 0e617e2..b3bbf99 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -281,6 +281,7 @@ SOURCES_libvlc_os2 = \
 	misc/atomic.c \
 	posix/filesystem.c \
 	posix/plugin.c \
+	win32/poll.c \
 	os2/thread.c \
 	os2/specific.c \
 	$(NULL)
diff --git a/src/win32/poll.c b/src/win32/poll.c
index 4fa693f..4cdd85b 100644
--- a/src/win32/poll.c
+++ b/src/win32/poll.c
@@ -28,19 +28,20 @@
 
 #include <vlc_common.h>
 
+#ifndef __OS2__
 #ifdef FD_SETSIZE
 /* Too late for #undef FD_SETSIZE to work: fd_set is already defined. */
 # error Header inclusion order compromised!
 #endif
 #define FD_SETSIZE 0
-#include <vlc_network.h>
-
-#ifdef __OS2__
-#include <sys/time.h>
-#include <sys/select.h>
-#define SOCKET unsigned
+#else
+# include <sys/time.h>
+# include <sys/select.h>
+# define SOCKET unsigned
 #endif
 
+#include <vlc_network.h>
+
 int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
 {
     size_t setsize = sizeof (fd_set) + nfds * sizeof (SOCKET);
@@ -59,9 +60,11 @@ int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
         return -1;
     }
 
+#ifndef __OS2__
 /* Winsock FD_SET uses FD_SETSIZE in its expansion */
 #undef FD_SETSIZE
 #define FD_SETSIZE (nfds)
+#endif
 
 resume:
     val = -1;
-- 
1.7.3.2

