Changeset 7fd77d963a10bba8397593a48a23b970665a9d91

Show
Ignore:
Timestamp:
01/27/08 16:56:24 (7 months ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1201449384 +0000
git-parent:

[37bc09bf45ed85666de87b46718f69b5c1fb46bd]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1201449384 +0000
Message:

Default to using pthread instead of exploding.
This fixes the single largest source of problems when including vlc/*.h out of the box.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • configure.ac

    r37bc09b r7fd77d9  
    765765  AC_DEFINE(HAVE_NANOSLEEP, 1, [Define if nanosleep is available.]) 
    766766fi 
     767fi # end "${SYS}" != "mingw32" -a "${SYS}" != "mingwce"  
    767768 
    768769dnl Check for misc headers 
    769 AC_MSG_CHECKING(for pthread_cond_t in pthread.h) 
    770 AC_EGREP_HEADER(pthread_cond_t,pthread.h,[ 
    771   AC_MSG_RESULT(yes) 
    772   AC_DEFINE(PTHREAD_COND_T_IN_PTHREAD_H, 1, 
    773             Define if <pthread.h> defines pthread_cond_t.)],[ 
    774   AC_MSG_RESULT(no)]) 
    775  
    776770AC_MSG_CHECKING(for strncasecmp in strings.h) 
    777771AC_EGREP_HEADER(strncasecmp,strings.h,[ 
  • include/vlc_threads.h

    r46d6d2d r7fd77d9  
    4545#   include <byteorder.h> 
    4646 
    47 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H )  /* pthreads (like Linux & BSD) */ 
     47#else                                         /* pthreads (like Linux & BSD) */ 
    4848#   define LIBVLC_USE_PTHREAD 1 
    4949#   define _APPLE_C_SOURCE    1 /* Proper pthread semantics on OSX */ 
     
    5656#      include <time.h> 
    5757#   endif 
    58  
    59 #else 
    60 #   error no threads available on your system ! 
    6158 
    6259#endif 
     
    8380#   define VLC_THREAD_PRIORITY_HIGHEST 15 
    8481 
    85 #elif defined(PTHREAD_COND_T_IN_PTHREAD_H
     82#elif defined(LIBVLC_USE_PTHREAD
    8683#   define VLC_THREAD_PRIORITY_LOW 0 
    8784#   define VLC_THREAD_PRIORITY_INPUT 20 
     
    190187 
    191188 
    192 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H ) 
     189#else 
    193190typedef pthread_t       vlc_thread_t; 
    194191typedef struct 
  • include/vlc_threads_funcs.h

    rc2f196a r7fd77d9  
    8585    __vlc_mutex_lock( __FILE__, __LINE__, P_MUTEX ) 
    8686 
    87 #if defined( PTHREAD_COND_T_IN_PTHREAD_H
     87#if defined(LIBVLC_USE_PTHREAD
    8888static inline unsigned long int CAST_PTHREAD_TO_INT (pthread_t th) 
    8989{ 
     
    130130    } 
    131131 
    132 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     132#elif defined(LIBVLC_USE_PTHREAD
    133133#   define vlc_assert_locked( m ) \ 
    134134           assert (pthread_mutex_lock (&((m)->mutex)) == EDEADLK) 
     
    200200    } 
    201201 
    202 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     202#elif defined(LIBVLC_USE_PTHREAD
    203203    i_result = pthread_mutex_unlock( &p_mutex->mutex ); 
    204204    if ( i_result ) 
     
    333333    } 
    334334 
    335 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     335#elif defined(LIBVLC_USE_PTHREAD
    336336    i_result = pthread_cond_signal( &p_condvar->cond ); 
    337337    if ( i_result ) 
     
    479479    i_result = 0; 
    480480 
    481 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     481#elif defined(LIBVLC_USE_PTHREAD
    482482 
    483483#   ifdef DEBUG 
     
    655655#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
    656656#   error Unimplemented 
    657 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     657#elif defined(LIBVLC_USE_PTHREAD
    658658    lldiv_t d = lldiv( deadline, 1000000 ); 
    659659    struct timespec ts = { d.quot, d.rem * 1000 }; 
     
    707707    i_ret = ( TlsSetValue( p_tls->handle, p_value ) != 0 ); 
    708708 
    709 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     709#elif defined(LIBVLC_USE_PTHREAD
    710710    i_ret = pthread_setspecific( p_tls->handle, p_value ); 
    711711 
     
    727727    p_ret = TlsGetValue( p_tls->handle ); 
    728728 
    729 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     729#elif defined(LIBVLC_USE_PTHREAD
    730730    p_ret = pthread_getspecific( p_tls->handle ); 
    731731 
  • src/libvlc-module.c

    r99fab90 r7fd77d9  
    18141814        change_need_restart(); 
    18151815 
    1816 #if !defined(__APPLE__) && !defined(SYS_BEOS) && defined(PTHREAD_COND_T_IN_PTHREAD_H
     1816#if !defined(__APPLE__) && !defined(SYS_BEOS) && defined(LIBVLC_USE_PTHREAD
    18171817    add_bool( "rt-priority", VLC_FALSE, NULL, RT_PRIORITY_TEXT, 
    18181818              RT_PRIORITY_LONGTEXT, VLC_TRUE ); 
     
    18201820#endif 
    18211821 
    1822 #if !defined(SYS_BEOS) && defined(PTHREAD_COND_T_IN_PTHREAD_H
     1822#if !defined(SYS_BEOS) && defined(LIBVLC_USE_PTHREAD
    18231823    add_integer( "rt-offset", 0, NULL, RT_OFFSET_TEXT, 
    18241824                 RT_OFFSET_LONGTEXT, VLC_TRUE ); 
  • src/misc/threads.c

    r46d6d2d r7fd77d9  
    7373 
    7474#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
    75 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     75#elif defined( LIBVLC_USE_PTHREAD
    7676static pthread_mutex_t once_mutex = PTHREAD_MUTEX_INITIALIZER; 
    7777#endif 
     
    116116    } 
    117117#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
    118 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     118#elif defined( LIBVLC_USE_PTHREAD
    119119    pthread_mutex_lock( &once_mutex ); 
    120120#endif 
     
    147147 
    148148#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
    149 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     149#elif defined( LIBVLC_USE_PTHREAD
    150150#endif 
    151151 
     
    180180#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
    181181    while( i_status == VLC_THREADS_PENDING ) msleep( THREAD_SLEEP ); 
    182 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     182#elif defined( LIBVLC_USE_PTHREAD
    183183    pthread_mutex_unlock( &once_mutex ); 
    184184#endif 
     
    203203#elif defined( WIN32 ) 
    204204#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
    205 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     205#elif defined( LIBVLC_USE_PTHREAD
    206206    pthread_mutex_lock( &once_mutex ); 
    207207#endif 
     
    220220#elif defined( WIN32 ) 
    221221#elif defined( HAVE_KERNEL_SCHEDULER_H ) 
    222 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     222#elif defined( LIBVLC_USE_PTHREAD
    223223    pthread_mutex_unlock( &once_mutex ); 
    224224#endif 
     
    281281    return B_OK; 
    282282 
    283 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     283#elif defined( LIBVLC_USE_PTHREAD
    284284# if defined(DEBUG) 
    285285    { 
     
    314314    p_mutex->mutex = CreateMutex( 0, FALSE, 0 ); 
    315315    return ( p_mutex->mutex != NULL ? 0 : 1 ); 
    316 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     316#elif defined( LIBVLC_USE_PTHREAD
    317317    pthread_mutexattr_t attr; 
    318318    int                 i_result; 
     
    372372    return B_OK; 
    373373 
    374 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     374#elif defined( LIBVLC_USE_PTHREAD
    375375    i_result = pthread_mutex_destroy( &p_mutex->mutex ); 
    376376    if( i_result ) 
     
    464464    return 0; 
    465465 
    466 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     466#elif defined( LIBVLC_USE_PTHREAD
    467467    pthread_condattr_t attr; 
    468468    int ret; 
     
    514514    return 0; 
    515515 
    516 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     516#elif defined( LIBVLC_USE_PTHREAD
    517517    i_result = pthread_cond_destroy( &p_condvar->cond ); 
    518518    if( i_result ) 
     
    550550    i_ret = !( p_tls->handle == 0xFFFFFFFF ); 
    551551 
    552 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     552#elif defined( LIBVLC_USE_PTHREAD
    553553    i_ret =  pthread_key_create( &p_tls->handle, NULL ); 
    554554#endif 
     
    611611    i_ret = resume_thread( p_priv->thread_id ); 
    612612 
    613 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     613#elif defined( LIBVLC_USE_PTHREAD
    614614    i_ret = pthread_create( &p_priv->thread_id, NULL, func, p_data ); 
    615615 
     
    706706    } 
    707707 
    708 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     708#elif defined( LIBVLC_USE_PTHREAD
    709709# ifndef __APPLE__ 
    710710    if( config_GetInt( p_this, "rt-priority" ) > 0 ) 
     
    838838    i_ret = (B_OK == wait_for_thread( p_priv->thread_id, &exit_value )); 
    839839 
    840 #elif defined( PTHREAD_COND_T_IN_PTHREAD_H
     840#elif defined( LIBVLC_USE_PTHREAD
    841841    i_ret = pthread_join( p_priv->thread_id, NULL ); 
    842842