From ff0c7dabfed2a1ec18580961072dfd1e039a5dd2 Mon Sep 17 00:00:00 2001 From: Kovensky Date: Thu, 30 Jul 2009 19:39:29 -0300 Subject: [PATCH] Static pthread support Patch from http://oss.netfarm.it/mplayer/patches/xx_pthread_static.diff --- configure | 18 ++++++++++++++++-- mencoder.c | 14 ++++++++++++++ mplayer.c | 14 ++++++++++++++ 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/configure b/configure index a65abdeb9a..e69b478bd6 100755 --- a/configure +++ b/configure @@ -3346,7 +3346,16 @@ if test "$_pthreads" = auto ; then cat > $TMPC << EOF #include void* func(void *arg) { return arg; } -int main(void) { pthread_t tid; return pthread_create(&tid, 0, func, 0) == 0 ? 0 : 1; } +int main(void) { + pthread_t tid; + int res = 0; +#ifdef PTW32_STATIC_LIB + pthread_win32_process_attach_np(); + pthread_win32_thread_attach_np(); +#endif + res = pthread_create (&tid, 0, func, 0) == 0 ? 0 : 1; + return res; +} EOF _pthreads=no if ! hpux ; then @@ -3354,10 +3363,15 @@ if ! hpux ; then # for crosscompilation, we cannot execute the program, be happy if we can link statically cc_check $THREAD_CFLAGS $_ld_tmp && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && break done + # static pthreads on mingw32 + if test "$_pthreads" = no && mingw32 ; then + _ld_tmp="-lpthreadGC2 -lws2_32" + cc_check $_ld_tmp -DPTW32_STATIC_LIB && (tmp_run || test "$_ld_static") && _ld_pthread="$_ld_tmp" && _pthreads=yes && CFLAGS="$CFLAGS -DPTW32_STATIC_LIB" + fi fi fi if test "$_pthreads" = yes ; then - test $_ld_pthread && _res_comment="using $_ld_pthread" + test -n "$_ld_pthread" && _res_comment="using $_ld_pthread" def_pthreads='#define HAVE_PTHREADS 1' def_threads='#define HAVE_THREADS 1' extra_cflags="$extra_cflags $THREAD_CFLAGS" diff --git a/mencoder.c b/mencoder.c index 6627332c17..74364952bc 100644 --- a/mencoder.c +++ b/mencoder.c @@ -358,6 +358,14 @@ static muxer_t* muxer=NULL; void print_wave_header(WAVEFORMATEX *h, int verbose_level); +#ifdef PTW32_STATIC_LIB +static void detach_ptw32(void) +{ + pthread_win32_thread_detach_np(); + pthread_win32_process_detach_np(); +} +#endif + int main(int argc,char* argv[]){ stream_t* stream=NULL; @@ -405,6 +413,12 @@ ao_data_t ao_data = {0,0,0,0,OUTBURST,-1,0}; audio_encoding_params_t aparams; audio_encoder_t *aencoder = NULL; +#ifdef PTW32_STATIC_LIB + pthread_win32_process_attach_np(); + pthread_win32_thread_attach_np(); + atexit(detach_ptw32); +#endif + mp_msg_init(); // Create the config context and register the options diff --git a/mplayer.c b/mplayer.c index 5e49c7d424..fc6264c099 100644 --- a/mplayer.c +++ b/mplayer.c @@ -2823,6 +2823,14 @@ static int read_keys(void *ctx, int fd) } +#ifdef PTW32_STATIC_LIB +static void detach_ptw32(void) +{ + pthread_win32_thread_detach_np(); + pthread_win32_process_detach_np(); +} +#endif + /* This preprocessor directive is a hack to generate a mplayer-nomain.o object * file for some tools to link against. */ #ifndef DISABLE_MAIN @@ -2850,6 +2858,12 @@ int i; .last_dvb_step = 1, }; +#ifdef PTW32_STATIC_LIB + pthread_win32_process_attach_np(); + pthread_win32_thread_attach_np(); + atexit(detach_ptw32); +#endif + InitTimer(); srand(GetTimerMS()); -- 2.11.4.GIT