From b3523e398cb3eb4b391d60183da6ce2ac959c212 Mon Sep 17 00:00:00 2001 From: "jani@ua141d10.elisa.omakaista.fi" <> Date: Tue, 30 Jan 2007 18:52:26 +0200 Subject: Cleanup of thread-type (linuxthread or NTPL) detection code Move get_thread_lib to mysys/my_pthread.c Set 'thr_client_alarm' to signal number used by thr_alarm to give alarms --- mysys/my_thr_init.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'mysys/my_thr_init.c') diff --git a/mysys/my_thr_init.c b/mysys/my_thr_init.c index 878a861bc94..5729f27b7a7 100644 --- a/mysys/my_thr_init.c +++ b/mysys/my_thr_init.c @@ -21,6 +21,7 @@ #include "mysys_priv.h" #include +#include #ifdef THREAD #ifdef USE_TLS @@ -44,6 +45,8 @@ pthread_mutexattr_t my_fast_mutexattr; pthread_mutexattr_t my_errchk_mutexattr; #endif +static uint get_thread_lib(void); + /* initialize thread environment @@ -57,6 +60,12 @@ pthread_mutexattr_t my_errchk_mutexattr; my_bool my_thread_global_init(void) { + thd_lib_detected= get_thread_lib(); + if (thd_lib_detected == THD_LIB_LT) + thr_client_alarm= SIGALRM; + else + thr_client_alarm= SIGUSR1; + if (pthread_key_create(&THR_KEY_mysys,0)) { fprintf(stderr,"Can't initialize threads: error %d\n",errno); @@ -276,4 +285,20 @@ const char *my_thread_name(void) } #endif /* DBUG_OFF */ + +static uint get_thread_lib(void) +{ + char buff[64]; + +#ifdef _CS_GNU_LIBPTHREAD_VERSION + confstr(_CS_GNU_LIBPTHREAD_VERSION, buff, sizeof(buff)); + + if (!strncasecmp(buff, "NPTL", 4)) + return THD_LIB_NPTL; + if (!strncasecmp(buff, "linuxthreads", 12)) + return THD_LIB_LT; +#endif + return THD_LIB_OTHER; +} + #endif /* THREAD */ -- cgit v1.2.1