Browse Source

vlc_threads: move poll() definitions in a separate header

It's using a compat version on Windows/Android/OS2 which is not available
to external modules.

This new header can't be used directly from external modules on Windows.
This makes vlc_threads.h usable from external modules on Windows.
pull/162/head
Steve Lhomme 2 years ago
parent
commit
3f613a85f5
  1. 99
      include/vlc_poll.h
  2. 52
      include/vlc_threads.h
  3. 1
      modules/access/dtv/en50221.c
  4. 1
      modules/access/dv.c
  5. 1
      modules/access/http/h2conn.c
  6. 1
      modules/access/http/h2output.c
  7. 1
      modules/access/linsys/linsys_hdsdi.c
  8. 1
      modules/access/linsys/linsys_sdi.c
  9. 1
      modules/access/oss.c
  10. 1
      modules/access/rdp.c
  11. 1
      modules/access/rtp/datagram.c
  12. 1
      modules/access/satip.c
  13. 1
      modules/control/globalhotkeys/xcb.c
  14. 1
      modules/control/lirc.c
  15. 1
      modules/control/netsync.c
  16. 1
      modules/services_discovery/udisks.c
  17. 1
      modules/video_output/xcb/window.c
  18. 1
      src/Makefile.am
  19. 1
      src/misc/interrupt.c
  20. 1
      src/network/httpd.c
  21. 1
      src/network/io.c
  22. 1
      test/modules/misc/tls.c

99
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 <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
* Christophe Massiot <massiot@via.ecp.fr>
*
* 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 <vlc_threads.h>
/**
* \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_ */

52
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 <errno.h>
@ -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 <unistd.h>
# include <pthread.h>
@ -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 <unistd.h> /* _POSIX_SPIN_LOCKS */
# include <pthread.h>

1
modules/access/dtv/en50221.c

@ -30,6 +30,7 @@
#include <vlc_arrays.h>
#include <vlc_tick.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_charset.h>
#include <vlc_fs.h>

1
modules/access/dv.c

@ -31,6 +31,7 @@
#include <vlc_common.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_plugin.h>
#include <vlc_access.h>

1
modules/access/http/h2conn.c

@ -34,6 +34,7 @@
#endif
#include <vlc_common.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_block.h>
#include <vlc_interrupt.h>
#include <vlc_tls.h>

1
modules/access/http/h2output.c

@ -33,6 +33,7 @@
#endif
#include <vlc_common.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_tls.h>
#include "h2frame.h"
#include "h2output.h"

1
modules/access/linsys/linsys_hdsdi.c

@ -42,6 +42,7 @@
#include <vlc_input.h>
#include <vlc_access.h>
#include <vlc_demux.h>
#include <vlc_poll.h>
#include <vlc_fs.h>

1
modules/access/linsys/linsys_sdi.c

@ -41,6 +41,7 @@
#include <vlc_input.h>
#include <vlc_access.h>
#include <vlc_demux.h>
#include <vlc_poll.h>
#include <vlc_fs.h>

1
modules/access/oss.c

@ -36,6 +36,7 @@
#include <vlc_access.h>
#include <vlc_demux.h>
#include <vlc_fs.h>
#include <vlc_poll.h>
#include <errno.h>
#include <fcntl.h>

1
modules/access/rdp.c

@ -28,6 +28,7 @@
#include <vlc_common.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_plugin.h>
#include <vlc_demux.h>
#include <vlc_url.h>

1
modules/access/rtp/datagram.c

@ -30,6 +30,7 @@
#include <vlc_common.h>
#include <vlc_network.h>
#include <vlc_poll.h>
#include "vlc_dtls.h"
#ifndef MSG_TRUNC

1
modules/access/satip.c

@ -33,6 +33,7 @@
#include <vlc_common.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_plugin.h>
#include <vlc_access.h>
#include <vlc_network.h>

1
modules/control/globalhotkeys/xcb.c

@ -29,6 +29,7 @@
#include <vlc_plugin.h>
#include <vlc_interface.h>
#include <vlc_actions.h>
#include <vlc_poll.h>
#include <errno.h>
#include <xcb/xcb.h>

1
modules/control/lirc.c

@ -37,6 +37,7 @@
#include <vlc_plugin.h>
#include <vlc_interface.h>
#include <vlc_actions.h>
#include <vlc_poll.h>
#ifdef HAVE_POLL_H
# include <poll.h>

1
modules/control/netsync.c

@ -35,6 +35,7 @@
#include <vlc_plugin.h>
#include <vlc_interface.h>
#include <vlc_playlist_legacy.h>
#include <vlc_poll.h>
#include <sys/types.h>
#include <unistd.h>

1
modules/services_discovery/udisks.c

@ -29,6 +29,7 @@
#include <vlc_common.h>
#include <vlc_arrays.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_plugin.h>
#include <vlc_modules.h>
#include <vlc_configuration.h>

1
modules/video_output/xcb/window.c

@ -47,6 +47,7 @@ typedef xcb_atom_t Atom;
#include <vlc_common.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_plugin.h>
#include <vlc_actions.h>
#include <vlc_window.h>

1
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 \

1
src/misc/interrupt.c

@ -42,6 +42,7 @@
#include <vlc_common.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_fs.h> /* vlc_pipe */
#include <vlc_network.h> /* vlc_accept */

1
src/network/httpd.c

@ -30,6 +30,7 @@
#include <vlc_common.h>
#include <vlc_threads.h>
#include <vlc_poll.h>
#include <vlc_httpd.h>
#include <assert.h>

1
src/network/io.c

@ -49,6 +49,7 @@
#include <vlc_common.h>
#include <vlc_network.h>
#include <vlc_poll.h>
#include <vlc_interrupt.h>
#if defined (_WIN32)
# undef EINPROGRESS

1
test/modules/misc/tls.c

@ -35,6 +35,7 @@
#include <poll.h>
#include <vlc_common.h>
#include <vlc_poll.h>
#include <vlc_modules.h>
#include <vlc_tls.h>
#include "../../../lib/libvlc_internal.h"

Loading…
Cancel
Save