diff options
author | Jiang Xin <worldhello.net@gmail.com> | 2019-05-31 14:34:26 +0800 |
---|---|---|
committer | Jiang Xin <worldhello.net@gmail.com> | 2019-05-31 14:34:26 +0800 |
commit | a17177ce3ac74afc0b2e6fc6c80c1e1991b96a13 (patch) | |
tree | 0ff1a62d28a13bc8d8708148b85d3b0ba2632f92 /trace2/tr2_tls.c | |
parent | Merge branch 'master' of https://github.com/Softcatala/git-po (diff) | |
parent | Git 2.22-rc2 (diff) | |
download | tgif-a17177ce3ac74afc0b2e6fc6c80c1e1991b96a13.tar.xz |
Merge branch 'master' of git://git.kernel.org/pub/scm/git/git
* 'master' of git://git.kernel.org/pub/scm/git/git: (66 commits)
Git 2.22-rc2
...
Diffstat (limited to 'trace2/tr2_tls.c')
-rw-r--r-- | trace2/tr2_tls.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/trace2/tr2_tls.c b/trace2/tr2_tls.c index e76d8c5d92..067c23755f 100644 --- a/trace2/tr2_tls.c +++ b/trace2/tr2_tls.c @@ -61,7 +61,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 @@ -76,9 +81,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) |