diff options
author | Chris Robinson <[email protected]> | 2020-06-28 12:48:41 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-06-28 12:55:55 -0700 |
commit | f81558c948e8dbc044176443c2455f6e2f3b5e08 (patch) | |
tree | 0da21d22244aefc40abb1ca5e02389272f6f84de | |
parent | 31791c9997d06a3a315d2b936515f643430cd5e9 (diff) |
Avoid including windows.h in threads.h
-rw-r--r-- | alc/alc.cpp | 5 | ||||
-rw-r--r-- | common/threads.cpp | 9 | ||||
-rw-r--r-- | common/threads.h | 9 |
3 files changed, 14 insertions, 9 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index e84b26e5..30d363af 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -22,6 +22,11 @@ #include "version.h" +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> +#endif + #include <exception> #include <algorithm> #include <array> diff --git a/common/threads.cpp b/common/threads.cpp index ff01de42..e3b715f0 100644 --- a/common/threads.cpp +++ b/common/threads.cpp @@ -20,12 +20,15 @@ #include "config.h" +#include "opthelpers.h" #include "threads.h" #include <system_error> #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include <windows.h> #include <limits> @@ -73,15 +76,15 @@ semaphore::~semaphore() void semaphore::post() { - if(!ReleaseSemaphore(mSem, 1, nullptr)) + if UNLIKELY(!ReleaseSemaphore(static_cast<HANDLE>(mSem), 1, nullptr)) throw std::system_error(std::make_error_code(std::errc::value_too_large)); } void semaphore::wait() noexcept -{ WaitForSingleObject(mSem, INFINITE); } +{ WaitForSingleObject(static_cast<HANDLE>(mSem), INFINITE); } bool semaphore::try_wait() noexcept -{ return WaitForSingleObject(mSem, 0) == WAIT_OBJECT_0; } +{ return WaitForSingleObject(static_cast<HANDLE>(mSem), 0) == WAIT_OBJECT_0; } } // namespace al diff --git a/common/threads.h b/common/threads.h index ff571a66..1cdb5d8f 100644 --- a/common/threads.h +++ b/common/threads.h @@ -11,12 +11,9 @@ #define FORCE_ALIGN #endif -#ifdef _WIN32 -#define WIN32_LEAN_AND_MEAN -#include <windows.h> -#elif defined(__APPLE__) +#if defined(__APPLE__) #include <dispatch/dispatch.h> -#else +#elif !defined(_WIN32) #include <semaphore.h> #endif @@ -26,7 +23,7 @@ namespace al { class semaphore { #ifdef _WIN32 - using native_type = HANDLE; + using native_type = void*; #elif defined(__APPLE__) using native_type = dispatch_semaphore_t; #else |