|
@@ -25,23 +25,6 @@
|
|
|
|
|
|
|
|
namespace Common {
|
|
namespace Common {
|
|
|
|
|
|
|
|
-int CurrentThreadId() {
|
|
|
|
|
-#ifdef _MSC_VER
|
|
|
|
|
- return GetCurrentThreadId();
|
|
|
|
|
-#elif defined __APPLE__
|
|
|
|
|
- return mach_thread_self();
|
|
|
|
|
-#else
|
|
|
|
|
- return 0;
|
|
|
|
|
-#endif
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-#ifdef _WIN32
|
|
|
|
|
-// Supporting functions
|
|
|
|
|
-void SleepCurrentThread(int ms) {
|
|
|
|
|
- Sleep(ms);
|
|
|
|
|
-}
|
|
|
|
|
-#endif
|
|
|
|
|
-
|
|
|
|
|
#ifdef _MSC_VER
|
|
#ifdef _MSC_VER
|
|
|
|
|
|
|
|
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) {
|
|
void SetThreadAffinity(std::thread::native_handle_type thread, u32 mask) {
|
|
@@ -62,7 +45,7 @@ void SwitchCurrentThread() {
|
|
|
|
|
|
|
|
// This is implemented much nicer in upcoming msvc++, see:
|
|
// This is implemented much nicer in upcoming msvc++, see:
|
|
|
// http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx
|
|
// http://msdn.microsoft.com/en-us/library/xcb2z8hs(VS.100).aspx
|
|
|
-void SetCurrentThreadName(const char* szThreadName) {
|
|
|
|
|
|
|
+void SetCurrentThreadName(const char* name) {
|
|
|
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
|
static const DWORD MS_VC_EXCEPTION = 0x406D1388;
|
|
|
|
|
|
|
|
#pragma pack(push, 8)
|
|
#pragma pack(push, 8)
|
|
@@ -75,7 +58,7 @@ void SetCurrentThreadName(const char* szThreadName) {
|
|
|
#pragma pack(pop)
|
|
#pragma pack(pop)
|
|
|
|
|
|
|
|
info.dwType = 0x1000;
|
|
info.dwType = 0x1000;
|
|
|
- info.szName = szThreadName;
|
|
|
|
|
|
|
+ info.szName = name;
|
|
|
info.dwThreadID = -1; // dwThreadID;
|
|
info.dwThreadID = -1; // dwThreadID;
|
|
|
info.dwFlags = 0;
|
|
info.dwFlags = 0;
|
|
|
|
|
|
|
@@ -107,10 +90,6 @@ void SetCurrentThreadAffinity(u32 mask) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
#ifndef _WIN32
|
|
|
-void SleepCurrentThread(int ms) {
|
|
|
|
|
- usleep(1000 * ms);
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
void SwitchCurrentThread() {
|
|
void SwitchCurrentThread() {
|
|
|
usleep(1000 * 1);
|
|
usleep(1000 * 1);
|
|
|
}
|
|
}
|
|
@@ -118,15 +97,15 @@ void SwitchCurrentThread() {
|
|
|
|
|
|
|
|
// MinGW with the POSIX threading model does not support pthread_setname_np
|
|
// MinGW with the POSIX threading model does not support pthread_setname_np
|
|
|
#if !defined(_WIN32) || defined(_MSC_VER)
|
|
#if !defined(_WIN32) || defined(_MSC_VER)
|
|
|
-void SetCurrentThreadName(const char* szThreadName) {
|
|
|
|
|
|
|
+void SetCurrentThreadName(const char* name) {
|
|
|
#ifdef __APPLE__
|
|
#ifdef __APPLE__
|
|
|
- pthread_setname_np(szThreadName);
|
|
|
|
|
|
|
+ pthread_setname_np(name);
|
|
|
#elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
|
#elif defined(__Bitrig__) || defined(__DragonFly__) || defined(__FreeBSD__) || defined(__OpenBSD__)
|
|
|
- pthread_set_name_np(pthread_self(), szThreadName);
|
|
|
|
|
|
|
+ pthread_set_name_np(pthread_self(), name);
|
|
|
#elif defined(__NetBSD__)
|
|
#elif defined(__NetBSD__)
|
|
|
- pthread_setname_np(pthread_self(), "%s", (void*)szThreadName);
|
|
|
|
|
|
|
+ pthread_setname_np(pthread_self(), "%s", (void*)name);
|
|
|
#else
|
|
#else
|
|
|
- pthread_setname_np(pthread_self(), szThreadName);
|
|
|
|
|
|
|
+ pthread_setname_np(pthread_self(), name);
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
#endif
|
|
#endif
|