mirror of
https://github.com/bkaradzic/bx.git
synced 2026-02-18 04:53:06 +01:00
Cleanup.
This commit is contained in:
@@ -6,7 +6,10 @@
|
||||
#include "bx_p.h"
|
||||
#include <bx/thread.h>
|
||||
|
||||
#if BX_PLATFORM_ANDROID \
|
||||
#if BX_CONFIG_SUPPORTS_THREADING
|
||||
|
||||
#if BX_CRT_NONE
|
||||
#elif BX_PLATFORM_ANDROID \
|
||||
|| BX_PLATFORM_LINUX \
|
||||
|| BX_PLATFORM_IOS \
|
||||
|| BX_PLATFORM_OSX \
|
||||
@@ -32,8 +35,6 @@ using namespace Windows::System::Threading;
|
||||
# endif // BX_PLATFORM_WINRT
|
||||
#endif // BX_PLATFORM_
|
||||
|
||||
#if BX_CONFIG_SUPPORTS_THREADING
|
||||
|
||||
namespace bx
|
||||
{
|
||||
static AllocatorI* getAllocator()
|
||||
@@ -44,7 +45,9 @@ namespace bx
|
||||
|
||||
struct ThreadInternal
|
||||
{
|
||||
#if BX_PLATFORM_WINDOWS \
|
||||
#if BX_CRT_NONE
|
||||
static void* threadFunc(void* _arg);
|
||||
#elif BX_PLATFORM_WINDOWS \
|
||||
|| BX_PLATFORM_WINRT \
|
||||
|| BX_PLATFORM_XBOXONE
|
||||
static DWORD WINAPI threadFunc(LPVOID _arg);
|
||||
@@ -90,7 +93,9 @@ namespace bx
|
||||
BX_STATIC_ASSERT(sizeof(ThreadInternal) <= sizeof(m_internal) );
|
||||
|
||||
ThreadInternal* ti = (ThreadInternal*)m_internal;
|
||||
#if BX_PLATFORM_WINDOWS \
|
||||
#if BX_CRT_NONE
|
||||
BX_UNUSED(ti);
|
||||
#elif BX_PLATFORM_WINDOWS \
|
||||
|| BX_PLATFORM_WINRT \
|
||||
|| BX_PLATFORM_XBOXONE
|
||||
ti->m_handle = INVALID_HANDLE_VALUE;
|
||||
@@ -118,7 +123,9 @@ namespace bx
|
||||
m_running = true;
|
||||
|
||||
ThreadInternal* ti = (ThreadInternal*)m_internal;
|
||||
#if BX_PLATFORM_WINDOWS \
|
||||
#if BX_CRT_NONE
|
||||
BX_UNUSED(ti);
|
||||
#elif BX_PLATFORM_WINDOWS \
|
||||
|| BX_PLATFORM_XBOXONE
|
||||
ti->m_handle = ::CreateThread(NULL
|
||||
, m_stackSize
|
||||
@@ -170,7 +177,9 @@ namespace bx
|
||||
{
|
||||
BX_CHECK(m_running, "Not running!");
|
||||
ThreadInternal* ti = (ThreadInternal*)m_internal;
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
#if BX_CRT_NONE
|
||||
BX_UNUSED(ti);
|
||||
#elif BX_PLATFORM_WINDOWS
|
||||
WaitForSingleObject(ti->m_handle, INFINITE);
|
||||
GetExitCodeThread(ti->m_handle, (DWORD*)&m_exitCode);
|
||||
CloseHandle(ti->m_handle);
|
||||
@@ -207,18 +216,21 @@ namespace bx
|
||||
{
|
||||
ThreadInternal* ti = (ThreadInternal*)m_internal;
|
||||
BX_UNUSED(ti);
|
||||
#if BX_PLATFORM_OSX || BX_PLATFORM_IOS
|
||||
#if BX_CRT_NONE
|
||||
BX_UNUSED(_name);
|
||||
#elif BX_PLATFORM_OSX \
|
||||
|| BX_PLATFORM_IOS
|
||||
pthread_setname_np(_name);
|
||||
#elif (BX_CRT_GLIBC >= 21200) && ! BX_PLATFORM_HURD
|
||||
pthread_setname_np(ti->m_handle, _name);
|
||||
#elif BX_PLATFORM_LINUX
|
||||
prctl(PR_SET_NAME,_name, 0, 0, 0);
|
||||
#elif BX_PLATFORM_BSD
|
||||
# ifdef __NetBSD__
|
||||
# if defined(__NetBSD__)
|
||||
pthread_setname_np(ti->m_handle, "%s", (void*)_name);
|
||||
# else
|
||||
pthread_set_name_np(ti->m_handle, _name);
|
||||
# endif // __NetBSD__
|
||||
# endif // defined(__NetBSD__)
|
||||
#elif BX_PLATFORM_WINDOWS && BX_COMPILER_MSVC
|
||||
# pragma pack(push, 8)
|
||||
struct ThreadName
|
||||
@@ -276,14 +288,42 @@ namespace bx
|
||||
|
||||
struct TlsDataInternal
|
||||
{
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
#if BX_CRT_NONE
|
||||
#elif BX_PLATFORM_WINDOWS
|
||||
uint32_t m_id;
|
||||
#elif !(BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT)
|
||||
pthread_key_t m_id;
|
||||
#endif // BX_PLATFORM_*
|
||||
};
|
||||
|
||||
#if BX_PLATFORM_WINDOWS
|
||||
#if BX_CRT_NONE
|
||||
TlsData::TlsData()
|
||||
{
|
||||
BX_STATIC_ASSERT(sizeof(TlsDataInternal) <= sizeof(m_internal) );
|
||||
|
||||
TlsDataInternal* ti = (TlsDataInternal*)m_internal;
|
||||
BX_UNUSED(ti);
|
||||
}
|
||||
|
||||
TlsData::~TlsData()
|
||||
{
|
||||
TlsDataInternal* ti = (TlsDataInternal*)m_internal;
|
||||
BX_UNUSED(ti);
|
||||
}
|
||||
|
||||
void* TlsData::get() const
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void TlsData::set(void* _ptr)
|
||||
{
|
||||
BX_UNUSED(_ptr);
|
||||
|
||||
TlsDataInternal* ti = (TlsDataInternal*)m_internal;
|
||||
BX_UNUSED(ti);
|
||||
}
|
||||
#elif BX_PLATFORM_WINDOWS
|
||||
TlsData::TlsData()
|
||||
{
|
||||
BX_STATIC_ASSERT(sizeof(TlsDataInternal) <= sizeof(m_internal) );
|
||||
|
||||
Reference in New Issue
Block a user