Skip to content

Commit 9a1430e

Browse files
committed
Merge branch 'jh/trace2' into jch
* jh/trace2: trace2: fix tracing when NO_PTHREADS is defined
2 parents 5cd4d19 + 5fdae9d commit 9a1430e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

trace2/tr2_tls.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,12 @@ struct tr2tls_thread_ctx *tr2tls_create_self(const char *thread_name,
6161

6262
struct tr2tls_thread_ctx *tr2tls_get_self(void)
6363
{
64-
struct tr2tls_thread_ctx *ctx = pthread_getspecific(tr2tls_key);
64+
struct tr2tls_thread_ctx *ctx;
65+
66+
if (!HAVE_THREADS)
67+
return tr2tls_thread_main;
68+
69+
ctx = pthread_getspecific(tr2tls_key);
6570

6671
/*
6772
* If the thread-proc did not call trace2_thread_start(), we won't
@@ -76,9 +81,10 @@ struct tr2tls_thread_ctx *tr2tls_get_self(void)
7681

7782
int tr2tls_is_main_thread(void)
7883
{
79-
struct tr2tls_thread_ctx *ctx = pthread_getspecific(tr2tls_key);
84+
if (!HAVE_THREADS)
85+
return 1;
8086

81-
return ctx == tr2tls_thread_main;
87+
return pthread_getspecific(tr2tls_key) == tr2tls_thread_main;
8288
}
8389

8490
void tr2tls_unset_self(void)

0 commit comments

Comments
 (0)