summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bx/src/mutex.cpp
diff options
context:
space:
mode:
author Branimir Karadžić <branimirkaradzic@gmail.com>2017-03-29 17:09:40 +0200
committer Miodrag Milanovic <mmicko@gmail.com>2017-03-29 17:09:40 +0200
commit49f7c99c7786ce257fae28dfeae2f8ee5810424c (patch)
tree1bbd30dd4dd48596186846c2fc77a8dc748215d2 /3rdparty/bx/src/mutex.cpp
parent79f22e060b2c012d628d5d1d83288c1bb6e6acef (diff)
Update BGFX and BX (nw)
Diffstat (limited to '3rdparty/bx/src/mutex.cpp')
-rw-r--r--3rdparty/bx/src/mutex.cpp42
1 files changed, 26 insertions, 16 deletions
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 <pthread.h>
-#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 <windows.h>
# include <errno.h>
#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