From 49f7c99c7786ce257fae28dfeae2f8ee5810424c Mon Sep 17 00:00:00 2001 From: Branimir Karadžić Date: Wed, 29 Mar 2017 17:09:40 +0200 Subject: Update BGFX and BX (nw) --- 3rdparty/bx/src/mutex.cpp | 42 ++++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) (limited to '3rdparty/bx/src/mutex.cpp') diff --git a/3rdparty/bx/src/mutex.cpp b/3rdparty/bx/src/mutex.cpp index 00e517684e2..988084bbf0b 100644 --- a/3rdparty/bx/src/mutex.cpp +++ b/3rdparty/bx/src/mutex.cpp @@ -7,17 +7,19 @@ #if BX_CONFIG_SUPPORTS_THREADING -#if 0 \ - || BX_PLATFORM_ANDROID \ - || BX_PLATFORM_LINUX \ - || BX_PLATFORM_NACL \ - || BX_PLATFORM_IOS \ - || BX_PLATFORM_OSX +#if BX_PLATFORM_ANDROID \ + || BX_PLATFORM_LINUX \ + || BX_PLATFORM_NACL \ + || BX_PLATFORM_IOS \ + || BX_PLATFORM_OSX \ + || BX_PLATFORM_PS4 \ + || BX_PLATFORM_RPI # include -#elif 0 \ - || BX_PLATFORM_WINDOWS \ - || BX_PLATFORM_WINRT \ - || BX_PLATFORM_XBOX360 +#elif BX_PLATFORM_WINDOWS \ + || BX_PLATFORM_WINRT \ + || BX_PLATFORM_XBOX360 \ + || BX_PLATFORM_XBOXONE +# include # include #endif // BX_PLATFORM_ @@ -50,7 +52,7 @@ namespace bx InitializeCriticalSectionEx(_mutex, 4000, 0); // docs recommend 4000 spincount as sane default #else InitializeCriticalSection(_mutex); -#endif +#endif // BX_PLATFORM_ return 0; } @@ -63,28 +65,36 @@ namespace bx Mutex::Mutex() { + BX_STATIC_ASSERT(sizeof(pthread_mutex_t) <= sizeof(m_internal) ); + pthread_mutexattr_t attr; + #if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE || BX_PLATFORM_WINRT #else pthread_mutexattr_init(&attr); pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); -#endif // BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_WINRT - pthread_mutex_init(&m_handle, &attr); +#endif // BX_PLATFORM_ + + pthread_mutex_t* handle = (pthread_mutex_t*)m_internal; + pthread_mutex_init(handle, &attr); } Mutex::~Mutex() { - pthread_mutex_destroy(&m_handle); + pthread_mutex_t* handle = (pthread_mutex_t*)m_internal; + pthread_mutex_destroy(handle); } void Mutex::lock() { - pthread_mutex_lock(&m_handle); + pthread_mutex_t* handle = (pthread_mutex_t*)m_internal; + pthread_mutex_lock(handle); } void Mutex::unlock() { - pthread_mutex_unlock(&m_handle); + pthread_mutex_t* handle = (pthread_mutex_t*)m_internal; + pthread_mutex_unlock(handle); } } // namespace bx -- cgit v1.2.3-70-g09d2