]> git.sesse.net Git - vlc/blobdiff - src/network/poll.c
Maemo: work-around segmentation fault when poll() unwinds
[vlc] / src / network / poll.c
index cf9554a30ab687c453425985cf52f6a025b24820..eb97c83db07749449b3dfac987ff927a6bf089fe 100644 (file)
 #include <vlc_network.h>
 
 
-#ifdef HAVE_POLL
+#if HAVE_MAEMO
+# include <signal.h>
+# include <errno.h>
+# include <poll.h>
+
+int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)
+{
+    struct timespec tsbuf, *ts;
+    sigset_t set;
+    int canc, ret;
+
+    if (timeout != -1)
+    {
+        div_t d = div (timeout, 1000);
+        tsbuf.tv_sec = d.quot;
+        tsbuf.tv_nsec = d.rem * 1000000;
+        ts = &tsbuf;
+    }
+    else
+        ts = NULL;
+
+    pthread_sigmask (SIG_BLOCK, NULL, &set);
+    sigdelset (&set, SIGRTMIN);
+
+    canc = vlc_savecancel ();
+    ret = ppoll (fds, nfds, ts, &set);
+    vlc_restorecancel (canc);
+
+    vlc_testcancel ();
+    return ret;
+}
+
+#elif defined (HAVE_POLL)
 struct pollfd;
 
 int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout)