X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fthreads.c;h=d2e0f220d769bce15c34935cb12ca259e8413cfe;hb=434c630cf7aa4b4facc1d2fcfb6e9bc4cf21dff1;hp=f5e828f313adecb9e9ef02ec368e841fcb90ac65;hpb=887aca53efaf08a47dc4c4fba867d5816538e841;p=libucw.git diff --git a/lib/threads.c b/lib/threads.c index f5e828f3..d2e0f220 100644 --- a/lib/threads.c +++ b/lib/threads.c @@ -14,6 +14,15 @@ #include +#ifdef CONFIG_LINUX +#include +#include +#ifdef __NR_gettid +static _syscall0(pid_t, gettid) +#define CONFIG_USE_GETTID +#endif +#endif + static pthread_key_t ucwlib_context_key; static pthread_mutex_t ucwlib_master_mutex; @@ -35,9 +44,17 @@ static int ucwlib_tid(void) { static int tid_counter; + int tid; + +#ifdef CONFIG_USE_GETTID + tid = gettid(); + if (tid > 0) + return tid; + /* The syscall might be unimplemented */ +#endif ucwlib_lock(); - int tid = ++tid_counter; + tid = ++tid_counter; ucwlib_unlock(); return tid; }