From f81558c948e8dbc044176443c2455f6e2f3b5e08 Mon Sep 17 00:00:00 2001
From: Chris Robinson <chris.kcat@gmail.com>
Date: Sun, 28 Jun 2020 12:48:41 -0700
Subject: Avoid including windows.h in threads.h

---
 common/threads.cpp | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

(limited to 'common/threads.cpp')

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
 
-- 
cgit v1.2.3