Commit 16f2ff86 authored by Sam Hocevar's avatar Sam Hocevar

* ./configure.in: do not try to link with -lrt if not using pthreads. This

    might break the HP/UX or Solaris ports, please check if possible.
  * ./src/misc/threads.c: fixed syntax in the st and pth implementations.
parent 7d2f6de5
...@@ -156,9 +156,9 @@ AC_CHECK_FUNC(gethostbyname,,[ ...@@ -156,9 +156,9 @@ AC_CHECK_FUNC(gethostbyname,,[
have_nanosleep=0 have_nanosleep=0
AC_CHECK_FUNC(nanosleep,have_nanosleep=1,[ AC_CHECK_FUNC(nanosleep,have_nanosleep=1,[
AC_CHECK_LIB(rt,nanosleep, AC_CHECK_LIB(rt,nanosleep,
[vlc_LDFLAGS="${vlc_LDFLAGS} -lrt"; have_nanosleep=1], [pthread_LDFLAGS="${pthread_LDFLAGS} -lrt"; have_nanosleep=1],
[AC_CHECK_LIB(posix4,nanosleep, [AC_CHECK_LIB(posix4,nanosleep,
[vlc_LDFLAGS="${vlc_LDFLAGS} -lposix4"; have_nanosleep=1])] [pthread_LDFLAGS="${pthread_LDFLAGS} -lposix4"; have_nanosleep=1])]
) )
]) ])
if test x$have_nanosleep = x1; then if test x$have_nanosleep = x1; then
...@@ -166,7 +166,7 @@ if test x$have_nanosleep = x1; then ...@@ -166,7 +166,7 @@ if test x$have_nanosleep = x1; then
Define if nanosleep is available.) Define if nanosleep is available.)
fi fi
# HP/UX port # HP/UX port
AC_CHECK_LIB(rt,sem_init, [vlc_LDFLAGS="${vlc_LDFLAGS} -lrt"]) AC_CHECK_LIB(rt,sem_init, [pthread_LDFLAGS="${pthread_LDFLAGS} -lrt"])
AC_CHECK_FUNC(inet_aton,,[ AC_CHECK_FUNC(inet_aton,,[
AC_CHECK_LIB(resolv,inet_aton,ipv4_LDFLAGS="${ipv4_LDFLAGS} -lresolv") AC_CHECK_LIB(resolv,inet_aton,ipv4_LDFLAGS="${ipv4_LDFLAGS} -lresolv")
...@@ -203,10 +203,10 @@ AC_CHECK_LIB(m,pow, ...@@ -203,10 +203,10 @@ AC_CHECK_LIB(m,pow,
dnl Check for pthreads - borrowed from XMMS dnl Check for pthreads - borrowed from XMMS
THREAD_LIB=error THREAD_LIB=error
if test "x${THREAD_LIB}" = "xerror"; then if test "x${THREAD_LIB}" = "xerror"; then
AC_CHECK_LIB(pthread,main,THREAD_LIB="-lpthread") AC_CHECK_LIB(pthread,main,THREAD_LIB="-lpthread ${pthread_LDFLAGS}")
fi fi
if test "x${THREAD_LIB}" = "xerror"; then if test "x${THREAD_LIB}" = "xerror"; then
AC_CHECK_LIB(pthreads,main,THREAD_LIB="-lpthreads") AC_CHECK_LIB(pthreads,main,THREAD_LIB="-lpthreads ${pthread_LDFLAGS}")
fi fi
if test "x${THREAD_LIB}" = "xerror"; then if test "x${THREAD_LIB}" = "xerror"; then
AC_CHECK_LIB(c_r,main,THREAD_LIB="-lc_r") AC_CHECK_LIB(c_r,main,THREAD_LIB="-lc_r")
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* This header provides portable declarations for mutexes & conditions * This header provides portable declarations for mutexes & conditions
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2002 VideoLAN * Copyright (C) 1999, 2002 VideoLAN
* $Id: vlc_threads.h,v 1.10 2002/08/29 23:53:22 massiot Exp $ * $Id: vlc_threads.h,v 1.11 2002/08/30 12:23:23 sam Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -105,15 +105,15 @@ typedef struct ...@@ -105,15 +105,15 @@ typedef struct
} vlc_cond_t; } vlc_cond_t;
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
typedef st_thread_t * vlc_thread_t; typedef st_thread_t vlc_thread_t;
typedef struct typedef struct
{ {
st_mutex_t * mutex; st_mutex_t mutex;
vlc_object_t * p_this; vlc_object_t * p_this;
} vlc_mutex_t; } vlc_mutex_t;
typedef struct typedef struct
{ {
st_cond_t * cond; st_cond_t cond;
vlc_object_t * p_this; vlc_object_t * p_this;
} vlc_cond_t; } vlc_cond_t;
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* This header provides a portable threads implementation. * This header provides a portable threads implementation.
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2002 VideoLAN * Copyright (C) 1999, 2002 VideoLAN
* $Id: vlc_threads_funcs.h,v 1.1 2002/08/29 23:53:22 massiot Exp $ * $Id: vlc_threads_funcs.h,v 1.2 2002/08/30 12:23:23 sam Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@via.ecp.fr> * Samuel Hocevar <sam@via.ecp.fr>
...@@ -74,7 +74,7 @@ static inline int __vlc_mutex_lock( char * psz_file, int i_line, ...@@ -74,7 +74,7 @@ static inline int __vlc_mutex_lock( char * psz_file, int i_line,
i_result = pth_mutex_acquire( &p_mutex->mutex, TRUE, NULL ); i_result = pth_mutex_acquire( &p_mutex->mutex, TRUE, NULL );
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
i_result = st_mutex_lock( *p_mutex->mutex ); i_result = st_mutex_lock( p_mutex->mutex );
#elif defined( WIN32 ) #elif defined( WIN32 )
if( p_mutex->mutex ) if( p_mutex->mutex )
...@@ -141,7 +141,7 @@ static inline int __vlc_mutex_unlock( char * psz_file, int i_line, ...@@ -141,7 +141,7 @@ static inline int __vlc_mutex_unlock( char * psz_file, int i_line,
i_result = pth_mutex_release( &p_mutex->mutex ); i_result = pth_mutex_release( &p_mutex->mutex );
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
i_result = st_mutex_unlock( *p_mutex->mutex ); i_result = st_mutex_unlock( p_mutex->mutex );
#elif defined( WIN32 ) #elif defined( WIN32 )
if( p_mutex->mutex ) if( p_mutex->mutex )
...@@ -222,7 +222,7 @@ static inline int __vlc_cond_signal( char * psz_file, int i_line, ...@@ -222,7 +222,7 @@ static inline int __vlc_cond_signal( char * psz_file, int i_line,
i_result = pth_cond_notify( &p_condvar->cond, FALSE ); i_result = pth_cond_notify( &p_condvar->cond, FALSE );
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
i_result = st_cond_signal( *p_condvar->cond ); i_result = st_cond_signal( p_condvar->cond );
#elif defined( WIN32 ) #elif defined( WIN32 )
/* Release one waiting thread if one is available. */ /* Release one waiting thread if one is available. */
...@@ -352,7 +352,7 @@ static inline int __vlc_cond_broadcast( char * psz_file, int i_line, ...@@ -352,7 +352,7 @@ static inline int __vlc_cond_broadcast( char * psz_file, int i_line,
i_result = pth_cond_notify( &p_condvar->cond, FALSE ); i_result = pth_cond_notify( &p_condvar->cond, FALSE );
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
i_result = st_cond_broadcast( *p_condvar->cond ); i_result = st_cond_broadcast( p_condvar->cond );
#elif defined( WIN32 ) #elif defined( WIN32 )
/* Release all waiting threads. */ /* Release all waiting threads. */
...@@ -479,9 +479,9 @@ static inline int __vlc_cond_wait( char * psz_file, int i_line, ...@@ -479,9 +479,9 @@ static inline int __vlc_cond_wait( char * psz_file, int i_line,
i_result = pth_cond_await( &p_condvar->cond, &p_mutex->mutex, NULL ); i_result = pth_cond_await( &p_condvar->cond, &p_mutex->mutex, NULL );
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
st_mutex_unlock( *p_mutex->mutex ); st_mutex_unlock( p_mutex->mutex );
i_result = st_cond_wait( *p_condvar->cond ); i_result = st_cond_wait( p_condvar->cond );
st_mutex_lock( *p_mutex->mutex ); st_mutex_lock( p_mutex->mutex );
#elif defined( WIN32 ) #elif defined( WIN32 )
if( !p_condvar->semaphore ) if( !p_condvar->semaphore )
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* threads.c : threads implementation for the VideoLAN client * threads.c : threads implementation for the VideoLAN client
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN * Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: threads.c,v 1.13 2002/08/29 23:53:22 massiot Exp $ * $Id: threads.c,v 1.14 2002/08/30 12:23:23 sam Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -224,8 +224,8 @@ int __vlc_mutex_init( vlc_object_t *p_this, vlc_mutex_t *p_mutex ) ...@@ -224,8 +224,8 @@ int __vlc_mutex_init( vlc_object_t *p_this, vlc_mutex_t *p_mutex )
return pth_mutex_init( &p_mutex->mutex ); return pth_mutex_init( &p_mutex->mutex );
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
*p_mutex->mutex = st_mutex_new(); p_mutex->mutex = st_mutex_new();
return ( *p_mutex == NULL ) ? errno : 0; return ( p_mutex == NULL ) ? errno : 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
/* We use mutexes on WinNT/2K/XP because we can use the SignalObjectAndWait /* We use mutexes on WinNT/2K/XP because we can use the SignalObjectAndWait
...@@ -254,7 +254,7 @@ int __vlc_mutex_init( vlc_object_t *p_this, vlc_mutex_t *p_mutex ) ...@@ -254,7 +254,7 @@ int __vlc_mutex_init( vlc_object_t *p_this, vlc_mutex_t *p_mutex )
pthread_mutexattr_init( &attr ); pthread_mutexattr_init( &attr );
pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP ); pthread_mutexattr_setkind_np( &attr, PTHREAD_MUTEX_ERRORCHECK_NP );
i_result = pthread_mutex_init( p_mutex, &attr ); i_result = pthread_mutex_init( &p_mutex->mutex, &attr );
pthread_mutexattr_destroy( &attr ); pthread_mutexattr_destroy( &attr );
return( i_result ); return( i_result );
} }
...@@ -303,7 +303,7 @@ int __vlc_mutex_destroy( char * psz_file, int i_line, vlc_mutex_t *p_mutex ) ...@@ -303,7 +303,7 @@ int __vlc_mutex_destroy( char * psz_file, int i_line, vlc_mutex_t *p_mutex )
return 0; return 0;
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
i_result = st_mutex_destroy( *p_mutex ); i_result = st_mutex_destroy( p_mutex->mutex );
#elif defined( WIN32 ) #elif defined( WIN32 )
if( p_mutex->mutex ) if( p_mutex->mutex )
...@@ -357,8 +357,8 @@ int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar ) ...@@ -357,8 +357,8 @@ int __vlc_cond_init( vlc_object_t *p_this, vlc_cond_t *p_condvar )
return pth_cond_init( &p_condvar->cond ); return pth_cond_init( &p_condvar->cond );
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
*p_condvar->cond = st_cond_new(); p_condvar->cond = st_cond_new();
return ( *p_condvar->cond == NULL ) ? errno : 0; return ( p_condvar->cond == NULL ) ? errno : 0;
#elif defined( WIN32 ) #elif defined( WIN32 )
/* Initialize counter */ /* Initialize counter */
...@@ -441,7 +441,7 @@ int __vlc_cond_destroy( char * psz_file, int i_line, vlc_cond_t *p_condvar ) ...@@ -441,7 +441,7 @@ int __vlc_cond_destroy( char * psz_file, int i_line, vlc_cond_t *p_condvar )
return 0; return 0;
#elif defined( ST_INIT_IN_ST_H ) #elif defined( ST_INIT_IN_ST_H )
i_result = st_cond_destroy( *p_condvar->cond ); i_result = st_cond_destroy( p_condvar->cond );
#elif defined( WIN32 ) #elif defined( WIN32 )
if( !p_condvar->semaphore ) if( !p_condvar->semaphore )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment