X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=ucw%2Fthreads.c;h=d9100119f601210692f59e6c58b4704c4dac2a85;hb=b8667492cf36a609939ee35ac42900ff0b0cc80f;hp=f0c701403eae4de819cd1aa96718cce3ea567fd0;hpb=30680da0fe1192be08f2ff02d912e3b8a0f1212f;p=libucw.git diff --git a/ucw/threads.c b/ucw/threads.c index f0c70140..d9100119 100644 --- a/ucw/threads.c +++ b/ucw/threads.c @@ -7,8 +7,8 @@ * of the GNU Lesser General Public License. */ -#include "ucw/lib.h" -#include "ucw/threads.h" +#include +#include #ifdef CONFIG_UCW_THREADS @@ -67,6 +67,12 @@ ucwlib_tid(void) /*** Thread context ***/ +static void CONSTRUCTOR_WITH_PRIORITY(10000) +ucwlib_threads_init_master(void) +{ + pthread_mutex_init(&ucwlib_master_mutex, NULL); +} + #ifdef CONFIG_UCW_TLS __thread struct ucwlib_context ucwlib_context; @@ -89,12 +95,11 @@ ucwlib_free_thread_context(void *p) xfree(p); } -static void CONSTRUCTOR +static void CONSTRUCTOR_WITH_PRIORITY(10000) ucwlib_threads_init(void) { if (pthread_key_create(&ucwlib_context_key, ucwlib_free_thread_context) < 0) die("Cannot create pthread_key: %m"); - pthread_mutex_init(&ucwlib_master_mutex, NULL); } struct ucwlib_context * @@ -114,7 +119,7 @@ ucwlib_thread_context(void) #else /* !CONFIG_UCW_THREADS */ -struct ucwlib_context default_ucwlib_context; +struct ucwlib_context ucwlib_default_context; #endif