aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/thread.cpp
diff options
context:
space:
mode:
authorthegeorg <thegeorg@yandex-team.ru>2022-02-10 16:45:08 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:08 +0300
commit4e839db24a3bbc9f1c610c43d6faaaa99824dcca (patch)
tree506dac10f5df94fab310584ee51b24fc5a081c22 /util/system/thread.cpp
parent2d37894b1b037cf24231090eda8589bbb44fb6fc (diff)
downloadydb-4e839db24a3bbc9f1c610c43d6faaaa99824dcca.tar.gz
Restoring authorship annotation for <thegeorg@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'util/system/thread.cpp')
-rw-r--r--util/system/thread.cpp70
1 files changed, 35 insertions, 35 deletions
diff --git a/util/system/thread.cpp b/util/system/thread.cpp
index 6236746c2d..8b56b2302c 100644
--- a/util/system/thread.cpp
+++ b/util/system/thread.cpp
@@ -9,21 +9,21 @@
#include "yassert.h"
#include <utility>
-#if defined(_glibc_)
- #if !__GLIBC_PREREQ(2, 30)
- #include <sys/syscall.h>
- #endif
-#endif
-
-#if defined(_unix_)
+#if defined(_glibc_)
+ #if !__GLIBC_PREREQ(2, 30)
+ #include <sys/syscall.h>
+ #endif
+#endif
+
+#if defined(_unix_)
#include <pthread.h>
- #include <sys/types.h>
-#elif defined(_win_)
+ #include <sys/types.h>
+#elif defined(_win_)
#include "dynlib.h"
#include <util/charset/wide.h>
#include <util/generic/scope.h>
-#else
- #error "FIXME"
+#else
+ #error "FIXME"
#endif
bool SetHighestThreadPriority() {
@@ -328,30 +328,30 @@ TThread::TId TThread::CurrentThreadId() noexcept {
return SystemCurrentThreadId();
}
-TThread::TId TThread::CurrentThreadNumericId() noexcept {
-#if defined(_win_)
- return GetCurrentThreadId();
-#elif defined(_darwin_)
- // There is no gettid() on MacOS and SYS_gettid returns completely unrelated numbers.
- // See: http://elliotth.blogspot.com/2012/04/gettid-on-mac-os.html
- uint64_t threadId;
- pthread_threadid_np(nullptr, &threadId);
- return threadId;
-#elif defined(_musl_) || defined(_bionic_)
- // both musl and android libc provide gettid() function
- return gettid();
-#elif defined(_glibc_)
- #if __GLIBC_PREREQ(2, 30)
- return gettid();
- #else
- // gettid() was introduced in glibc=2.30, previous versions lack neat syscall wrapper
- return syscall(SYS_gettid);
- #endif
-#else
- #error "Implement me"
-#endif
-}
-
+TThread::TId TThread::CurrentThreadNumericId() noexcept {
+#if defined(_win_)
+ return GetCurrentThreadId();
+#elif defined(_darwin_)
+ // There is no gettid() on MacOS and SYS_gettid returns completely unrelated numbers.
+ // See: http://elliotth.blogspot.com/2012/04/gettid-on-mac-os.html
+ uint64_t threadId;
+ pthread_threadid_np(nullptr, &threadId);
+ return threadId;
+#elif defined(_musl_) || defined(_bionic_)
+ // both musl and android libc provide gettid() function
+ return gettid();
+#elif defined(_glibc_)
+ #if __GLIBC_PREREQ(2, 30)
+ return gettid();
+ #else
+ // gettid() was introduced in glibc=2.30, previous versions lack neat syscall wrapper
+ return syscall(SYS_gettid);
+ #endif
+#else
+ #error "Implement me"
+#endif
+}
+
TThread::TId TThread::ImpossibleThreadId() noexcept {
return Max<TThread::TId>();
}