Attempt to fix Linux

This commit is contained in:
Daniel R. 2024-10-30 16:46:01 +01:00 committed by IndecisiveTurtle
parent d0f427721c
commit ecf2dbbb37
2 changed files with 10 additions and 4 deletions

View file

@ -11,7 +11,7 @@
namespace Core {
Thread::Thread() : native_handle{nullptr} {}
Thread::Thread() : native_handle{0} {}
Thread::~Thread() {}
@ -20,7 +20,7 @@ int Thread::Create(ThreadFunc func, void* arg) {
native_handle = CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)func, arg, 0, nullptr);
return native_handle ? 0 : -1;
#else
pthread_t* pthr = reinterpret_cast<pthread_t*>(native_handle);
pthread_t* pthr = reinterpret_cast<pthread_t*>(&native_handle);
pthread_attr_t pattr;
pthread_attr_init(&pattr);
return pthread_create(pthr, &pattr, (PthreadFunc)func, arg);

View file

@ -3,6 +3,8 @@
#pragma once
#include "common/types.h"
namespace Core {
class Thread {
@ -16,12 +18,16 @@ public:
int Create(ThreadFunc func, void* arg);
void Exit();
void* GetHandle() {
return native_handle;
uintptr_t GetHandle() {
return reinterpret_cast<uintptr_t>(native_handle);
}
private:
#if _WIN64
void* native_handle;
#else
uintptr_t native_handle;
#endif
};
} // namespace Core