WIN32 macro -> _WIN32

This commit is contained in:
Connor McLaughlin 2021-06-28 20:16:48 +10:00
parent 489de3f9ce
commit 911e9a37f1
41 changed files with 123 additions and 123 deletions

View file

@ -3,7 +3,7 @@
TEST(FileSystem, IsAbsolutePath)
{
#ifdef WIN32
#ifdef _WIN32
ASSERT_TRUE(FileSystem::IsAbsolutePath("C:\\"));
ASSERT_TRUE(FileSystem::IsAbsolutePath("C:\\Path"));
ASSERT_TRUE(FileSystem::IsAbsolutePath("C:\\Path\\Subdirectory"));

View file

@ -3,7 +3,7 @@
#include <cstdlib>
#include <mutex>
#ifdef WIN32
#ifdef _WIN32
#include "windows_headers.h"
#include <intrin.h>
#include <tlhelp32.h>
@ -13,7 +13,7 @@ static std::mutex s_AssertFailedMutex;
static inline void FreezeThreads(void** ppHandle)
{
#ifdef WIN32
#ifdef _WIN32
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
if (hSnapshot != INVALID_HANDLE_VALUE)
{
@ -43,7 +43,7 @@ static inline void FreezeThreads(void** ppHandle)
static inline void ResumeThreads(void* pHandle)
{
#ifdef WIN32
#ifdef _WIN32
HANDLE hSnapshot = (HANDLE)pHandle;
if (pHandle != INVALID_HANDLE_VALUE)
{
@ -79,7 +79,7 @@ void Y_OnAssertFailed(const char* szMessage, const char* szFunction, const char*
char szMsg[512];
std::snprintf(szMsg, sizeof(szMsg), "%s in function %s (%s:%u)", szMessage, szFunction, szFile, uLine);
#ifdef WIN32
#ifdef _WIN32
SetConsoleTextAttribute(GetStdHandle(STD_ERROR_HANDLE), FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
WriteConsoleA(GetStdHandle(STD_ERROR_HANDLE), szMsg, static_cast<DWORD>(std::strlen(szMsg)), NULL, NULL);
OutputDebugStringA(szMsg);
@ -114,7 +114,7 @@ void Y_OnPanicReached(const char* szMessage, const char* szFunction, const char*
char szMsg[512];
std::snprintf(szMsg, sizeof(szMsg), "%s in function %s (%s:%u)", szMessage, szFunction, szFile, uLine);
#ifdef WIN32
#ifdef _WIN32
SetConsoleTextAttribute(GetStdHandle(STD_ERROR_HANDLE), FOREGROUND_BLUE | FOREGROUND_GREEN | FOREGROUND_INTENSITY);
WriteConsoleA(GetStdHandle(STD_ERROR_HANDLE), szMsg, static_cast<DWORD>(std::strlen(szMsg)), NULL, NULL);
OutputDebugStringA(szMsg);

View file

@ -9,7 +9,7 @@
#include <cstdlib>
#include <cstring>
#include <sys/stat.h>
#if defined(WIN32)
#if defined(_WIN32)
#include "windows_headers.h"
#include <direct.h>
#include <io.h>
@ -118,7 +118,7 @@ public:
return true;
}
#if defined(WIN32)
#if defined(_WIN32)
virtual bool SeekAbsolute(u64 Offset) override
{
@ -265,7 +265,7 @@ public:
{
if (m_discarded)
{
#if WIN32
#if _WIN32
// delete the temporary file
if (!DeleteFileW(StringUtil::UTF8StringToWideString(m_temporaryFileName).c_str()))
{
@ -308,7 +308,7 @@ public:
fflush(m_pFile);
#ifdef WIN32
#ifdef _WIN32
// move the atomic file name to the original file name
if (!MoveFileExW(StringUtil::UTF8StringToWideString(m_temporaryFileName).c_str(),
StringUtil::UTF8StringToWideString(m_originalFileName).c_str(), MOVEFILE_REPLACE_EXISTING))
@ -975,7 +975,7 @@ std::unique_ptr<ByteStream> ByteStream_OpenFileStream(const char* fileName, u32
}
// append platform path seperator
#if defined(WIN32)
#if defined(_WIN32)
tempStr[i] = '\\';
#else
tempStr[i] = '/';
@ -1119,7 +1119,7 @@ std::unique_ptr<ByteStream> ByteStream_OpenFileStream(const char* fileName, u32
const u32 fileNameLength = static_cast<u32>(std::strlen(fileName));
char* tempStr = (char*)alloca(fileNameLength + 1);
#if defined(WIN32)
#if defined(_WIN32)
// check if it starts with a drive letter. if so, skip ahead
if (fileNameLength >= 2 && fileName[1] == ':')
{
@ -1156,7 +1156,7 @@ std::unique_ptr<ByteStream> ByteStream_OpenFileStream(const char* fileName, u32
if (errno == ENOENT)
{
// try creating it
#if defined(WIN32)
#if defined(_WIN32)
if (mkdir(tempStr) < 0)
#else
if (mkdir(tempStr, 0777) < 0)
@ -1175,7 +1175,7 @@ std::unique_ptr<ByteStream> ByteStream_OpenFileStream(const char* fileName, u32
}
// append platform path seperator
#if defined(WIN32)
#if defined(_WIN32)
tempStr[i] = '\\';
#else
tempStr[i] = '/';

View file

@ -1,7 +1,7 @@
#include "event.h"
#include "assert.h"
#if defined(WIN32)
#if defined(_WIN32)
#include "windows_headers.h"
#include <malloc.h>
#elif defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
@ -11,7 +11,7 @@
namespace Common {
#if defined(WIN32) && defined(USE_WIN32_EVENT_OBJECTS)
#if defined(_WIN32) && defined(USE_WIN32_EVENT_OBJECTS)
Event::Event(bool auto_reset /* = false */)
{
@ -55,7 +55,7 @@ void Event::WaitForMultiple(Event** events, u32 num_events)
WaitForMultipleObjects(num_events, event_handles, TRUE, INFINITE);
}
#elif defined(WIN32)
#elif defined(_WIN32)
Event::Event(bool auto_reset /* = false */) : m_auto_reset(auto_reset)
{

View file

@ -3,7 +3,7 @@
// #define USE_WIN32_EVENT_OBJECTS 1
#if defined(WIN32) && !defined(USE_WIN32_EVENT_OBJECTS)
#if defined(_WIN32) && !defined(USE_WIN32_EVENT_OBJECTS)
#include "windows_headers.h"
#include <atomic>
#elif defined(__linux__) || defined(__APPLE__) || defined(__HAIKU__)
@ -31,9 +31,9 @@ public:
static void WaitForMultiple(Event** events, u32 num_events);
private:
#if defined(WIN32) && defined(USE_WIN32_EVENT_OBJECTS)
#if defined(_WIN32) && defined(USE_WIN32_EVENT_OBJECTS)
void* m_event_handle;
#elif defined(WIN32)
#elif defined(_WIN32)
CRITICAL_SECTION m_cs;
CONDITION_VARIABLE m_cv;
std::atomic_uint32_t m_waiters{0};

View file

@ -19,7 +19,7 @@
#include <sys/sysctl.h>
#endif
#if defined(WIN32)
#if defined(_WIN32)
#include <shlobj.h>
#else
#include <dirent.h>
@ -573,7 +573,7 @@ void SanitizeFileName(std::string& Destination, bool StripSlashes /* = true*/)
bool IsAbsolutePath(const std::string_view& path)
{
#ifdef WIN32
#ifdef _WIN32
return (path.length() >= 3 && ((path[0] >= 'A' && path[0] <= 'Z') || (path[0] >= 'a' && path[0] <= 'z')) &&
path[1] == ':' && (path[2] == '/' || path[2] == '\\'));
#else
@ -713,7 +713,7 @@ std::vector<std::string> GetRootDirectoryList()
{
std::vector<std::string> results;
#ifdef WIN32
#ifdef _WIN32
char buf[256];
if (GetLogicalDriveStringsA(sizeof(buf), buf) != 0)
{
@ -774,7 +774,7 @@ FileSystem::ManagedCFilePtr OpenManagedCFile(const char* filename, const char* m
std::FILE* OpenCFile(const char* filename, const char* mode)
{
#ifdef WIN32
#ifdef _WIN32
int filename_len = static_cast<int>(std::strlen(filename));
int mode_len = static_cast<int>(std::strlen(mode));
int wlen = MultiByteToWideChar(CP_UTF8, 0, filename, filename_len, nullptr, 0);

View file

@ -9,7 +9,7 @@
class ByteStream;
#ifdef WIN32
#ifdef _WIN32
#define FS_OSPATH_SEPARATOR_CHARACTER '\\'
#define FS_OSPATH_SEPARATOR_STR "\\"
#else

View file

@ -9,7 +9,7 @@
#endif
Log_SetChannel(GL::Context);
#if defined(WIN32) && !defined(_M_ARM64)
#if defined(_WIN32) && !defined(_M_ARM64)
#include "context_wgl.h"
#elif defined(__APPLE__) && !defined(LIBERTRO)
#include "context_agl.h"
@ -97,7 +97,7 @@ std::unique_ptr<GL::Context> Context::Create(const WindowInfo& wi, const Version
}
std::unique_ptr<Context> context;
#if defined(WIN32) && !defined(_M_ARM64)
#if defined(_WIN32) && !defined(_M_ARM64)
context = ContextWGL::Create(wi, versions_to_try, num_versions_to_try);
#elif defined(__APPLE__)
context = ContextAGL::Create(wi, versions_to_try, num_versions_to_try);

View file

@ -67,7 +67,7 @@ public:
static const std::array<Version, 16>& GetAllVersionsList();
protected:
#ifdef WIN32
#ifdef _WIN32
#endif
WindowInfo m_wi;

View file

@ -6,7 +6,7 @@
#include <algorithm>
Log_SetChannel(JitCodeBuffer);
#if defined(WIN32)
#if defined(_WIN32)
#include "windows_headers.h"
#else
#include <errno.h>
@ -43,7 +43,7 @@ bool JitCodeBuffer::Allocate(u32 size /* = 64 * 1024 * 1024 */, u32 far_code_siz
m_total_size = size + far_code_size;
#if defined(WIN32)
#if defined(_WIN32)
m_code_ptr = static_cast<u8*>(VirtualAlloc(nullptr, m_total_size, MEM_COMMIT, PAGE_EXECUTE_READWRITE));
if (!m_code_ptr)
{
@ -88,7 +88,7 @@ bool JitCodeBuffer::Initialize(void* buffer, u32 size, u32 far_code_size /* = 0
if ((far_code_size > 0 && guard_size >= far_code_size) || (far_code_size + (guard_size * 2)) > size)
return false;
#if defined(WIN32)
#if defined(_WIN32)
DWORD old_protect = 0;
if (!VirtualProtect(buffer, size, PAGE_EXECUTE_READWRITE, &old_protect))
{
@ -156,7 +156,7 @@ void JitCodeBuffer::Destroy()
{
if (m_owns_buffer)
{
#if defined(WIN32)
#if defined(_WIN32)
VirtualFree(m_code_ptr, 0, MEM_RELEASE);
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__) || defined(__FreeBSD__)
munmap(m_code_ptr, m_total_size);
@ -164,7 +164,7 @@ void JitCodeBuffer::Destroy()
}
else if (m_code_ptr)
{
#if defined(WIN32)
#if defined(_WIN32)
DWORD old_protect = 0;
VirtualProtect(m_code_ptr, m_total_size, m_old_protection, &old_protect);
#else
@ -237,7 +237,7 @@ void JitCodeBuffer::Align(u32 alignment, u8 padding_value)
void JitCodeBuffer::FlushInstructionCache(void* address, u32 size)
{
#if defined(WIN32)
#if defined(_WIN32)
::FlushInstructionCache(GetCurrentProcess(), address, size);
#elif defined(__GNUC__) || defined(__clang__)
__builtin___clear_cache(reinterpret_cast<char*>(address), reinterpret_cast<char*>(address) + size);

View file

@ -7,7 +7,7 @@
#include <mutex>
#include <vector>
#if defined(WIN32)
#if defined(_WIN32)
#include "windows_headers.h"
#elif defined(__ANDROID__)
#include <android/log.h>
@ -531,7 +531,7 @@ void Writev(const char* channelName, const char* functionName, LOGLEVEL level, c
va_list apCopy;
va_copy(apCopy, ap);
#ifdef WIN32
#ifdef _WIN32
u32 requiredSize = static_cast<u32>(_vscprintf(format, apCopy));
#else
u32 requiredSize = std::vsnprintf(nullptr, 0, format, apCopy);

View file

@ -4,7 +4,7 @@
#include "common/string_util.h"
Log_SetChannel(Common::MemoryArena);
#if defined(WIN32)
#if defined(_WIN32)
#include "common/windows_headers.h"
#elif defined(ANDROID)
#include <dlfcn.h>
@ -69,7 +69,7 @@ MemoryArena::~MemoryArena()
void* MemoryArena::FindBaseAddressForMapping(size_t size)
{
void* base_address;
#if defined(WIN32)
#if defined(_WIN32)
base_address = VirtualAlloc(nullptr, size, MEM_RESERVE, PAGE_READWRITE);
if (base_address)
VirtualFree(base_address, 0, MEM_RELEASE);
@ -96,7 +96,7 @@ void* MemoryArena::FindBaseAddressForMapping(size_t size)
bool MemoryArena::IsValid() const
{
#if defined(WIN32)
#if defined(_WIN32)
return m_file_handle != nullptr;
#else
return m_shmem_fd >= 0;
@ -217,7 +217,7 @@ bool MemoryArena::Create(size_t size, bool writable, bool executable)
void MemoryArena::Destroy()
{
#if defined(WIN32)
#if defined(_WIN32)
if (m_file_handle)
{
CloseHandle(m_file_handle);
@ -255,7 +255,7 @@ void* MemoryArena::CreateViewPtr(size_t offset, size_t size, bool writable, bool
void* fixed_address /*= nullptr*/)
{
void* base_pointer;
#if defined(WIN32)
#if defined(_WIN32)
const DWORD desired_access = FILE_MAP_READ | (writable ? FILE_MAP_WRITE : 0) | (executable ? FILE_MAP_EXECUTE : 0);
base_pointer =
MapViewOfFileEx(m_file_handle, desired_access, Truncate32(offset >> 32), Truncate32(offset), size, fixed_address);
@ -277,7 +277,7 @@ void* MemoryArena::CreateViewPtr(size_t offset, size_t size, bool writable, bool
bool MemoryArena::FlushViewPtr(void* address, size_t size)
{
#if defined(WIN32)
#if defined(_WIN32)
return FlushViewOfFile(address, size);
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
return (msync(address, size, 0) >= 0);
@ -289,7 +289,7 @@ bool MemoryArena::FlushViewPtr(void* address, size_t size)
bool MemoryArena::ReleaseViewPtr(void* address, size_t size)
{
bool result;
#if defined(WIN32)
#if defined(_WIN32)
result = static_cast<bool>(UnmapViewOfFile(address));
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
result = (munmap(address, size) >= 0);
@ -311,7 +311,7 @@ bool MemoryArena::ReleaseViewPtr(void* address, size_t size)
void* MemoryArena::CreateReservedPtr(size_t size, void* fixed_address /*= nullptr*/)
{
void* base_pointer;
#if defined(WIN32)
#if defined(_WIN32)
base_pointer = VirtualAlloc(fixed_address, size, MEM_RESERVE, PAGE_NOACCESS);
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
const int flags =
@ -330,7 +330,7 @@ void* MemoryArena::CreateReservedPtr(size_t size, void* fixed_address /*= nullpt
bool MemoryArena::ReleaseReservedPtr(void* address, size_t size)
{
bool result;
#if defined(WIN32)
#if defined(_WIN32)
result = static_cast<bool>(VirtualFree(address, 0, MEM_RELEASE));
#elif defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
result = (munmap(address, size) >= 0);
@ -351,7 +351,7 @@ bool MemoryArena::ReleaseReservedPtr(void* address, size_t size)
bool MemoryArena::SetPageProtection(void* address, size_t length, bool readable, bool writable, bool executable)
{
#if defined(WIN32)
#if defined(_WIN32)
static constexpr DWORD protection_table[2][2][2] = {
{{PAGE_NOACCESS, PAGE_EXECUTE}, {PAGE_WRITECOPY, PAGE_EXECUTE_WRITECOPY}},
{{PAGE_READONLY, PAGE_EXECUTE_READ}, {PAGE_READWRITE, PAGE_EXECUTE_READWRITE}}};

View file

@ -60,7 +60,7 @@ public:
static bool SetPageProtection(void* address, size_t length, bool readable, bool writable, bool executable);
private:
#if defined(WIN32)
#if defined(_WIN32)
void* m_file_handle = nullptr;
#elif defined(__linux__) || defined(ANDROID) || defined(__APPLE__) || defined(__FreeBSD__)
int m_shmem_fd = -1;

View file

@ -7,7 +7,7 @@
#include <vector>
Log_SetChannel(Common::PageFaultHandler);
#if defined(WIN32)
#if defined(_WIN32)
#include "windows_headers.h"
#elif defined(__linux__) || defined(__ANDROID__)
#include <signal.h>
@ -78,7 +78,7 @@ static bool IsStoreInstruction(const void* ptr)
}
#endif
#if defined(WIN32) && (defined(CPU_X64) || defined(CPU_AARCH64))
#if defined(_WIN32) && (defined(CPU_X64) || defined(CPU_AARCH64))
static PVOID s_veh_handle;
static LONG ExceptionHandler(PEXCEPTION_POINTERS exi)
@ -222,7 +222,7 @@ bool InstallHandler(void* owner, Callback callback)
if (was_empty)
{
#if defined(WIN32) && (defined(CPU_X64) || defined(CPU_AARCH64))
#if defined(_WIN32) && (defined(CPU_X64) || defined(CPU_AARCH64))
s_veh_handle = AddVectoredExceptionHandler(1, ExceptionHandler);
if (!s_veh_handle)
{
@ -279,7 +279,7 @@ bool RemoveHandler(void* owner)
if (m_handlers.empty())
{
#if defined(WIN32) && (defined(CPU_X64) || defined(CPU_AARCH64))
#if defined(_WIN32) && (defined(CPU_X64) || defined(CPU_AARCH64))
RemoveVectoredExceptionHandler(s_veh_handle);
s_veh_handle = nullptr;
#elif defined(USE_SIGSEGV)

View file

@ -4,7 +4,7 @@
#include <cstdio>
#include <sstream>
#ifdef WIN32
#ifdef _WIN32
#include "windows_headers.h"
#endif
@ -24,7 +24,7 @@ std::string StdStringFromFormatV(const char* format, std::va_list ap)
std::va_list ap_copy;
va_copy(ap_copy, ap);
#ifdef WIN32
#ifdef _WIN32
int len = _vscprintf(format, ap_copy);
#else
int len = std::vsnprintf(nullptr, 0, format, ap_copy);
@ -190,7 +190,7 @@ std::string EncodeHex(const u8* data, int length)
return ss.str();
}
#ifdef WIN32
#ifdef _WIN32
std::wstring UTF8StringToWideString(const std::string_view& str)
{

View file

@ -160,7 +160,7 @@ ALWAYS_INLINE static int StrideMemCmp(const void* p1, std::size_t p1_stride, con
return 0;
}
#ifdef WIN32
#ifdef _WIN32
/// Converts the specified UTF-8 string to a wide string.
std::wstring UTF8StringToWideString(const std::string_view& str);

View file

@ -2,7 +2,7 @@
#include <cstdio>
#include <cstdlib>
#ifdef WIN32
#ifdef _WIN32
#include "windows_headers.h"
#else
#include <sys/time.h>
@ -12,7 +12,7 @@
namespace Common {
#ifdef WIN32
#ifdef _WIN32
static double s_counter_frequency;
static bool s_counter_initialized = false;
@ -250,7 +250,7 @@ void Timer::HybridSleep(std::uint64_t ns, std::uint64_t min_sleep_time)
void Timer::NanoSleep(std::uint64_t ns)
{
#if defined(WIN32)
#if defined(_WIN32)
HANDLE timer = GetSleepTimer();
if (timer)
{

View file

@ -2,7 +2,7 @@
#include <cstring>
#include <ctime>
#if defined(WIN32)
#if defined(_WIN32)
static void UnixTimeToSystemTime(time_t t, LPSYSTEMTIME pst);
static time_t SystemTimeToUnixTime(const SYSTEMTIME* pst);
@ -11,7 +11,7 @@ static time_t SystemTimeToUnixTime(const SYSTEMTIME* pst);
Timestamp::Timestamp()
{
#if defined(WIN32)
#if defined(_WIN32)
m_value.wYear = 1970;
m_value.wMonth = 1;
m_value.wDayOfWeek = 0;
@ -28,7 +28,7 @@ Timestamp::Timestamp()
Timestamp::Timestamp(const Timestamp& copy)
{
#if defined(WIN32)
#if defined(_WIN32)
std::memcpy(&m_value, &copy.m_value, sizeof(m_value));
#else
std::memcpy(&m_value, &copy.m_value, sizeof(m_value));
@ -37,7 +37,7 @@ Timestamp::Timestamp(const Timestamp& copy)
double Timestamp::DifferenceInSeconds(Timestamp& other) const
{
#if defined(WIN32)
#if defined(_WIN32)
FILETIME lft, rft;
SystemTimeToFileTime(&m_value, &lft);
SystemTimeToFileTime(&other.m_value, &rft);
@ -55,7 +55,7 @@ double Timestamp::DifferenceInSeconds(Timestamp& other) const
s64 Timestamp::DifferenceInSecondsInt(Timestamp& other) const
{
#if defined(WIN32)
#if defined(_WIN32)
FILETIME lft, rft;
SystemTimeToFileTime(&m_value, &lft);
SystemTimeToFileTime(&other.m_value, &rft);
@ -72,7 +72,7 @@ s64 Timestamp::DifferenceInSecondsInt(Timestamp& other) const
Timestamp::UnixTimestampValue Timestamp::AsUnixTimestamp() const
{
#if defined(WIN32)
#if defined(_WIN32)
return (UnixTimestampValue)SystemTimeToUnixTime(&m_value);
#else
return (UnixTimestampValue)m_value.tv_sec;
@ -83,7 +83,7 @@ Timestamp::ExpandedTime Timestamp::AsExpandedTime() const
{
ExpandedTime et;
#if defined(WIN32)
#if defined(_WIN32)
et.Year = m_value.wYear;
et.Month = m_value.wMonth;
et.DayOfMonth = m_value.wDay;
@ -111,7 +111,7 @@ Timestamp::ExpandedTime Timestamp::AsExpandedTime() const
void Timestamp::SetNow()
{
#if defined(WIN32)
#if defined(_WIN32)
GetSystemTime(&m_value);
#else
gettimeofday(&m_value, NULL);
@ -120,7 +120,7 @@ void Timestamp::SetNow()
void Timestamp::SetUnixTimestamp(UnixTimestampValue value)
{
#if defined(WIN32)
#if defined(_WIN32)
UnixTimeToSystemTime((time_t)value, &m_value);
#else
m_value.tv_sec = (time_t)value;
@ -130,7 +130,7 @@ void Timestamp::SetUnixTimestamp(UnixTimestampValue value)
void Timestamp::SetExpandedTime(const ExpandedTime& value)
{
#if defined(WIN32)
#if defined(_WIN32)
// bit of a hacky way to fill in the missing fields
SYSTEMTIME st;
st.wYear = (WORD)value.Year;
@ -170,7 +170,7 @@ void Timestamp::ToString(String& destination, const char* format) const
time_t unixTime = (time_t)AsUnixTimestamp();
tm localTime;
#if defined(WIN32)
#if defined(_WIN32)
localtime_s(&localTime, &unixTime);
#else
localtime_r(&unixTime, &localTime);
@ -207,7 +207,7 @@ Timestamp Timestamp::FromExpandedTime(const ExpandedTime& value)
bool Timestamp::operator==(const Timestamp& other) const
{
#if defined(WIN32)
#if defined(_WIN32)
return std::memcmp(&m_value, &other.m_value, sizeof(m_value)) == 0;
#else
return std::memcmp(&m_value, &other.m_value, sizeof(m_value)) == 0;
@ -221,7 +221,7 @@ bool Timestamp::operator!=(const Timestamp& other) const
bool Timestamp::operator<(const Timestamp& other) const
{
#if defined(WIN32)
#if defined(_WIN32)
if (m_value.wYear > other.m_value.wYear)
return false;
@ -279,7 +279,7 @@ bool Timestamp::operator<(const Timestamp& other) const
bool Timestamp::operator<=(const Timestamp& other) const
{
#if defined(WIN32)
#if defined(_WIN32)
if (m_value.wYear > other.m_value.wYear)
return false;
@ -337,7 +337,7 @@ bool Timestamp::operator<=(const Timestamp& other) const
bool Timestamp::operator>(const Timestamp& other) const
{
#if defined(WIN32)
#if defined(_WIN32)
if (m_value.wYear < other.m_value.wYear)
return false;
@ -395,7 +395,7 @@ bool Timestamp::operator>(const Timestamp& other) const
bool Timestamp::operator>=(const Timestamp& other) const
{
#if defined(WIN32)
#if defined(_WIN32)
if (m_value.wYear < other.m_value.wYear)
return false;
@ -453,7 +453,7 @@ bool Timestamp::operator>=(const Timestamp& other) const
Timestamp& Timestamp::operator=(const Timestamp& other)
{
#if defined(WIN32)
#if defined(_WIN32)
std::memcpy(&m_value, &other.m_value, sizeof(m_value));
#else
std::memcpy(&m_value, &other.m_value, sizeof(m_value));
@ -462,7 +462,7 @@ Timestamp& Timestamp::operator=(const Timestamp& other)
return *this;
}
#if defined(WIN32)
#if defined(_WIN32)
// http://support.microsoft.com/kb/167296
static void UnixTimeToFileTime(time_t t, LPFILETIME pft)

View file

@ -2,7 +2,7 @@
#include "types.h"
#include "string.h"
#if defined(WIN32)
#if defined(_WIN32)
#include "windows_headers.h"
#else
#include <sys/time.h>
@ -51,7 +51,7 @@ public:
static Timestamp FromExpandedTime(const ExpandedTime& value);
// windows-specific
#ifdef WIN32
#ifdef _WIN32
FILETIME AsFileTime();
void SetWindowsFileTime(const FILETIME* pFileTime);
static Timestamp FromWindowsFileTime(const FILETIME* pFileTime);
@ -67,7 +67,7 @@ public:
Timestamp& operator=(const Timestamp& other);
private:
#if defined(WIN32)
#if defined(_WIN32)
SYSTEMTIME m_value;
#else
struct timeval m_value;

View file

@ -5,7 +5,7 @@
#if defined(CPU_X64)
// We need to include windows.h before xbyak does..
#ifdef WIN32
#ifdef _WIN32
#include "common/windows_headers.h"
#endif
@ -81,7 +81,7 @@ constexpr u32 MAX_FAR_HOST_BYTES_PER_INSTRUCTION = 128;
constexpr u32 CODE_STORAGE_ALIGNMENT = 4096;
// ABI selection
#if defined(WIN32)
#if defined(_WIN32)
#define ABI_WIN64 1
#elif defined(__linux__) || defined(__ANDROID__) || defined(__APPLE__) || defined(__HAIKU__) || defined(__FreeBSD__)
#define ABI_SYSV 1

View file

@ -650,12 +650,12 @@ const char* Settings::GetCPUFastmemModeDisplayName(CPUFastmemMode mode)
}
static constexpr auto s_gpu_renderer_names = make_array(
#ifdef WIN32
#ifdef _WIN32
"D3D11",
#endif
"Vulkan", "OpenGL", "Software");
static constexpr auto s_gpu_renderer_display_names = make_array(
#ifdef WIN32
#ifdef _WIN32
TRANSLATABLE("GPURenderer", "Hardware (D3D11)"),
#endif
TRANSLATABLE("GPURenderer", "Hardware (Vulkan)"), TRANSLATABLE("GPURenderer", "Hardware (OpenGL)"),

View file

@ -1008,7 +1008,7 @@ bool CreateGPU(GPURenderer renderer)
g_gpu = GPU::CreateHardwareVulkanRenderer();
break;
#ifdef WIN32
#ifdef _WIN32
case GPURenderer::HardwareD3D11:
g_gpu = GPU::CreateHardwareD3D11Renderer();
break;

View file

@ -183,7 +183,7 @@ bool TextureReplacements::ParseReplacementFilename(const std::string& filename,
{
const char* extension = std::strrchr(filename.c_str(), '.');
const char* title = std::strrchr(filename.c_str(), '/');
#ifdef WIN32
#ifdef _WIN32
const char* title2 = std::strrchr(filename.c_str(), '\\');
if (title2 && (!title || title2 > title))
title = title2;

View file

@ -54,7 +54,7 @@ enum class PGXPMode : u8
enum class GPURenderer : u8
{
#ifdef WIN32
#ifdef _WIN32
HardwareD3D11,
#endif
HardwareVulkan,

View file

@ -22,7 +22,7 @@
#include <cmath>
Log_SetChannel(NoGUIHostInterface);
#ifdef WIN32
#ifdef _WIN32
#include "frontend-common/d3d11_host_display.h"
#endif
@ -97,13 +97,13 @@ bool NoGUIHostInterface::CreateDisplay(bool fullscreen)
break;
case GPURenderer::HardwareOpenGL:
#ifndef WIN32
#ifndef _WIN32
default:
#endif
m_display = std::make_unique<FrontendCommon::OpenGLHostDisplay>();
break;
#ifdef WIN32
#ifdef _WIN32
case GPURenderer::HardwareD3D11:
default:
m_display = std::make_unique<FrontendCommon::D3D11HostDisplay>();
@ -151,7 +151,7 @@ bool NoGUIHostInterface::AcquireHostDisplay()
bool needs_switch = false;
switch (g_settings.gpu_renderer)
{
#ifdef WIN32
#ifdef _WIN32
case GPURenderer::HardwareD3D11:
needs_switch = (render_api != HostDisplay::RenderAPI::D3D11);
break;

View file

@ -25,7 +25,7 @@ Log_SetChannel(AutoUpdaterDialog);
// Logic to detect whether we can use the auto updater.
// Currently Windows-only, and requires that the channel be defined by the buildbot.
#ifdef WIN32
#ifdef _WIN32
#if defined(__has_include) && __has_include("scmversion/tag.h")
#include "scmversion/tag.h"
#ifdef SCM_RELEASE_TAGS
@ -444,7 +444,7 @@ void AutoUpdaterDialog::remindMeLaterClicked()
done(0);
}
#ifdef WIN32
#ifdef _WIN32
bool AutoUpdaterDialog::processUpdate(const QByteArray& update_data)
{

View file

@ -44,7 +44,7 @@ private:
bool updateNeeded() const;
std::string getCurrentUpdateTag() const;
#ifdef WIN32
#ifdef _WIN32
bool processUpdate(const QByteArray& update_data);
bool extractUpdater(const QString& zip_path, const QString& destination_path);
bool doUpdate(const QString& zip_path, const QString& updater_path, const QString& destination_path);

View file

@ -359,7 +359,7 @@ void DebuggerWindow::closeEvent(QCloseEvent* event)
void DebuggerWindow::setupAdditionalUi()
{
#ifdef WIN32
#ifdef _WIN32
QFont fixedFont;
fixedFont.setFamily(QStringLiteral("Consolas"));
fixedFont.setFixedPitch(true);

View file

@ -9,7 +9,7 @@
// For enumerating adapters.
#include "frontend-common/vulkan_host_display.h"
#ifdef WIN32
#ifdef _WIN32
#include "frontend-common/d3d11_host_display.h"
#endif
@ -202,7 +202,7 @@ void DisplaySettingsWidget::populateGPUAdaptersAndResolutions()
bool threaded_presentation_supported = false;
switch (static_cast<GPURenderer>(m_ui.renderer->currentIndex()))
{
#ifdef WIN32
#ifdef _WIN32
case GPURenderer::HardwareD3D11:
aml = FrontendCommon::D3D11HostDisplay::StaticGetAdapterAndModeList();
break;

View file

@ -1626,7 +1626,7 @@ void MainWindow::checkForUpdates(bool display_message)
mbox.setTextFormat(Qt::RichText);
QString message;
#ifdef WIN32
#ifdef _WIN32
message =
tr("<p>Sorry, you are trying to update a DuckStation version which is not an official GitHub release. To "
"prevent incompatibilities, the auto-updater is only enabled on official builds.</p>"

View file

@ -10,7 +10,7 @@
#include <QtGui/QWindowStateChangeEvent>
#include <cmath>
#if !defined(WIN32) && !defined(APPLE)
#if !defined(_WIN32) && !defined(APPLE)
#include <qpa/qplatformnativeinterface.h>
#endif
@ -56,7 +56,7 @@ std::optional<WindowInfo> QtDisplayWidget::getWindowInfo() const
WindowInfo wi;
// Windows and Apple are easy here since there's no display connection.
#if defined(WIN32)
#if defined(_WIN32)
wi.type = WindowInfo::Type::Win32;
wi.window_handle = reinterpret_cast<void*>(winId());
#elif defined(__APPLE__)

View file

@ -39,7 +39,7 @@
#include <memory>
Log_SetChannel(QtHostInterface);
#ifdef WIN32
#ifdef _WIN32
#include "common/windows_headers.h"
#include "frontend-common/d3d11_host_display.h"
#include <KnownFolders.h>
@ -570,13 +570,13 @@ HostDisplay* QtHostInterface::createHostDisplay()
break;
case GPURenderer::HardwareOpenGL:
#ifndef WIN32
#ifndef _WIN32
default:
#endif
m_display = std::make_unique<FrontendCommon::OpenGLHostDisplay>();
break;
#ifdef WIN32
#ifdef _WIN32
case GPURenderer::HardwareD3D11:
default:
m_display = std::make_unique<FrontendCommon::D3D11HostDisplay>();
@ -1616,7 +1616,7 @@ void QtHostInterface::wakeThread()
static std::string GetFontPath(const char* name)
{
#ifdef WIN32
#ifdef _WIN32
PWSTR folder_path;
if (FAILED(SHGetKnownFolderPath(FOLDERID_Fonts, 0, nullptr, &folder_path)))
return StringUtil::StdStringFromFormat("C:\\Windows\\Fonts\\%s", name);
@ -1637,7 +1637,7 @@ void QtHostInterface::setImGuiFont()
std::string path;
const ImWchar* range = nullptr;
#ifdef WIN32
#ifdef _WIN32
if (language == "ja")
{
path = GetFontPath("msgothic.ttc");

View file

@ -51,7 +51,7 @@
#include "cheevos.h"
#endif
#ifdef WIN32
#ifdef _WIN32
#include "common/windows_headers.h"
#include <KnownFolders.h>
#include <ShlObj.h>
@ -926,7 +926,7 @@ void CommonHostInterface::SetUserDirectory()
}
else
{
#if defined(WIN32)
#if defined(_WIN32)
// On Windows, use My Documents\DuckStation.
PWSTR documents_directory;
if (SUCCEEDED(SHGetKnownFolderPath(FOLDERID_Documents, 0, NULL, &documents_directory)))
@ -3092,7 +3092,7 @@ void CommonHostInterface::SetTimerResolutionIncreased(bool enabled)
m_timer_resolution_increased = enabled;
#ifdef WIN32
#ifdef _WIN32
if (enabled)
timeBeginPeriod(1);
else

View file

@ -109,7 +109,7 @@ static constexpr std::array<const char*, static_cast<u32>(ControllerInterface::B
#ifdef WITH_SDL2
TRANSLATABLE("ControllerInterface", "SDL"),
#endif
#ifdef WIN32
#ifdef _WIN32
TRANSLATABLE("ControllerInterface", "XInput"),
TRANSLATABLE("ControllerInterface", "DInput"),
#endif
@ -143,7 +143,7 @@ ControllerInterface::Backend ControllerInterface::GetDefaultBackend()
#ifdef WITH_SDL2
return Backend::SDL;
#else
#ifdef WIN32
#ifdef _WIN32
return Backend::XInput;
#else
return Backend::None;
@ -154,7 +154,7 @@ ControllerInterface::Backend ControllerInterface::GetDefaultBackend()
#ifdef WITH_SDL2
#include "sdl_controller_interface.h"
#endif
#ifdef WIN32
#ifdef _WIN32
#include "dinput_controller_interface.h"
#include "xinput_controller_interface.h"
#endif
@ -168,7 +168,7 @@ std::unique_ptr<ControllerInterface> ControllerInterface::Create(Backend type)
if (type == Backend::SDL)
return std::make_unique<SDLControllerInterface>();
#endif
#ifdef WIN32
#ifdef _WIN32
if (type == Backend::XInput)
return std::make_unique<XInputControllerInterface>();
if (type == Backend::DInput)

View file

@ -21,7 +21,7 @@ public:
#ifdef WITH_SDL2
SDL,
#endif
#ifdef WIN32
#ifdef _WIN32
XInput,
DInput,
#endif

View file

@ -3,7 +3,7 @@
#include "common/log.h"
Log_SetChannel(CubebAudioStream);
#ifdef WIN32
#ifdef _WIN32
#include "common/windows_headers.h"
#include <objbase.h>
#pragma comment(lib, "Ole32.lib")
@ -21,7 +21,7 @@ bool CubebAudioStream::OpenDevice()
{
Assert(!IsOpen());
#ifdef WIN32
#ifdef _WIN32
HRESULT hr = CoInitializeEx(nullptr, COINIT_MULTITHREADED);
m_com_initialized_by_us = SUCCEEDED(hr);
if (FAILED(hr) && hr != RPC_E_CHANGED_MODE && hr != S_FALSE)
@ -150,7 +150,7 @@ void CubebAudioStream::DestroyContext()
cubeb_destroy(m_cubeb_context);
m_cubeb_context = nullptr;
#ifdef WIN32
#ifdef _WIN32
if (m_com_initialized_by_us)
CoUninitialize();
#endif

View file

@ -30,7 +30,7 @@ protected:
cubeb_stream* m_cubeb_stream = nullptr;
bool m_paused = true;
#ifdef WIN32
#ifdef _WIN32
bool m_com_initialized_by_us = false;
#endif
};

View file

@ -2054,7 +2054,7 @@ void DrawSettingsWindow()
switch (s_settings_copy.gpu_renderer)
{
#ifdef WIN32
#ifdef _WIN32
case GPURenderer::HardwareD3D11:
{
settings_changed |= ToggleButtonForNonSetting(
@ -2463,7 +2463,7 @@ void DrawSettingsWindow()
"Use Debug GPU Device", "Enable debugging when supported by the host's renderer API. Only for developer use.",
&s_settings_copy.gpu_use_debug_device);
#ifdef WIN32
#ifdef _WIN32
settings_changed |=
ToggleButton("Increase Timer Resolution", "Enables more precise frame pacing at the cost of battery life.",
&s_settings_copy.increase_timer_resolution);

View file

@ -11,7 +11,7 @@
#include <utility>
Log_SetChannel(GameSettings);
#ifdef WIN32
#ifdef _WIN32
#include "common/windows_headers.h"
#endif
#include "SimpleIni.h"

View file

@ -2,7 +2,7 @@
#include "core/settings.h"
// being a pain here...
#ifdef WIN32
#ifdef _WIN32
#include "common/windows_headers.h"
#endif
#include "SimpleIni.h"

View file

@ -12,7 +12,7 @@
#include <string>
#include <vector>
#ifdef WIN32
#ifdef _WIN32
#include <shellapi.h>
#endif
@ -55,7 +55,7 @@ bool Updater::OpenUpdateZip(const char* path)
bool Updater::RecursiveDeleteDirectory(const char* path)
{
#ifdef WIN32
#ifdef _WIN32
// making this safer on Win32...
std::wstring wpath(StringUtil::UTF8StringToWideString(path));
wpath += L'\0';
@ -286,7 +286,7 @@ bool Updater::CommitUpdate()
const std::string dest_file_name = StringUtil::StdStringFromFormat(
"%s" FS_OSPATH_SEPARATOR_STR "%s", m_destination_directory.c_str(), ftu.destination_filename.c_str());
m_progress->DisplayFormattedInformation("Moving '%s' to '%s'", staging_file_name.c_str(), dest_file_name.c_str());
#ifdef WIN32
#ifdef _WIN32
const bool result =
MoveFileExW(StringUtil::UTF8StringToWideString(staging_file_name).c_str(),
StringUtil::UTF8StringToWideString(dest_file_name).c_str(), MOVEFILE_REPLACE_EXISTING);