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
# 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 */
/* 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;
/* 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;
/* 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;
/* 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 );
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;
{
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 )
{
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 );
#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) );
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 */
/* 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() )
{
/* 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 )
/* 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 );
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 )
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 )
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;
/* 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;
{
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;
/* 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 )
#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();
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
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) )
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 ));