From 55c75d2c873885cfda9b21cfc011855ef1f68520 Mon Sep 17 00:00:00 2001 From: Nekotekina Date: Sat, 6 Mar 2021 20:10:48 +0300 Subject: [PATCH] Implement thread_ctrl::get_tid() --- Utilities/Thread.cpp | 9 +++++++++ Utilities/Thread.h | 3 +++ 2 files changed, 12 insertions(+) diff --git a/Utilities/Thread.cpp b/Utilities/Thread.cpp index 92d2ffcf69..a74fbba6c9 100644 --- a/Utilities/Thread.cpp +++ b/Utilities/Thread.cpp @@ -2978,3 +2978,12 @@ std::pair thread_ctrl::get_thread_stack() #endif return {saddr, ssize}; } + +u64 thread_ctrl::get_tid() +{ +#ifdef _WIN32 + return GetCurrentThreadId(); +#else + return reinterpret_cast(pthread_self()); +#endif +} diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 929324de4c..abcc0bc8ff 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -339,6 +339,9 @@ public: } }; + // Get thread ID (works for all threads) + static u64 get_tid(); + private: // Miscellaneous static const u64 process_affinity_mask;