From 2570aea213ca86dfc4e97c6a9a73f874101a7602 Mon Sep 17 00:00:00 2001 From: Jamie Reece Wilson Date: Tue, 19 Dec 2023 03:43:11 +0000 Subject: [PATCH] [+] Clang/Win32 compilation support --- Aurora.json | 3 ++- Include/Aurora/IO/Loop/Loop.hpp | 2 +- Source/AuProcAddresses.NT.hpp | 4 ++-- Source/Debug/Demangle.cpp | 4 +--- Source/Debug/ExceptionWatcher.NT.hpp | 4 ++++ Source/IO/FS/Async.NT.hpp | 2 +- Source/IO/FS/Watcher.NT.cpp | 11 +++++++---- Source/IO/IPC/AuIPCPrimitives.NT.cpp | 4 ++-- Source/IO/Loop/LSEvent.NT.hpp | 6 +++--- Source/IO/Loop/LSHandle.hpp | 2 +- Source/IO/Loop/LSMutex.NT.hpp | 6 +++--- Source/IO/Loop/LSSemaphore.NT.cpp | 4 ++-- Source/IO/Loop/LSSemaphore.NT.hpp | 6 +++--- Source/IO/Net/AuNetStream.NT.cpp | 4 ++-- Source/IO/Net/AuNetStream.NT.hpp | 2 +- Source/Time/AuCivilTime.cpp | 16 ++++++++++++---- 16 files changed, 47 insertions(+), 33 deletions(-) diff --git a/Aurora.json b/Aurora.json index e5d2af46..e4ad6b27 100644 --- a/Aurora.json +++ b/Aurora.json @@ -14,7 +14,8 @@ "c99-designator", "reorder-init-list", "ignored-attributes", - "missing-declarations" + "missing-declarations", + "microsoft-enum-forward-reference" ], "notesClang": "missing-declarations was added to slience a macro hack. dw about it. it being '(struct {};)'. all the other options are my desire for c++ to be less stupid of a language, we all know whats unofficially supported and commonly suppressed in large projects.", "defines": [], diff --git a/Include/Aurora/IO/Loop/Loop.hpp b/Include/Aurora/IO/Loop/Loop.hpp index f899eb0b..ff29acc5 100644 --- a/Include/Aurora/IO/Loop/Loop.hpp +++ b/Include/Aurora/IO/Loop/Loop.hpp @@ -33,7 +33,7 @@ namespace Aurora::IO::Loop AUKN_SYM bool WaitMultipleLoopSourcesEx(const AuList> &lsList, AuList> &signaled, - AuUInt64 uFlags = { kWaitMultipleFlagAny }, + AuUInt64 uFlags = kWaitMultipleFlagAny, AuOptional optTimeoutMS = {}); struct ILSSemaphore : virtual ILoopSource diff --git a/Source/AuProcAddresses.NT.hpp b/Source/AuProcAddresses.NT.hpp index 1e09e9e2..2996da96 100644 --- a/Source/AuProcAddresses.NT.hpp +++ b/Source/AuProcAddresses.NT.hpp @@ -26,7 +26,7 @@ struct _NETRESOURCEW; enum _SE_OBJECT_TYPE; enum _MINIDUMP_TYPE; -#if defined(AURORA_COMPILER_MSVC) +//#if defined(AURORA_COMPILER_MSVC) struct _IP_ADAPTER_ADDRESSES_LH; struct _IP_ADAPTER_ADDRESSES_XP; #if (NTDDI_VERSION >= NTDDI_VISTA) @@ -39,7 +39,7 @@ enum _MINIDUMP_TYPE; typedef _IP_ADAPTER_ADDRESSES_XP IP_ADAPTER_ADDRESSES; typedef _IP_ADAPTER_ADDRESSES_XP *PIP_ADAPTER_ADDRESSES; #endif -#endif +//#endif namespace Aurora { diff --git a/Source/Debug/Demangle.cpp b/Source/Debug/Demangle.cpp index 1baca002..038e2803 100644 --- a/Source/Debug/Demangle.cpp +++ b/Source/Debug/Demangle.cpp @@ -10,9 +10,7 @@ #if defined(AURORA_IS_MODERNNT_DERIVED) #include -#endif - -#if defined(AURORA_COMPILER_CLANG) +#elif defined(AURORA_COMPILER_CLANG) #include #endif diff --git a/Source/Debug/ExceptionWatcher.NT.hpp b/Source/Debug/ExceptionWatcher.NT.hpp index 4eca9c37..aedb39df 100644 --- a/Source/Debug/ExceptionWatcher.NT.hpp +++ b/Source/Debug/ExceptionWatcher.NT.hpp @@ -7,6 +7,10 @@ ***/ #pragma once +#if defined(AURORA_COMPILER_CLANG) + struct _ThrowInfo; +#endif + namespace Aurora::Debug { AuString ReportSEH(HMODULE handle, void *exception, const void *throwInfo, const AuFunction &resolveFallback, const StackTrace &trace, const AuFunction &prereport); diff --git a/Source/IO/FS/Async.NT.hpp b/Source/IO/FS/Async.NT.hpp index f8f88111..d287b9f9 100644 --- a/Source/IO/FS/Async.NT.hpp +++ b/Source/IO/FS/Async.NT.hpp @@ -61,7 +61,7 @@ namespace Aurora::IO::FS bool Wait(AuUInt32 timeout) override; AuSPtr NewLoopSource() override; - void Reset(); + void Reset() override; bool IDontWannaUsePorts(); diff --git a/Source/IO/FS/Watcher.NT.cpp b/Source/IO/FS/Watcher.NT.cpp index e2a51d39..e0d67d45 100644 --- a/Source/IO/FS/Watcher.NT.cpp +++ b/Source/IO/FS/Watcher.NT.cpp @@ -263,16 +263,19 @@ namespace Aurora::IO::FS bool NTCachedPath::AddEvent(NTWatcher *parent, EWatchEvent type, const AuString &path) { AuCtorCode_t code; - auto watchedFile = AuTryConstruct(code, this->userData, this->strTheCakeIsALie); + WatchedFile watchedFile; + + watchedFile.userData = this->userData; + watchedFile.path = AuMove(AuTryConstruct(code, this->strTheCakeIsALie)); if (!code) { return false; } - + WatchEvent event; event.event = type; event.watch = AuMove(watchedFile); - event.file = AuTryConstruct(code, path); + event.file = AuMove(AuTryConstruct(code, path)); if (!code) { return false; @@ -387,7 +390,7 @@ namespace Aurora::IO::FS REQUEST_OPLOCK_CURRENT_VERSION, sizeof(REQUEST_OPLOCK_INPUT_BUFFER), OPLOCK_LEVEL_CACHE_READ | OPLOCK_LEVEL_CACHE_HANDLE, - bFirstTime ? REQUEST_OPLOCK_INPUT_FLAG_REQUEST : REQUEST_OPLOCK_INPUT_FLAG_ACK, + (DWORD)(bFirstTime ? REQUEST_OPLOCK_INPUT_FLAG_REQUEST : REQUEST_OPLOCK_INPUT_FLAG_ACK), }; DWORD dwBytesReturned; diff --git a/Source/IO/IPC/AuIPCPrimitives.NT.cpp b/Source/IO/IPC/AuIPCPrimitives.NT.cpp index c634f19e..f283dac1 100644 --- a/Source/IO/IPC/AuIPCPrimitives.NT.cpp +++ b/Source/IO/IPC/AuIPCPrimitives.NT.cpp @@ -338,8 +338,8 @@ namespace Aurora::IO::IPC token.NewId(); handle.PushId(EIPCHandleType::eIPCPrimitiveSemaphore, token); - - auto semaphore = ::CreateSemaphoreA(nullptr, startingValue, AuNumericLimits::max(), token.ToNTPath().c_str()); + + auto semaphore = ::CreateSemaphoreA(nullptr, startingValue, /*AuNumericLimits::max()*/ LONG_MAX, token.ToNTPath().c_str()); if ((!semaphore) || (semaphore == INVALID_HANDLE_VALUE)) { diff --git a/Source/IO/Loop/LSEvent.NT.hpp b/Source/IO/Loop/LSEvent.NT.hpp index 596adff3..65ae5cac 100644 --- a/Source/IO/Loop/LSEvent.NT.hpp +++ b/Source/IO/Loop/LSEvent.NT.hpp @@ -19,8 +19,8 @@ namespace Aurora::IO::Loop bool Set() override; bool Reset() override; - virtual bool ILSEvent::IsSignaled() override; - virtual bool ILSEvent::WaitOn(AuUInt32 timeout) override; - virtual ELoopSource ILSEvent::GetType() override; + virtual bool IsSignaled() override; + virtual bool WaitOn(AuUInt32 timeout) override; + virtual ELoopSource GetType() override; }; } \ No newline at end of file diff --git a/Source/IO/Loop/LSHandle.hpp b/Source/IO/Loop/LSHandle.hpp index a4e22304..577d7637 100644 --- a/Source/IO/Loop/LSHandle.hpp +++ b/Source/IO/Loop/LSHandle.hpp @@ -12,7 +12,7 @@ namespace Aurora::IO::Loop { #if defined(AURORA_IS_MODERNNT_DERIVED) - static constexpr auto kInvalidHandle = (AuUInt)INVALID_HANDLE_VALUE; + static constexpr auto kInvalidHandle = (const AuUInt)-1; #else static constexpr auto kInvalidHandle = -1; #endif diff --git a/Source/IO/Loop/LSMutex.NT.hpp b/Source/IO/Loop/LSMutex.NT.hpp index c0e9204c..458597e2 100644 --- a/Source/IO/Loop/LSMutex.NT.hpp +++ b/Source/IO/Loop/LSMutex.NT.hpp @@ -17,8 +17,8 @@ namespace Aurora::IO::Loop bool Unlock() override; - bool ILSMutex::IsSignaled() override; - bool ILSMutex::WaitOn(AuUInt32 timeout) override; - ELoopSource ILSMutex::GetType() override; + bool IsSignaled() override; + bool WaitOn(AuUInt32 timeout) override; + ELoopSource GetType() override; }; } \ No newline at end of file diff --git a/Source/IO/Loop/LSSemaphore.NT.cpp b/Source/IO/Loop/LSSemaphore.NT.cpp index 2272a964..9824fc7c 100644 --- a/Source/IO/Loop/LSSemaphore.NT.cpp +++ b/Source/IO/Loop/LSSemaphore.NT.cpp @@ -52,7 +52,7 @@ namespace Aurora::IO::Loop bool LSSemaphore::TryInit(AuUInt32 initialCount) { - auto semaphore = ::CreateSemaphoreA(NULL, initialCount, AuNumericLimits::max(), NULL); + auto semaphore = ::CreateSemaphoreA(NULL, initialCount, /*AuNumericLimits::max()*/ LONG_MAX, NULL); if (!semaphore) { SysPushErrorGen("Out of OS resources?"); @@ -68,7 +68,7 @@ namespace Aurora::IO::Loop { AuSPtr ret; - auto semaphore = ::CreateSemaphoreA(NULL, initialCount, AuNumericLimits::max(), NULL); + auto semaphore = ::CreateSemaphoreA(NULL, initialCount, /*AuNumericLimits::max()*/ LONG_MAX, NULL); if (!semaphore) { SysPushErrorGen("Out of OS resources?"); diff --git a/Source/IO/Loop/LSSemaphore.NT.hpp b/Source/IO/Loop/LSSemaphore.NT.hpp index 91c9dff5..4cd15277 100644 --- a/Source/IO/Loop/LSSemaphore.NT.hpp +++ b/Source/IO/Loop/LSSemaphore.NT.hpp @@ -21,8 +21,8 @@ namespace Aurora::IO::Loop bool AddOne() override; bool AddMany(AuUInt32 uCount) override; - bool ILSSemaphore::IsSignaled() override; - bool ILSSemaphore::WaitOn(AuUInt32 timeout) override; - ELoopSource ILSSemaphore::GetType() override; + bool IsSignaled() override; + bool WaitOn(AuUInt32 timeout) override; + ELoopSource GetType() override; }; } \ No newline at end of file diff --git a/Source/IO/Net/AuNetStream.NT.cpp b/Source/IO/Net/AuNetStream.NT.cpp index 95eefc3a..eb2f6d3c 100644 --- a/Source/IO/Net/AuNetStream.NT.cpp +++ b/Source/IO/Net/AuNetStream.NT.cpp @@ -109,7 +109,7 @@ namespace Aurora::IO::Net WSABUF bufferArray[] { { - memoryView->length, + (ULONG)memoryView->length, memoryView->Begin() } }; @@ -213,7 +213,7 @@ namespace Aurora::IO::Net WSABUF bufferArray[] { { - memoryView->length, + (ULONG)memoryView->length, (CHAR *)memoryView->Begin() } }; diff --git a/Source/IO/Net/AuNetStream.NT.hpp b/Source/IO/Net/AuNetStream.NT.hpp index 1a3187a1..b0e32e45 100644 --- a/Source/IO/Net/AuNetStream.NT.hpp +++ b/Source/IO/Net/AuNetStream.NT.hpp @@ -43,7 +43,7 @@ namespace Aurora::IO::Net void SetBaseOffset(AuUInt64 uBaseOffset) override; - void Reset(); + void Reset() override; void MakeSyncable(); void ForceNextWriteWait(); diff --git a/Source/Time/AuCivilTime.cpp b/Source/Time/AuCivilTime.cpp index 50b84d9b..4d9bc02b 100644 --- a/Source/Time/AuCivilTime.cpp +++ b/Source/Time/AuCivilTime.cpp @@ -11,7 +11,15 @@ #include "AuCivilTime.hpp" #include "Time.hpp" -#if defined(AURORA_IS_MODERNNT_DERIVED) + +#if defined(AURORA_COMPILER_MSVC) || \ + defined(_CRT_USE_CONFORMING_ANNEX_K_TIME) + + #define TIME_MSFT_LIKE + +#endif + +#if defined(TIME_MSFT_LIKE) #define timegm _mkgmtime @@ -108,12 +116,12 @@ namespace Aurora::Time auto timet = MSToCTime(time); if (shift == ETimezoneShift::eUTC) { - #if defined(AURORA_COMPILER_MSVC) + #if defined(TIME_MSFT_LIKE) auto tm = gmtime_s(&ret, &timet); #else auto tm = gmtime_r(&timet, &ret); #endif - #if defined(AURORA_COMPILER_MSVC) + #if defined(TIME_MSFT_LIKE) SysAssert(!tm, "couldn't convert civil time"); #else SysAssert(tm, "couldn't convert civil time"); @@ -122,7 +130,7 @@ namespace Aurora::Time } else { - #if defined(AURORA_COMPILER_MSVC) + #if defined(TIME_MSFT_LIKE) if (localtime_s(&ret, &timet)) #else if (!localtime_r(&timet, &ret))