[vlc-commits] threads: vlc_thread_t is opaque

Rémi Denis-Courmont git at videolan.org
Mon Jul 25 18:11:26 CEST 2016


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Mon Jul 25 19:10:11 2016 +0300| [6efb88ff345c61cbc36a372a8d7fc2aa91a7b5b4] | committer: Rémi Denis-Courmont

threads: vlc_thread_t is opaque

Comparison with zero means nothing.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6efb88ff345c61cbc36a372a8d7fc2aa91a7b5b4
---

 include/vlc_threads.h      | 16 ++++++++++++----
 modules/access/Makefile.am |  2 +-
 modules/demux/Makefile.am  |  2 +-
 src/posix/thread.c         | 15 ++++++++-------
 4 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/include/vlc_threads.h b/include/vlc_threads.h
index 33b9b53..226af0f 100644
--- a/include/vlc_threads.h
+++ b/include/vlc_threads.h
@@ -52,7 +52,11 @@ VLC_API void vlc_testcancel(void);
 #  define ETIMEDOUT 10060 /* This is the value in winsock.h. */
 # endif
 
-typedef struct vlc_thread *vlc_thread_t;
+typedef struct
+{
+    struct vlc_thread *thread;
+} vlc_thread_t;
+
 # define VLC_THREAD_CANCELED NULL
 # define LIBVLC_NEED_SLEEP
 typedef struct
@@ -249,7 +253,10 @@ typedef struct vlc_timer *vlc_timer_t;
 /**
  * Thread handle.
  */
-typedef pthread_t       vlc_thread_t;
+typedef struct
+{
+    pthread_t handle;
+} vlc_thread_t;
 
 /**
  * Return value of a canceled thread.
@@ -660,12 +667,13 @@ void vlc_addr_broadcast(void *addr);
  * The thread must be <i>joined</i> with vlc_join() to reclaim resources
  * when it is not needed anymore.
  *
- * @param th [OUT] pointer to write the handle of the created thread to
- *                 (mandatory, must be non-NULL)
+ * @param th storage space for the handle of the new thread (cannot be NULL)
+ *           [OUT]
  * @param entry entry point for the thread
  * @param data data parameter given to the entry point
  * @param priority thread priority value
  * @return 0 on success, a standard error code on error.
+ * @note In case of error, the value of *th is undefined.
  */
 VLC_API int vlc_clone(vlc_thread_t *th, void *(*entry)(void *), void *data,
                       int priority) VLC_USED;
diff --git a/modules/access/Makefile.am b/modules/access/Makefile.am
index 5046583..3c71e64 100644
--- a/modules/access/Makefile.am
+++ b/modules/access/Makefile.am
@@ -444,7 +444,7 @@ endif
 
 libsatip_plugin_la_SOURCES = access/satip.c
 libsatip_plugin_la_LIBADD = $(SOCKET_LIBS) $(LIBPTHREAD)
-access_LTLIBRARIES += libsatip_plugin.la
+EXTRA_LTLIBRARIES += libsatip_plugin.la
 
 ### Misc ###
 
diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index 71fd206..e127b9f 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -448,7 +448,7 @@ if HAVE_GCRYPT
 libadaptive_plugin_la_CXXFLAGS += $(GCRYPT_CFLAGS)
 libadaptive_plugin_la_LIBADD += $(GCRYPT_LIBS)
 endif
-demux_LTLIBRARIES += libadaptive_plugin.la
+EXTRA_LTLIBRARIES += libadaptive_plugin.la
 
 libttml_plugin_la_SOURCES = demux/ttml.c
 demux_LTLIBRARIES += libttml_plugin.la
diff --git a/src/posix/thread.c b/src/posix/thread.c
index f1d9542..ec0fbdb 100644
--- a/src/posix/thread.c
+++ b/src/posix/thread.c
@@ -481,7 +481,7 @@ static int vlc_clone_attr (vlc_thread_t *th, pthread_attr_t *attr,
     assert (ret == 0); /* fails iif VLC_STACKSIZE is invalid */
 #endif
 
-    ret = pthread_create (th, attr, entry, data);
+    ret = pthread_create(&th->handle, attr, entry, data);
     pthread_sigmask (SIG_SETMASK, &oldset, NULL);
     pthread_attr_destroy (attr);
     return ret;
@@ -496,9 +496,9 @@ int vlc_clone (vlc_thread_t *th, void *(*entry) (void *), void *data,
     return vlc_clone_attr (th, &attr, entry, data, priority);
 }
 
-void vlc_join (vlc_thread_t handle, void **result)
+void vlc_join(vlc_thread_t th, void **result)
 {
-    int val = pthread_join (handle, result);
+    int val = pthread_join(th.handle, result);
     VLC_THREAD_ASSERT ("joining thread");
 }
 
@@ -548,7 +548,8 @@ int vlc_clone_detach (vlc_thread_t *th, void *(*entry) (void *), void *data,
 
 vlc_thread_t vlc_thread_self (void)
 {
-    return pthread_self ();
+    vlc_thread_t thread = { pthread_self() };
+    return thread;
 }
 
 #if !defined (__linux__)
@@ -573,7 +574,7 @@ int vlc_set_priority (vlc_thread_t th, int priority)
         else
             sp.sched_priority += sched_get_priority_min (policy = SCHED_RR);
 
-        if (pthread_setschedparam (th, policy, &sp))
+        if (pthread_setschedparam(th.handle, policy, &sp))
             return VLC_EGENERIC;
     }
 #else
@@ -582,9 +583,9 @@ int vlc_set_priority (vlc_thread_t th, int priority)
     return VLC_SUCCESS;
 }
 
-void vlc_cancel (vlc_thread_t thread_id)
+void vlc_cancel(vlc_thread_t th)
 {
-    pthread_cancel (thread_id);
+    pthread_cancel(th.handle);
 }
 
 int vlc_savecancel (void)



More information about the vlc-commits mailing list