[vlc-devel] [PATCH] vlc_poll: remove

Rafaël Carré funman at videolan.org
Sun Jan 22 10:52:48 CET 2012


---
 compat/poll.c         |   21 ++++++++++++++++++++-
 include/vlc_fixups.h  |    2 +-
 include/vlc_network.h |    4 ----
 src/os2/thread.c      |   16 ----------------
 src/win32/thread.c    |   16 ----------------
 5 files changed, 21 insertions(+), 38 deletions(-)

diff --git a/compat/poll.c b/compat/poll.c
index 0a27b71..1168983 100644
--- a/compat/poll.c
+++ b/compat/poll.c
@@ -37,7 +37,7 @@
 # include <sys/select.h>
 #endif
 
-int (poll) (struct pollfd *fds, unsigned nfds, int timeout)
+static int (real_poll) (struct pollfd *fds, unsigned nfds, int timeout)
 {
 #ifdef WIN32
     size_t setsize = sizeof (fd_set) + nfds * sizeof (SOCKET);
@@ -129,3 +129,22 @@ int (poll) (struct pollfd *fds, unsigned nfds, int timeout)
 #endif
     return val;
 }
+
+/* Cancelable poll */
+extern void vlc_testcancel(void);
+
+int (poll) (struct pollfd *fds, unsigned nfds, int timeout)
+{
+    vlc_testcancel ();
+
+    while (timeout > 50)
+    {
+        int val = real_poll (fds, nfds, timeout);
+        if (val != 0)
+            return val;
+        timeout -= 50;
+        vlc_testcancel ();
+    }
+
+    return real_poll (fds, nfds, timeout);
+}
diff --git a/include/vlc_fixups.h b/include/vlc_fixups.h
index b5884f4..9b83cf2 100644
--- a/include/vlc_fixups.h
+++ b/include/vlc_fixups.h
@@ -275,7 +275,7 @@ struct pollfd
 };
 #endif
 #ifndef HAVE_POLL
-# define poll(a, b, c) vlc_poll(a, b, c)
+int poll(struct pollfd *, unsigned, int);
 #endif
 
 #ifndef HAVE_IF_NAMEINDEX
diff --git a/include/vlc_network.h b/include/vlc_network.h
index c1769b1..431dfd5 100644
--- a/include/vlc_network.h
+++ b/include/vlc_network.h
@@ -160,10 +160,6 @@ VLC_API ssize_t net_Printf( vlc_object_t *p_this, int fd, const v_socket_t *, co
 VLC_API ssize_t net_vaPrintf( vlc_object_t *p_this, int fd, const v_socket_t *, const char *psz_fmt, va_list args );
 #define net_vaPrintf(a,b,c,d,e) net_vaPrintf(VLC_OBJECT(a),b,c,d,e)
 
-struct pollfd;
-VLC_API int vlc_poll(struct pollfd *fds, unsigned nfds, int timeout);
-
-
 #ifdef WIN32
 /* Microsoft: same semantic, same value, different name... go figure */
 # define SHUT_RD SD_RECEIVE
diff --git a/src/os2/thread.c b/src/os2/thread.c
index e92ef20..3f08658 100644
--- a/src/os2/thread.c
+++ b/src/os2/thread.c
@@ -805,22 +805,6 @@ void vlc_control_cancel (int cmd, ...)
     va_end (ap);
 }
 
-int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
-{
-    vlc_testcancel ();
-
-    while (timeout > 50)
-    {
-        int val = poll (fds, nfds, timeout);
-        if (val != 0)
-            return val;
-        timeout -= 50;
-        vlc_testcancel ();
-    }
-
-    return poll (fds, nfds, timeout);
-}
-
 #define Q2LL( q )   ( *( long long * )&( q ))
 
 /*** Clock ***/
diff --git a/src/win32/thread.c b/src/win32/thread.c
index 0cd833d..cd4c454 100644
--- a/src/win32/thread.c
+++ b/src/win32/thread.c
@@ -777,22 +777,6 @@ void vlc_control_cancel (int cmd, ...)
     va_end (ap);
 }
 
-int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
-{
-    vlc_testcancel ();
-
-    while (timeout > 50)
-    {
-        int val = poll (fds, nfds, timeout);
-        if (val != 0)
-            return val;
-        timeout -= 50;
-        vlc_testcancel ();
-    }
-
-    return poll (fds, nfds, timeout);
-}
-
 /*** Clock ***/
 mtime_t mdate (void)
 {
-- 
1.7.8.3



More information about the vlc-devel mailing list