]> git.sesse.net Git - vlc/commitdiff
Remove State Threads support
authorRémi Denis-Courmont <rem@videolan.org>
Tue, 22 Jan 2008 16:17:33 +0000 (16:17 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Tue, 22 Jan 2008 16:17:33 +0000 (16:17 +0000)
configure.ac
include/vlc_threads.h
include/vlc_threads_funcs.h
src/misc/mtime.c
src/misc/threads.c

index 5223ed70f155647cb8740a23d64797e3bf0e1c51..6881990e37565f14ec63b7bc205ae3b4b09f9381 100644 (file)
@@ -741,49 +741,27 @@ fi
 dnl Check for cthreads under GNU/Hurd for instance
 AC_CHECK_LIB(threads,cthread_fork,THREAD_LIB="-lthreads")
 
-dnl
-dnl  State Threads
-dnl
-AC_ARG_ENABLE(st,
-  [  --enable-st             State Threads (default disabled)],
-  [ if test "${enable_st}" = "yes"; then
-    AC_CHECK_LIB(st,st_init)
-    AC_MSG_CHECKING(for st_init in st.h)
-    AC_EGREP_HEADER(st_init,st.h,[
-      AC_MSG_RESULT(yes)
-      AC_DEFINE(ST_INIT_IN_ST_H, 1,
-                Define if <st.h> defines st_init)
-      THREAD_LIB="-lst"
-    ],[
-      AC_MSG_RESULT(yes)
-    ])
-    fi
-])
-
 VLC_ADD_LIBS([libvlc plugin],[${THREAD_LIB}])
 
 dnl Don't link with rt when using GNU-pth
-if test "${THREAD_LIB}" != "-lst"; then
-  AC_CHECK_LIB(rt, clock_nanosleep, [
-    VLC_ADD_LIBS([libvlc],[-lrt])
-    AC_DEFINE(HAVE_CLOCK_NANOSLEEP, 1, [Define to 1 if you have clock_nanosleep.])
-  ], [
-    dnl HP/UX port
-    AC_CHECK_LIB(rt,sem_init, [VLC_ADD_LIBS([libvlc],[-lrt])])
-  ])
+AC_CHECK_LIB(rt, clock_nanosleep, [
+  VLC_ADD_LIBS([libvlc],[-lrt])
+  AC_DEFINE(HAVE_CLOCK_NANOSLEEP, 1, [Define to 1 if you have clock_nanosleep.])
+], [
+  dnl HP/UX port
+  AC_CHECK_LIB(rt,sem_init, [VLC_ADD_LIBS([libvlc],[-lrt])])
+])
 
-  have_nanosleep=false
-  AC_CHECK_FUNCS(nanosleep,have_nanosleep=:,[
-    AC_CHECK_LIB(rt,nanosleep,
-      [VLC_ADD_LIBS([libvlc],[-lrt]) have_nanosleep=:],
-      [AC_CHECK_LIB(posix4,nanosleep,
-          [VLC_ADD_LIBS([libvlc],[-lposix4]) have_nanosleep=:])]
-    )
-  ])
-  if ${have_nanosleep}; then
-    AC_DEFINE(HAVE_NANOSLEEP, 1,
-              Define if nanosleep is available.)
-  fi
+have_nanosleep=false
+AC_CHECK_FUNCS(nanosleep,have_nanosleep=:,[
+  AC_CHECK_LIB(rt,nanosleep,
+    [VLC_ADD_LIBS([libvlc],[-lrt]) have_nanosleep=:],
+    [AC_CHECK_LIB(posix4,nanosleep,
+        [VLC_ADD_LIBS([libvlc],[-lposix4]) have_nanosleep=:])]
+  )
+])
+if ${have_nanosleep}; then
+  AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if nanosleep is available.])
 fi
 
 dnl Check for misc headers
index 22015cbd2036c983eef8594c0f62adf2ad8e93b5..86abfe698c46312ee9652a04a36e1886cb32f2fe 100644 (file)
 #   include <sys/time.h>
 #endif
 
-#if defined( ST_INIT_IN_ST_H )                            /* State threads */
-#   include <st.h>
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
                                                                 /* WinCE API */
 #elif defined( WIN32 )
 #   include <process.h>                                         /* Win32 API */
  * Type definitions
  *****************************************************************************/
 
-#if defined( ST_INIT_IN_ST_H )
-typedef st_thread_t      vlc_thread_t;
-typedef struct
-{
-    st_mutex_t mutex;
-    vlc_object_t * p_this;
-} vlc_mutex_t;
-typedef struct
-{
-    st_cond_t cond;
-    vlc_object_t * p_this;
-} vlc_cond_t;
-typedef struct
-{
-    int handle;
-} vlc_threadvar_t;
-
-#elif defined( WIN32 ) || defined( UNDER_CE )
+#if defined( WIN32 ) || defined( UNDER_CE )
 typedef struct
 {
     /* thread id */
index d9a671495bb7931860bc53ca45377ff2ebd1ad55..0d7daaff6b04f813098bc6f13893ad71ae75c1e4 100644 (file)
@@ -100,10 +100,7 @@ static inline int __vlc_mutex_lock( const char * psz_file, int i_line,
     /* In case of error : */
     unsigned long int i_thread = 0;
 
-#if defined( ST_INIT_IN_ST_H )
-    i_result = st_mutex_lock( p_mutex->mutex );
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     EnterCriticalSection( &p_mutex->csection );
     i_result = 0;
 
@@ -176,10 +173,7 @@ static inline int __vlc_mutex_unlock( const char * psz_file, int i_line,
     /* In case of error : */
     unsigned long int i_thread = 0;
 
-#if defined( ST_INIT_IN_ST_H )
-    i_result = st_mutex_unlock( p_mutex->mutex );
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     LeaveCriticalSection( &p_mutex->csection );
     i_result = 0;
 
@@ -259,10 +253,7 @@ static inline int __vlc_cond_signal( const char * psz_file, int i_line,
     /* In case of error : */
     unsigned long int i_thread = 0;
 
-#if defined( ST_INIT_IN_ST_H )
-    i_result = st_cond_signal( p_condvar->cond );
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     PulseEvent( p_condvar->event );
     i_result = 0;
 
@@ -391,12 +382,7 @@ static inline int __vlc_cond_wait( const char * psz_file, int i_line,
     /* In case of error : */
     unsigned long int i_thread = 0;
 
-#if defined( ST_INIT_IN_ST_H )
-    st_mutex_unlock( p_mutex->mutex );
-    i_result = st_cond_wait( p_condvar->cond );
-    st_mutex_lock( p_mutex->mutex );
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     p_condvar->i_waiting_threads++;
     LeaveCriticalSection( &p_mutex->csection );
     WaitForSingleObject( p_condvar->event, INFINITE );
@@ -575,9 +561,7 @@ static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
     int i_res;
     unsigned long int i_thread = 0;
 
-#if defined( ST_INIT_IN_ST_H )
-#   error Unimplemented
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     mtime_t delay_ms = (deadline - mdate())/1000;
 
     DWORD result;
@@ -738,9 +722,7 @@ static inline int vlc_threadvar_set( vlc_threadvar_t * p_tls, void *p_value )
 {
     int i_ret;
 
-#if  defined( ST_INIT_IN_ST_H )
-    return st_thread_setspecific( p_tls->handle, p_value );
-#elif defined( HAVE_KERNEL_SCHEDULER_H )
+#if defined( HAVE_KERNEL_SCHEDULER_H )
     return -1;
 
 #elif defined( UNDER_CE ) || defined( WIN32 )
@@ -763,9 +745,7 @@ static inline void* vlc_threadvar_get( vlc_threadvar_t * p_tls )
 {
     void* p_ret;
 
-#if defined( ST_INIT_IN_ST_H )
-    p_ret = st_thread_getspecific( p_handle->key );
-#elif defined( HAVE_KERNEL_SCHEDULER_H )
+#if defined( HAVE_KERNEL_SCHEDULER_H )
     p_ret = NULL;
 #elif defined( UNDER_CE ) || defined( WIN32 )
     p_ret = TlsGetValue( p_tls->handle );
index 385cc38861dec2754d1916f4e986335f4097d7e8..93fbdb472ece075a15d841392130e1adcae12c05 100644 (file)
@@ -326,9 +326,6 @@ void msleep( mtime_t delay )
 #elif defined( HAVE_KERNEL_OS_H )
     snooze( delay );
 
-#elif defined( ST_INIT_IN_ST_H )
-    st_usleep( delay );
-
 #elif defined( WIN32 ) || defined( UNDER_CE )
     Sleep( (int) (delay / 1000) );
 
index 45d133f844e15f3d22798bba751ad80dcea04d8a..59a9c64f8934fa3c68df48966037bec80bbd5819 100644 (file)
@@ -44,8 +44,7 @@ static volatile unsigned i_initializations = 0;
 static volatile int i_status = VLC_THREADS_UNINITIALIZED;
 static vlc_object_t *p_root;
 
-#if defined( ST_INIT_IN_ST_H )
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
 #elif defined( WIN32 )
 
 /* following is only available on NT/2000/XP and above */
@@ -104,8 +103,7 @@ int __vlc_threads_init( vlc_object_t *p_this )
 
     /* If we have lazy mutex initialization, use it. Otherwise, we just
      * hope nothing wrong happens. */
-#if defined( ST_INIT_IN_ST_H )
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
 #elif defined( WIN32 )
     if( IsDebuggerPresent() )
     {
@@ -126,10 +124,7 @@ int __vlc_threads_init( vlc_object_t *p_this )
         /* We should be safe now. Do all the initialization stuff we want. */
         p_libvlc_global->b_ready = VLC_FALSE;
 
-#if defined( ST_INIT_IN_ST_H )
-        i_ret = st_init();
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
         /* Nothing to initialize */
 
 #elif defined( WIN32 )
@@ -177,9 +172,7 @@ int __vlc_threads_init( vlc_object_t *p_this )
 
     /* If we have lazy mutex initialization support, unlock the mutex;
      * otherwize, do a naive wait loop. */
-#if defined( ST_INIT_IN_ST_H )
-    while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
 #elif defined( WIN32 )
     while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP );
@@ -207,8 +200,7 @@ int __vlc_threads_init( vlc_object_t *p_this )
 int __vlc_threads_end( vlc_object_t *p_this )
 {
     (void)p_this;
-#if defined( ST_INIT_IN_ST_H )
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
 #elif defined( WIN32 )
 #elif defined( HAVE_KERNEL_SCHEDULER_H )
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
@@ -226,8 +218,7 @@ int __vlc_threads_end( vlc_object_t *p_this )
         vlc_object_destroy( p_root );
     }
 
-#if defined( ST_INIT_IN_ST_H )
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
 #elif defined( WIN32 )
 #elif defined( HAVE_KERNEL_SCHEDULER_H )
 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )
@@ -245,11 +236,7 @@ int __vlc_mutex_init( vlc_object_t *p_this, vlc_mutex_t *p_mutex )
     assert( p_this );
     p_mutex->p_this = p_this;
 
-#if defined( ST_INIT_IN_ST_H )
-    p_mutex->mutex = st_mutex_new();
-    return ( p_mutex->mutex == NULL ) ? errno : 0;
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     InitializeCriticalSection( &p_mutex->csection );
     return 0;
 
@@ -363,10 +350,7 @@ int __vlc_mutex_destroy( const char * psz_file, int i_line, vlc_mutex_t *p_mutex
     /* In case of error : */
     int i_thread = -1;
 
-#if defined( ST_INIT_IN_ST_H )
-    i_result = st_mutex_destroy( p_mutex->mutex );
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     DeleteCriticalSection( &p_mutex->csection );
     return 0;
 
@@ -420,11 +404,7 @@ int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar )
 {
     p_condvar->p_this = p_this;
 
-#if defined( ST_INIT_IN_ST_H )
-    p_condvar->cond = st_cond_new();
-    return ( p_condvar->cond == NULL ) ? errno : 0;
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     /* Initialize counter */
     p_condvar->i_waiting_threads = 0;
 
@@ -531,10 +511,7 @@ int __vlc_cond_destroy( const char * psz_file, int i_line, vlc_cond_t *p_condvar
     /* In case of error : */
     int i_thread = -1;
 
-#if defined( ST_INIT_IN_ST_H )
-    i_result = st_cond_destroy( p_condvar->cond );
-
-#elif defined( UNDER_CE )
+#if defined( UNDER_CE )
     i_result = !CloseHandle( p_condvar->event );
 
 #elif defined( WIN32 )
@@ -585,8 +562,6 @@ int __vlc_threadvar_create( vlc_object_t *p_this, vlc_threadvar_t *p_tls )
 #if defined( HAVE_KERNEL_SCHEDULER_H )
     msg_Err( p_this, "TLS not implemented" );
     i_ret VLC_EGENERIC;
-#elif defined( ST_INIT_IN_ST_H )
-    i_ret = st_key_create( &p_tls->handle, NULL );
 #elif defined( UNDER_CE ) || defined( WIN32 )
 #elif defined( WIN32 )
     p_tls->handle = TlsAlloc();
@@ -616,11 +591,7 @@ int __vlc_thread_create( vlc_object_t *p_this, const char * psz_file, int i_line
 
     vlc_mutex_lock( &p_this->object_lock );
 
-#if defined( ST_INIT_IN_ST_H )
-    p_priv->thread_id = st_thread_create( func, p_data, 1, 0 );
-    i_ret = 0;
-
-#elif defined( WIN32 ) || defined( UNDER_CE )
+#if defined( WIN32 ) || defined( UNDER_CE )
     {
         /* When using the MSVCRT C library you have to use the _beginthreadex
          * function instead of CreateThread, otherwise you'll end up with
@@ -749,8 +720,7 @@ int __vlc_thread_set_priority( vlc_object_t *p_this, const char * psz_file,
                                int i_line, int i_priority )
 {
     vlc_object_internals_t *p_priv = p_this->p_internals;
-#if defined( ST_INIT_IN_ST_H )
-#elif defined( WIN32 ) || defined( UNDER_CE )
+#if defined( WIN32 ) || defined( UNDER_CE )
     if( !p_priv->thread_id.hThread )
         p_priv->thread_id.hThread = GetCurrentThread();
     if( !SetThreadPriority(p_priv->thread_id.hThread, i_priority) )
@@ -887,10 +857,7 @@ void __vlc_thread_join( vlc_object_t *p_this, const char * psz_file, int i_line
 
     int i_ret = 0;
 
-#if defined( ST_INIT_IN_ST_H )
-    i_ret = st_thread_join( p_priv->thread_id, NULL );
-
-#elif defined( HAVE_KERNEL_SCHEDULER_H )
+#if defined( HAVE_KERNEL_SCHEDULER_H )
     int32_t exit_value;
     i_ret = (B_OK == wait_for_thread( p_priv->thread_id, &exit_value ));