mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 16:22:00 +00:00
Bug 1841030
- cache the thread id in thread-local storage r=profiler-reviewers,canaltinova
Differential Revision: https://phabricator.services.mozilla.com/D205838
This commit is contained in:
parent
a7cc2c512a
commit
2332065828
@ -102,8 +102,12 @@ BaseProfilerThreadId profiler_current_thread_id() {
|
||||
namespace mozilla::baseprofiler {
|
||||
|
||||
BaseProfilerThreadId profiler_current_thread_id() {
|
||||
// glibc doesn't provide a wrapper for gettid() until 2.30
|
||||
return BaseProfilerThreadId::FromNativeId(syscall(SYS_gettid));
|
||||
static thread_local pid_t tid;
|
||||
if (!tid) {
|
||||
// glibc doesn't provide a wrapper for gettid() until 2.30
|
||||
tid = static_cast<pid_t>(syscall(SYS_gettid));
|
||||
}
|
||||
return BaseProfilerThreadId::FromNativeId(tid);
|
||||
}
|
||||
|
||||
} // namespace mozilla::baseprofiler
|
||||
|
@ -67,8 +67,12 @@ ProfilerThreadId profiler_current_thread_id() {
|
||||
# include <sys/syscall.h>
|
||||
|
||||
ProfilerThreadId profiler_current_thread_id() {
|
||||
// glibc doesn't provide a wrapper for gettid() until 2.30
|
||||
return ProfilerThreadId::FromNativeId(syscall(SYS_gettid));
|
||||
static thread_local pid_t tid;
|
||||
if (!tid) {
|
||||
// glibc doesn't provide a wrapper for gettid() until 2.30
|
||||
tid = static_cast<pid_t>(syscall(SYS_gettid));
|
||||
}
|
||||
return ProfilerThreadId::FromNativeId(tid);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------- FreeBSD
|
||||
|
Loading…
Reference in New Issue
Block a user