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;