提交 5fdae9d3 编写于 作者: J Jeff Hostetler 提交者: Junio C Hamano

trace2: fix tracing when NO_PTHREADS is defined

Teach trace2 TLS code to not rely on pthread_getspecific() when NO_PTHREADS
is defined.  Instead, always assume the context data of the main thread.
Signed-off-by: NJeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 c173542c
......@@ -47,7 +47,12 @@ struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name)
struct tr2tls_thread_ctx *tr2tls_get_self(void)
{
struct tr2tls_thread_ctx *ctx = pthread_getspecific(tr2tls_key);
struct tr2tls_thread_ctx *ctx;
if (!HAVE_THREADS)
return tr2tls_thread_main;
ctx = pthread_getspecific(tr2tls_key);
/*
* If the thread-proc did not call trace2_thread_start(), we won't
......@@ -62,9 +67,10 @@ struct tr2tls_thread_ctx *tr2tls_get_self(void)
int tr2tls_is_main_thread(void)
{
struct tr2tls_thread_ctx *ctx = pthread_getspecific(tr2tls_key);
if (!HAVE_THREADS)
return 1;
return ctx == tr2tls_thread_main;
return pthread_getspecific(tr2tls_key) == tr2tls_thread_main;
}
void tr2tls_unset_self(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册