summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Hostetler <jeffhost@microsoft.com>2019-05-21 19:33:59 (GMT)
committerJunio C Hamano <gitster@pobox.com>2019-05-28 17:52:34 (GMT)
commit5fdae9d3be45ce17e22b5f7a742cae3dfe687516 (patch)
treeb8d098c02499e6d8ca6b494eee58542927adfeb9
parentc173542c84cdf5e71b393e91f9d9664a85f995b2 (diff)
downloadgit-5fdae9d3be45ce17e22b5f7a742cae3dfe687516.zip
git-5fdae9d3be45ce17e22b5f7a742cae3dfe687516.tar.gz
git-5fdae9d3be45ce17e22b5f7a742cae3dfe687516.tar.bz2
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>
-rw-r--r--trace2/tr2_tls.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c
index 8e65b03..e0c4529 100644
--- a/trace2/tr2_tls.c
+++ b/trace2/tr2_tls.c
@@ -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)