mirror of
https://github.com/WinampDesktop/winamp.git
synced 2025-06-21 10:35:39 -04:00
WIN32 macro -> _WIN32
This commit is contained in:
@ -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);
|
||||
|
@ -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] = '/';
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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};
|
||||
|
@ -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);
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
class ByteStream;
|
||||
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#define FS_OSPATH_SEPARATOR_CHARACTER '\\'
|
||||
#define FS_OSPATH_SEPARATOR_STR "\\"
|
||||
#else
|
||||
|
@ -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);
|
||||
|
@ -67,7 +67,7 @@ public:
|
||||
static const std::array<Version, 16>& GetAllVersionsList();
|
||||
|
||||
protected:
|
||||
#ifdef WIN32
|
||||
#ifdef _WIN32
|
||||
#endif
|
||||
|
||||
WindowInfo m_wi;
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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}}};
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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, ©.m_value, sizeof(m_value));
|
||||
#else
|
||||
std::memcpy(&m_value, ©.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)
|
||||
|
@ -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;
|
||||
|
Reference in New Issue
Block a user