mirror of
https://github.com/minetest/minetest.git
synced 2024-11-23 08:03:45 +01:00
Fix native thread handle usage on win32
This commit is contained in:
parent
8674dc831d
commit
7c7ae79f9f
@ -59,6 +59,8 @@ DEALINGS IN THE SOFTWARE.
|
||||
#include <mach/thread_act.h>
|
||||
#endif
|
||||
|
||||
// See https://msdn.microsoft.com/en-us/library/hh920601.aspx#thread__native_handle_method
|
||||
#define win32_native_handle() ((HANDLE) getThreadHandle())
|
||||
|
||||
Thread::Thread(const std::string &name) :
|
||||
m_name(name),
|
||||
@ -81,9 +83,8 @@ Thread::~Thread()
|
||||
m_running = false;
|
||||
|
||||
#if defined(_WIN32)
|
||||
// See https://msdn.microsoft.com/en-us/library/hh920601.aspx#thread__native_handle_method
|
||||
TerminateThread((HANDLE) m_thread_obj->native_handle(), 0);
|
||||
CloseHandle((HANDLE) m_thread_obj->native_handle());
|
||||
TerminateThread(win32_native_handle(), 0);
|
||||
CloseHandle(win32_native_handle());
|
||||
#else
|
||||
// We need to pthread_kill instead on Android since NDKv5's pthread
|
||||
// implementation is incomplete.
|
||||
@ -261,13 +262,9 @@ bool Thread::bindToProcessor(unsigned int proc_number)
|
||||
|
||||
return false;
|
||||
|
||||
#elif _MSC_VER
|
||||
#elif defined(_WIN32)
|
||||
|
||||
return SetThreadAffinityMask(getThreadHandle(), 1 << proc_number);
|
||||
|
||||
#elif __MINGW32__
|
||||
|
||||
return SetThreadAffinityMask(pthread_gethandle(getThreadHandle()), 1 << proc_number);
|
||||
return SetThreadAffinityMask(win32_native_handle(), 1 << proc_number);
|
||||
|
||||
#elif __FreeBSD_version >= 702106 || defined(__linux__) || defined(__DragonFly__)
|
||||
|
||||
@ -320,13 +317,9 @@ bool Thread::bindToProcessor(unsigned int proc_number)
|
||||
|
||||
bool Thread::setPriority(int prio)
|
||||
{
|
||||
#ifdef _MSC_VER
|
||||
#ifdef _WIN32
|
||||
|
||||
return SetThreadPriority(getThreadHandle(), prio);
|
||||
|
||||
#elif __MINGW32__
|
||||
|
||||
return SetThreadPriority(pthread_gethandle(getThreadHandle()), prio);
|
||||
return SetThreadPriority(win32_native_handle(), prio);
|
||||
|
||||
#else
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user