diff options
author | jani@ua141d10.elisa.omakaista.fi <> | 2007-01-30 18:52:26 +0200 |
---|---|---|
committer | jani@ua141d10.elisa.omakaista.fi <> | 2007-01-30 18:52:26 +0200 |
commit | b3523e398cb3eb4b391d60183da6ce2ac959c212 (patch) | |
tree | bf4ddf26e334366c90958a67e6d3c8c1ad3c0cd6 /mysys/my_thr_init.c | |
parent | ff58749b290dc8f5f8e78ce7b5a73d7efecc610a (diff) | |
download | mariadb-git-b3523e398cb3eb4b391d60183da6ce2ac959c212.tar.gz |
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
Diffstat (limited to 'mysys/my_thr_init.c')
-rw-r--r-- | mysys/my_thr_init.c | 25 |
1 files changed, 25 insertions, 0 deletions
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 <m_string.h> +#include <signal.h> #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 */ |