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: Jeff Hostetler <jeffhost@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
May 21, 2019 at 12:33 UTC
5fdae9d3be45ce17e22b5f7a742cae3dfe687516
1 file changed
+9
-3
trace2/tr2_tls.c
+9
-3
@@ -47,7 +47,12 @@ struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name)
47
48
struct tr2tls_thread_ctx *tr2tls_get_self(void)
49
{
50
- struct tr2tls_thread_ctx *ctx = pthread_getspecific(tr2tls_key);
50
+ struct tr2tls_thread_ctx *ctx;
51
+
52
+ if (!HAVE_THREADS)
53
+ return tr2tls_thread_main;
54
+
55
+ ctx = pthread_getspecific(tr2tls_key);
56
57
/*
58
* 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)
67
68
int tr2tls_is_main_thread(void)
69
{
65
- struct tr2tls_thread_ctx *ctx = pthread_getspecific(tr2tls_key);
70
+ if (!HAVE_THREADS)
71
+ return 1;
72
67
- return ctx == tr2tls_thread_main;
73
+ return pthread_getspecific(tr2tls_key) == tr2tls_thread_main;
74
}
75
76
void tr2tls_unset_self(void)