*: check defined(_WIN32) instead of defined(WIN32)

Only _WIN32 is defined by the compiler, and WIN32 is not standardized
and may be missing.

Closes #169
This commit is contained in:
Max Kellermann
2017-12-12 10:22:20 +01:00
parent d9552d8a6d
commit dfaf08743c
91 changed files with 226 additions and 225 deletions

View File

@@ -30,7 +30,7 @@
#ifndef THREAD_COND_HXX
#define THREAD_COND_HXX
#ifdef WIN32
#ifdef _WIN32
#include "WindowsCond.hxx"
class Cond : public WindowsCond {};

View File

@@ -22,7 +22,7 @@
#include "Compiler.h"
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <pthread.h>
@@ -34,7 +34,7 @@
* debugging code.
*/
class ThreadId {
#ifdef WIN32
#ifdef _WIN32
DWORD id;
#else
pthread_t id;
@@ -46,7 +46,7 @@ public:
*/
ThreadId() = default;
#ifdef WIN32
#ifdef _WIN32
constexpr ThreadId(DWORD _id):id(_id) {}
#else
constexpr ThreadId(pthread_t _id):id(_id) {}
@@ -54,7 +54,7 @@ public:
gcc_const
static ThreadId Null() noexcept {
#ifdef WIN32
#ifdef _WIN32
return 0;
#else
static ThreadId null;
@@ -72,7 +72,7 @@ public:
*/
gcc_pure
static const ThreadId GetCurrent() noexcept {
#ifdef WIN32
#ifdef _WIN32
return ::GetCurrentThreadId();
#else
return pthread_self();
@@ -81,7 +81,7 @@ public:
gcc_pure
bool operator==(const ThreadId &other) const noexcept {
#ifdef WIN32
#ifdef _WIN32
return id == other.id;
#else
return pthread_equal(id, other.id);

View File

@@ -32,7 +32,7 @@
#include <mutex>
#ifdef WIN32
#ifdef _WIN32
#include "CriticalSection.hxx"
class Mutex : public CriticalSection {};

View File

@@ -33,7 +33,7 @@ Thread::Start(void (*_f)(void *ctx), void *_ctx)
f = _f;
ctx = _ctx;
#ifdef WIN32
#ifdef _WIN32
handle = ::CreateThread(nullptr, 0, ThreadProc, this, 0, &id);
if (handle == nullptr)
throw MakeLastError("Failed to create thread");
@@ -66,7 +66,7 @@ Thread::Join()
assert(IsDefined());
assert(!IsInside());
#ifdef WIN32
#ifdef _WIN32
::WaitForSingleObject(handle, INFINITE);
::CloseHandle(handle);
handle = nullptr;
@@ -76,7 +76,7 @@ Thread::Join()
#endif
}
#ifdef WIN32
#ifdef _WIN32
DWORD WINAPI
Thread::ThreadProc(LPVOID ctx)

View File

@@ -23,7 +23,7 @@
#include "check.h"
#include "Compiler.h"
#ifdef WIN32
#ifdef _WIN32
#include <windows.h>
#else
#include <pthread.h>
@@ -32,7 +32,7 @@
#include <assert.h>
class Thread {
#ifdef WIN32
#ifdef _WIN32
HANDLE handle = nullptr;
DWORD id;
#else
@@ -66,7 +66,7 @@ public:
#endif
bool IsDefined() const {
#ifdef WIN32
#ifdef _WIN32
return handle != nullptr;
#else
return defined;
@@ -78,7 +78,7 @@ public:
*/
gcc_pure
bool IsInside() const noexcept {
#ifdef WIN32
#ifdef _WIN32
return GetCurrentThreadId() == id;
#else
#ifdef NDEBUG
@@ -93,7 +93,7 @@ public:
void Join();
private:
#ifdef WIN32
#ifdef _WIN32
static DWORD WINAPI ThreadProc(LPVOID ctx);
#else
static void *ThreadProc(void *ctx);

View File

@@ -34,7 +34,7 @@
#include <sched.h>
#include <sys/syscall.h>
#include <unistd.h>
#elif defined(WIN32)
#elif defined(_WIN32)
#include <windows.h>
#endif
@@ -71,7 +71,7 @@ SetThreadIdlePriority()
ioprio_set_idle();
#elif defined(WIN32)
#elif defined(_WIN32)
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_IDLE);
#endif
};