From dafa6bff2e62072e6ba0b48250b079cb37abd7c2 Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Tue, 11 Jan 2022 13:24:53 +0100 Subject: [PATCH] Add inlined current thread id on Linux and Android --- Source/Engine/Platform/Android/AndroidPlatform.cpp | 5 ----- Source/Engine/Platform/Android/AndroidPlatform.h | 6 +++++- Source/Engine/Platform/Linux/LinuxPlatform.cpp | 6 ------ Source/Engine/Platform/Linux/LinuxPlatform.h | 6 +++++- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/Source/Engine/Platform/Android/AndroidPlatform.cpp b/Source/Engine/Platform/Android/AndroidPlatform.cpp index 4dd8a7174..eb2c277f3 100644 --- a/Source/Engine/Platform/Android/AndroidPlatform.cpp +++ b/Source/Engine/Platform/Android/AndroidPlatform.cpp @@ -709,11 +709,6 @@ ProcessMemoryStats AndroidPlatform::GetProcessMemoryStats() return result; } -uint64 AndroidPlatform::GetCurrentThreadID() -{ - return static_cast(pthread_self()); -} - void AndroidPlatform::SetThreadPriority(ThreadPriority priority) { // TODO: impl this diff --git a/Source/Engine/Platform/Android/AndroidPlatform.h b/Source/Engine/Platform/Android/AndroidPlatform.h index 85988b019..219c415b7 100644 --- a/Source/Engine/Platform/Android/AndroidPlatform.h +++ b/Source/Engine/Platform/Android/AndroidPlatform.h @@ -5,6 +5,7 @@ #if PLATFORM_ANDROID #include "Engine/Platform/Unix/UnixPlatform.h" +#include struct android_app; @@ -83,7 +84,10 @@ public: static int32 GetCacheLineSize(); static MemoryStats GetMemoryStats(); static ProcessMemoryStats GetProcessMemoryStats(); - static uint64 GetCurrentThreadID(); + static uint64 GetCurrentThreadID() + { + return static_cast(pthread_self()); + } static void SetThreadPriority(ThreadPriority priority); static void SetThreadAffinityMask(uint64 affinityMask); static void Sleep(int32 milliseconds); diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.cpp b/Source/Engine/Platform/Linux/LinuxPlatform.cpp index 9b2756454..401690d16 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.cpp +++ b/Source/Engine/Platform/Linux/LinuxPlatform.cpp @@ -215,7 +215,6 @@ static int X11_MessageBoxInit(MessageBoxData* data) LINUX_DIALOG_PRINT("Couldn't load font %s", MessageBoxFont); data->font_set = X11::XCreateFontSet(data->display, "fixed", &missing, &num_missing, NULL); if (missing != nullptr) X11::XFreeStringList(missing); - //return 1; } return 0; @@ -1792,11 +1791,6 @@ ProcessMemoryStats LinuxPlatform::GetProcessMemoryStats() return result; } -uint64 LinuxPlatform::GetCurrentThreadID() -{ - return static_cast(pthread_self()); -} - void LinuxPlatform::SetThreadPriority(ThreadPriority priority) { // TODO: impl this diff --git a/Source/Engine/Platform/Linux/LinuxPlatform.h b/Source/Engine/Platform/Linux/LinuxPlatform.h index 6e1e9e356..64e8707e8 100644 --- a/Source/Engine/Platform/Linux/LinuxPlatform.h +++ b/Source/Engine/Platform/Linux/LinuxPlatform.h @@ -5,6 +5,7 @@ #if PLATFORM_LINUX #include "Engine/Platform/Unix/UnixPlatform.h" +#include /// /// The Linux platform implementation and application management utilities. @@ -92,7 +93,10 @@ public: static int32 GetCacheLineSize(); static MemoryStats GetMemoryStats(); static ProcessMemoryStats GetProcessMemoryStats(); - static uint64 GetCurrentThreadID(); + static uint64 GetCurrentThreadID() + { + return static_cast(pthread_self()); + } static void SetThreadPriority(ThreadPriority priority); static void SetThreadAffinityMask(uint64 affinityMask); static void Sleep(int32 milliseconds);