diff --git a/include/vlc_poll.h b/include/vlc_poll.h new file mode 100644 index 0000000000..7994ff1dcb --- /dev/null +++ b/include/vlc_poll.h @@ -0,0 +1,99 @@ +/***************************************************************************** + * vlc_poll.h : poll implementation for the VideoLAN client + ***************************************************************************** + * Copyright (C) 1999, 2002 VLC authors and VideoLAN + * Copyright © 2007-2016 Rémi Denis-Courmont + * + * Authors: Jean-Marc Dressler + * Samuel Hocevar + * Gildas Bazin + * Christophe Massiot + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation; either version 2.1 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#ifndef VLC_POLL_H_ +#define VLC_POLL_H_ + +#include + +/** + * \ingroup os + * \defgroup thread Poll implementations + * @{ + * \file + * Poll implementations + */ + +#if defined (_WIN32) +static inline int vlc_poll(struct pollfd *fds, unsigned nfds, int timeout) +{ + int val; + + vlc_testcancel(); + val = poll(fds, nfds, timeout); + if (val < 0) + vlc_testcancel(); + return val; +} +# define poll(u,n,t) vlc_poll(u, n, t) + +#elif defined (__OS2__) +static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) +{ + static int (*vlc_poll_os2)(struct pollfd *, unsigned, int) = NULL; + + if (!vlc_poll_os2) + { + HMODULE hmod; + CHAR szFailed[CCHMAXPATH]; + + if (DosLoadModule(szFailed, sizeof(szFailed), "vlccore", &hmod)) + return -1; + + if (DosQueryProcAddr(hmod, 0, "_vlc_poll_os2", (PFN *)&vlc_poll_os2)) + return -1; + } + + return (*vlc_poll_os2)(fds, nfds, timeout); +} +# define poll(u,n,t) vlc_poll(u, n, t) + +#elif defined (__ANDROID__) /* pthreads subset without pthread_cancel() */ +static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) +{ + int val; + + do + { + int ugly_timeout = ((unsigned)timeout >= 50) ? 50 : timeout; + if (timeout >= 0) + timeout -= ugly_timeout; + + vlc_testcancel (); + val = poll (fds, nfds, ugly_timeout); + } + while (val == 0 && timeout != 0); + + return val; +} + +# define poll(u,n,t) vlc_poll(u, n, t) + +#else /* POSIX threads */ + +#endif + +#endif /* !VLC_POLL_H_ */ diff --git a/include/vlc_threads.h b/include/vlc_threads.h index df83468f53..1c02ccac3e 100644 --- a/include/vlc_threads.h +++ b/include/vlc_threads.h @@ -64,18 +64,6 @@ typedef struct vlc_thread *vlc_thread_t; typedef struct vlc_threadvar *vlc_threadvar_t; typedef struct vlc_timer *vlc_timer_t; -static inline int vlc_poll(struct pollfd *fds, unsigned nfds, int timeout) -{ - int val; - - vlc_testcancel(); - val = poll(fds, nfds, timeout); - if (val < 0) - vlc_testcancel(); - return val; -} -# define poll(u,n,t) vlc_poll(u, n, t) - #elif defined (__OS2__) # include @@ -87,26 +75,6 @@ typedef struct vlc_timer *vlc_timer_t; # define pthread_sigmask sigprocmask -static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) -{ - static int (*vlc_poll_os2)(struct pollfd *, unsigned, int) = NULL; - - if (!vlc_poll_os2) - { - HMODULE hmod; - CHAR szFailed[CCHMAXPATH]; - - if (DosLoadModule(szFailed, sizeof(szFailed), "vlccore", &hmod)) - return -1; - - if (DosQueryProcAddr(hmod, 0, "_vlc_poll_os2", (PFN *)&vlc_poll_os2)) - return -1; - } - - return (*vlc_poll_os2)(fds, nfds, timeout); -} -# define poll(u,n,t) vlc_poll(u, n, t) - #elif defined (__ANDROID__) /* pthreads subset without pthread_cancel() */ # include # include @@ -118,26 +86,6 @@ typedef struct vlc_thread *vlc_thread_t; typedef pthread_key_t vlc_threadvar_t; typedef struct vlc_timer *vlc_timer_t; -static inline int vlc_poll (struct pollfd *fds, unsigned nfds, int timeout) -{ - int val; - - do - { - int ugly_timeout = ((unsigned)timeout >= 50) ? 50 : timeout; - if (timeout >= 0) - timeout -= ugly_timeout; - - vlc_testcancel (); - val = poll (fds, nfds, ugly_timeout); - } - while (val == 0 && timeout != 0); - - return val; -} - -# define poll(u,n,t) vlc_poll(u, n, t) - #else /* POSIX threads */ # include /* _POSIX_SPIN_LOCKS */ # include diff --git a/modules/access/dtv/en50221.c b/modules/access/dtv/en50221.c index 8050321561..4c7e94f17f 100644 --- a/modules/access/dtv/en50221.c +++ b/modules/access/dtv/en50221.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/modules/access/dv.c b/modules/access/dv.c index 0eb37fbc1a..555946de78 100644 --- a/modules/access/dv.c +++ b/modules/access/dv.c @@ -31,6 +31,7 @@ #include #include +#include #include #include diff --git a/modules/access/http/h2conn.c b/modules/access/http/h2conn.c index 85a3f2e5b7..561f7ae2a3 100644 --- a/modules/access/http/h2conn.c +++ b/modules/access/http/h2conn.c @@ -34,6 +34,7 @@ #endif #include #include +#include #include #include #include diff --git a/modules/access/http/h2output.c b/modules/access/http/h2output.c index d0aae4bc43..0b648f3bb8 100644 --- a/modules/access/http/h2output.c +++ b/modules/access/http/h2output.c @@ -33,6 +33,7 @@ #endif #include #include +#include #include #include "h2frame.h" #include "h2output.h" diff --git a/modules/access/linsys/linsys_hdsdi.c b/modules/access/linsys/linsys_hdsdi.c index 8c82448076..e3107e1e3d 100644 --- a/modules/access/linsys/linsys_hdsdi.c +++ b/modules/access/linsys/linsys_hdsdi.c @@ -42,6 +42,7 @@ #include #include #include +#include #include diff --git a/modules/access/linsys/linsys_sdi.c b/modules/access/linsys/linsys_sdi.c index c4307c9bbc..cdff943bd0 100644 --- a/modules/access/linsys/linsys_sdi.c +++ b/modules/access/linsys/linsys_sdi.c @@ -41,6 +41,7 @@ #include #include #include +#include #include diff --git a/modules/access/oss.c b/modules/access/oss.c index 7081747aa8..ad93127416 100644 --- a/modules/access/oss.c +++ b/modules/access/oss.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include diff --git a/modules/access/rdp.c b/modules/access/rdp.c index 692053958d..a2303174e7 100644 --- a/modules/access/rdp.c +++ b/modules/access/rdp.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include diff --git a/modules/access/rtp/datagram.c b/modules/access/rtp/datagram.c index 0ea99e4b3e..ce49f97bb1 100644 --- a/modules/access/rtp/datagram.c +++ b/modules/access/rtp/datagram.c @@ -30,6 +30,7 @@ #include #include +#include #include "vlc_dtls.h" #ifndef MSG_TRUNC diff --git a/modules/access/satip.c b/modules/access/satip.c index 0354716298..ce98cf21a9 100644 --- a/modules/access/satip.c +++ b/modules/access/satip.c @@ -33,6 +33,7 @@ #include #include +#include #include #include #include diff --git a/modules/control/globalhotkeys/xcb.c b/modules/control/globalhotkeys/xcb.c index 8c858f94f6..5c09092b18 100644 --- a/modules/control/globalhotkeys/xcb.c +++ b/modules/control/globalhotkeys/xcb.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include diff --git a/modules/control/lirc.c b/modules/control/lirc.c index 72e67d70e7..b6d8716077 100644 --- a/modules/control/lirc.c +++ b/modules/control/lirc.c @@ -37,6 +37,7 @@ #include #include #include +#include #ifdef HAVE_POLL_H # include diff --git a/modules/control/netsync.c b/modules/control/netsync.c index 67365cd636..a79e4e93b9 100644 --- a/modules/control/netsync.c +++ b/modules/control/netsync.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include diff --git a/modules/services_discovery/udisks.c b/modules/services_discovery/udisks.c index a7d78a20a6..99f2b08ccb 100644 --- a/modules/services_discovery/udisks.c +++ b/modules/services_discovery/udisks.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include diff --git a/modules/video_output/xcb/window.c b/modules/video_output/xcb/window.c index 45a1e98ddc..eadb954d99 100644 --- a/modules/video_output/xcb/window.c +++ b/modules/video_output/xcb/window.c @@ -47,6 +47,7 @@ typedef xcb_atom_t Atom; #include #include +#include #include #include #include diff --git a/src/Makefile.am b/src/Makefile.am index 188dfcd7dd..525628515a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -90,6 +90,7 @@ pluginsinclude_HEADERS = \ ../include/vlc_playlist.h \ ../include/vlc_playlist_export.h \ ../include/vlc_plugin.h \ + ../include/vlc_poll.h \ ../include/vlc_probe.h \ ../include/vlc_preparser.h \ ../include/vlc_queue.h \ diff --git a/src/misc/interrupt.c b/src/misc/interrupt.c index 2e676ad383..864624e18c 100644 --- a/src/misc/interrupt.c +++ b/src/misc/interrupt.c @@ -42,6 +42,7 @@ #include #include +#include #include /* vlc_pipe */ #include /* vlc_accept */ diff --git a/src/network/httpd.c b/src/network/httpd.c index 928719cf37..b00b6d6e85 100644 --- a/src/network/httpd.c +++ b/src/network/httpd.c @@ -30,6 +30,7 @@ #include #include +#include #include #include diff --git a/src/network/io.c b/src/network/io.c index db6ce989d0..22a1ae83c6 100644 --- a/src/network/io.c +++ b/src/network/io.c @@ -49,6 +49,7 @@ #include #include +#include #include #if defined (_WIN32) # undef EINPROGRESS diff --git a/test/modules/misc/tls.c b/test/modules/misc/tls.c index efbd171086..3dc0e10d66 100644 --- a/test/modules/misc/tls.c +++ b/test/modules/misc/tls.c @@ -35,6 +35,7 @@ #include #include +#include #include #include #include "../../../lib/libvlc_internal.h"