[vlc-commits] [Git][videolan/vlc][master] vlc_threads: move poll() definitions in a separate header

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Jan 30 10:05:47 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
3f613a85 by Steve Lhomme at 2024-01-30T09:39:00+00:00
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.

- - - - -


22 changed files:

- + include/vlc_poll.h
- include/vlc_threads.h
- modules/access/dtv/en50221.c
- modules/access/dv.c
- modules/access/http/h2conn.c
- modules/access/http/h2output.c
- modules/access/linsys/linsys_hdsdi.c
- modules/access/linsys/linsys_sdi.c
- modules/access/oss.c
- modules/access/rdp.c
- modules/access/rtp/datagram.c
- modules/access/satip.c
- modules/control/globalhotkeys/xcb.c
- modules/control/lirc.c
- modules/control/netsync.c
- modules/services_discovery/udisks.c
- modules/video_output/xcb/window.c
- src/Makefile.am
- src/misc/interrupt.c
- src/network/httpd.c
- src/network/io.c
- test/modules/misc/tls.c


Changes:

=====================================
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 at via.ecp.fr>
+ *          Samuel Hocevar <sam at via.ecp.fr>
+ *          Gildas Bazin <gbazin at netcourrier.com>
+ *          Christophe Massiot <massiot at 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_ */


=====================================
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>


=====================================
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>
 


=====================================
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>
 


=====================================
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>


=====================================
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"


=====================================
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>
 


=====================================
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>
 


=====================================
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>


=====================================
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>


=====================================
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


=====================================
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>


=====================================
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>


=====================================
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>


=====================================
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>


=====================================
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>


=====================================
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>


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


=====================================
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 */
 


=====================================
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>


=====================================
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


=====================================
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"



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3f613a85f58edc1e37d56a1fe7769c9e14981258

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/3f613a85f58edc1e37d56a1fe7769c9e14981258
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list