diff options
30 files changed, 119 insertions, 100 deletions
diff --git a/zen/cmds/cache.cpp b/zen/cmds/cache.cpp index 202bf9246..2a911c8c7 100644 --- a/zen/cmds/cache.cpp +++ b/zen/cmds/cache.cpp @@ -9,16 +9,9 @@ #include <memory> -// cpr //////////////////////////////////////////////////////////////////// -// -// For some reason, these don't seem to stick, so we disable the warnings -//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1 -//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1 -#pragma warning(push) -#pragma warning(disable : 4004) -#pragma warning(disable : 4996) +ZEN_THIRD_PARTY_INCLUDES_START #include <cpr/cpr.h> -#pragma warning(pop) +ZEN_THIRD_PARTY_INCLUDES_END using namespace fmt::literals; diff --git a/zen/cmds/run.cpp b/zen/cmds/run.cpp index b20b1b64c..085e74061 100644 --- a/zen/cmds/run.cpp +++ b/zen/cmds/run.cpp @@ -17,16 +17,9 @@ #include <filesystem> -// cpr //////////////////////////////////////////////////////////////////// -// -// For some reason, these don't seem to stick, so we disable the warnings -//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1 -//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1 -#pragma warning(push) -#pragma warning(disable : 4004) -#pragma warning(disable : 4996) +ZEN_THIRD_PARTY_INCLUDES_START #include <cpr/cpr.h> -#pragma warning(pop) +ZEN_THIRD_PARTY_INCLUDES_END #if ZEN_PLATFORM_WINDOWS # pragma comment(lib, "Crypt32.lib") diff --git a/zencore/include/zencore/compactbinarypackage.h b/zencore/include/zencore/compactbinarypackage.h index cc2c4815a..3fb85beb3 100644 --- a/zencore/include/zencore/compactbinarypackage.h +++ b/zencore/include/zencore/compactbinarypackage.h @@ -12,6 +12,11 @@ #include <span> #include <variant> +#ifdef GetObject +# error "windows.h pollution" +# undef GetObject +#endif + namespace zen { class CbWriter; diff --git a/zencore/include/zencore/fmtutils.h b/zencore/include/zencore/fmtutils.h index 29e2ae78a..7e60c2bef 100644 --- a/zencore/include/zencore/fmtutils.h +++ b/zencore/include/zencore/fmtutils.h @@ -6,7 +6,11 @@ #include <zencore/string.h> #include <zencore/uid.h> + +ZEN_THIRD_PARTY_INCLUDES_START #include <fmt/format.h> +ZEN_THIRD_PARTY_INCLUDES_END + #include <filesystem> #include <string_view> diff --git a/zencore/include/zencore/logging.h b/zencore/include/zencore/logging.h index 0838cfe80..0b080cb9d 100644 --- a/zencore/include/zencore/logging.h +++ b/zencore/include/zencore/logging.h @@ -2,11 +2,12 @@ #pragma once -// clang-format off -#include "prewindows.h" +#include <zencore/zencore.h> + +ZEN_THIRD_PARTY_INCLUDES_START #include <spdlog/spdlog.h> -#include "postwindows.h" -// clang-format on +#undef GetObject +ZEN_THIRD_PARTY_INCLUDES_END #include <string_view> diff --git a/zencore/include/zencore/postwindows.h b/zencore/include/zencore/postwindows.h deleted file mode 100644 index 35b7db3af..000000000 --- a/zencore/include/zencore/postwindows.h +++ /dev/null @@ -1,3 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. - -#undef GetObject diff --git a/zencore/include/zencore/prewindows.h b/zencore/include/zencore/prewindows.h deleted file mode 100644 index 0bc74e49b..000000000 --- a/zencore/include/zencore/prewindows.h +++ /dev/null @@ -1 +0,0 @@ -// Copyright Epic Games, Inc. All Rights Reserved. diff --git a/zencore/include/zencore/windows.h b/zencore/include/zencore/windows.h index 2b6dc4839..621621ae8 100644 --- a/zencore/include/zencore/windows.h +++ b/zencore/include/zencore/windows.h @@ -2,7 +2,7 @@ #pragma once -#include "prewindows.h" +ZEN_THIRD_PARTY_INCLUDES_START struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax error: 'identifier' was unexpected here" when using /permissive- #ifndef NOMINMAX @@ -10,5 +10,6 @@ struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax erro #endif #define WIN32_LEAN_AND_MEAN #include <windows.h> +#undef GetObject -#include "postwindows.h" +ZEN_THIRD_PARTY_INCLUDES_END diff --git a/zencore/include/zencore/zencore.h b/zencore/include/zencore/zencore.h index 3f92d7ac4..de848146a 100644 --- a/zencore/include/zencore/zencore.h +++ b/zencore/include/zencore/zencore.h @@ -64,6 +64,22 @@ # pragma warning(disable : 4324) // warning C4324: '<type>': structure was padded due to alignment specifier #endif +#ifndef ZEN_THIRD_PARTY_INCLUDES_START +# if ZEN_COMPILER_MSC +# define ZEN_THIRD_PARTY_INCLUDES_START __pragma(warning(push)) __pragma(warning(disable : 4668)) +# else +# define ZEN_THIRD_PARTY_INCLUDES_START +# endif +#endif + +#ifndef ZEN_THIRD_PARTY_INCLUDES_END +# if ZEN_COMPILER_MSC +# define ZEN_THIRD_PARTY_INCLUDES_END __pragma(warning(pop)) +# else +# define ZEN_THIRD_PARTY_INCLUDES_END +# endif +#endif + ////////////////////////////////////////////////////////////////////////// // Architecture // diff --git a/zencore/iobuffer.cpp b/zencore/iobuffer.cpp index 68047bde0..63d5ac98d 100644 --- a/zencore/iobuffer.cpp +++ b/zencore/iobuffer.cpp @@ -15,7 +15,9 @@ #include <system_error> #if ZEN_USE_MIMALLOC +ZEN_THIRD_PARTY_INCLUDES_START # include <mimalloc.h> +ZEN_THIRD_PARTY_INCLUDES_END #endif #if ZEN_PLATFORM_WINDOWS @@ -390,9 +392,12 @@ IoBufferBuilder::ReadFromFileMaybe(IoBuffer& InBuffer) DWORD dwNumberOfBytesRead = 0; BOOL Success = ::ReadFile(FileRef.FileHandle, OutBuffer.MutableData(), DWORD(NumberOfBytesToRead), &dwNumberOfBytesRead, &Ovl); - ZEN_ASSERT(dwNumberOfBytesRead == NumberOfBytesToRead); + if (!Success) + { + ThrowLastError("ReadFile failed in IoBufferBuilder::ReadFromFileMaybe"); + } - // TODO: error handling + ZEN_ASSERT(dwNumberOfBytesRead == NumberOfBytesToRead); return OutBuffer; #else diff --git a/zencore/memory.cpp b/zencore/memory.cpp index da78ae3a8..62c81076d 100644 --- a/zencore/memory.cpp +++ b/zencore/memory.cpp @@ -6,7 +6,9 @@ #ifdef ZEN_PLATFORM_WINDOWS # include <malloc.h> +ZEN_THIRD_PARTY_INCLUDES_START # include <mimalloc.h> +ZEN_THIRD_PARTY_INCLUDES_END #else # include <cstdlib> #endif diff --git a/zencore/thread.cpp b/zencore/thread.cpp index 72b8c54f6..2a38283e1 100644 --- a/zencore/thread.cpp +++ b/zencore/thread.cpp @@ -2,7 +2,6 @@ #include <zencore/thread.h> -#include <fmt/format.h> #include <zencore/except.h> #include <zencore/string.h> #include <zencore/testing.h> @@ -13,6 +12,10 @@ # include <unistd.h> #endif +ZEN_THIRD_PARTY_INCLUDES_START +#include <fmt/format.h> +ZEN_THIRD_PARTY_INCLUDES_END + namespace zen { #if ZEN_PLATFORM_WINDOWS diff --git a/zencore/zencore.vcxproj b/zencore/zencore.vcxproj index 421802d3f..95b9eace5 100644 --- a/zencore/zencore.vcxproj +++ b/zencore/zencore.vcxproj @@ -115,6 +115,7 @@ <ClInclude Include="include\zencore\atomic.h" /> <ClInclude Include="include\zencore\base64.h" /> <ClInclude Include="include\zencore\blake3.h" /> + <ClInclude Include="include\zencore\blockingqueue.h" /> <ClInclude Include="include\zencore\compactbinaryvalue.h" /> <ClInclude Include="include\zencore\compositebuffer.h" /> <ClInclude Include="include\zencore\crc32.h" /> @@ -131,8 +132,6 @@ <ClInclude Include="include\zencore\memory.h" /> <ClInclude Include="include\zencore\meta.h" /> <ClInclude Include="include\zencore\mpscqueue.h" /> - <ClInclude Include="include\zencore\postwindows.h" /> - <ClInclude Include="include\zencore\prewindows.h" /> <ClInclude Include="include\zencore\refcount.h" /> <ClInclude Include="include\zencore\scopeguard.h" /> <ClInclude Include="include\zencore\session.h" /> diff --git a/zencore/zencore.vcxproj.filters b/zencore/zencore.vcxproj.filters index e701e9354..1aedf9eab 100644 --- a/zencore/zencore.vcxproj.filters +++ b/zencore/zencore.vcxproj.filters @@ -36,8 +36,6 @@ <ClInclude Include="include\zencore\compositebuffer.h" /> <ClInclude Include="include\zencore\crc32.h" /> <ClInclude Include="include\zencore\meta.h" /> - <ClInclude Include="include\zencore\prewindows.h" /> - <ClInclude Include="include\zencore\postwindows.h" /> <ClInclude Include="include\zencore\logging.h" /> <ClInclude Include="include\zencore\session.h" /> <ClInclude Include="include\zencore\testutils.h" /> @@ -45,6 +43,7 @@ <ClInclude Include="include\zencore\mpscqueue.h" /> <ClInclude Include="include\zencore\base64.h" /> <ClInclude Include="include\zencore\compactbinaryvalue.h" /> + <ClInclude Include="include\zencore\blockingqueue.h" /> </ItemGroup> <ItemGroup> <ClCompile Include="sha1.cpp" /> diff --git a/zenhttp/httpserver.cpp b/zenhttp/httpserver.cpp index 150054c30..f40836c4a 100644 --- a/zenhttp/httpserver.cpp +++ b/zenhttp/httpserver.cpp @@ -577,12 +577,12 @@ CreateHttpServer(std::string_view ServerClass) { using namespace std::literals; -#if 1 - HttpServerClass Class = HttpServerClass::kHttpAsio; -#elif ZEN_WITH_HTTPSYS - HttpServerClass Class = HttpServerClass::kHttpSys; -#else HttpServerClass Class = HttpServerClass::kHttpNull; + +#if ZEN_WITH_HTTPSYS + Class = HttpServerClass::kHttpSys; +#elif 1 + Class = HttpServerClass::kHttpAsio; #endif if (ServerClass == "asio"sv) diff --git a/zenhttp/include/zenhttp/httpclient.h b/zenhttp/include/zenhttp/httpclient.h index aa36a8027..9ece86111 100644 --- a/zenhttp/include/zenhttp/httpclient.h +++ b/zenhttp/include/zenhttp/httpclient.h @@ -10,14 +10,9 @@ #include <zencore/windows.h> -// For some reason, these don't seem to stick, so we disable the warnings -//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1 -//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1 -#pragma warning(push) -#pragma warning(disable : 4004) -#pragma warning(disable : 4996) +ZEN_THIRD_PARTY_INCLUDES_START #include <cpr/cpr.h> -#pragma warning(pop) +ZEN_THIRD_PARTY_INCLUDES_END namespace zen { diff --git a/zenhttp/include/zenhttp/httpserver.h b/zenhttp/include/zenhttp/httpserver.h index 55bd08a8e..93ba452c7 100644 --- a/zenhttp/include/zenhttp/httpserver.h +++ b/zenhttp/include/zenhttp/httpserver.h @@ -4,14 +4,13 @@ #include "zenhttp.h" -#include <zenhttp/httpcommon.h> - #include <zencore/enumflags.h> #include <zencore/iobuffer.h> #include <zencore/iohash.h> #include <zencore/refcount.h> #include <zencore/string.h> #include <zencore/uid.h> +#include <zenhttp/httpcommon.h> #include <functional> #include <gsl/gsl-lite.hpp> diff --git a/zenhttp/include/zenhttp/zenhttp.h b/zenhttp/include/zenhttp/zenhttp.h index 165f34b48..59c64b31f 100644 --- a/zenhttp/include/zenhttp/zenhttp.h +++ b/zenhttp/include/zenhttp/zenhttp.h @@ -4,6 +4,14 @@ #include <zencore/zencore.h> +#ifndef ZEN_WITH_HTTPSYS +# if ZEN_PLATFORM_WINDOWS +# define ZEN_WITH_HTTPSYS 1 +# else +# define ZEN_WITH_HTTPSYS 0 +# endif +#endif + #define ZENHTTP_API // Placeholder to allow DLL configs in the future namespace zen { diff --git a/zenserver-test/zenserver-test.cpp b/zenserver-test/zenserver-test.cpp index 19770e05f..0f9026e76 100644 --- a/zenserver-test/zenserver-test.cpp +++ b/zenserver-test/zenserver-test.cpp @@ -23,7 +23,9 @@ #include <zenutil/zenserverprocess.h> #if ZEN_USE_MIMALLOC +ZEN_THIRD_PARTY_INCLUDES_START # include <mimalloc.h> +ZEN_THIRD_PARTY_INCLUDES_END #endif #include <http_parser.h> @@ -32,7 +34,11 @@ # pragma comment(lib, "Crypt32.lib") # pragma comment(lib, "Wldap32.lib") #endif + +ZEN_THIRD_PARTY_INCLUDES_START #include <cpr/cpr.h> +#undef GetObject +ZEN_THIRD_PARTY_INCLUDES_END #include <ppl.h> #include <atomic> @@ -594,10 +600,6 @@ private: ////////////////////////////////////////////////////////////////////////// #if 0 -# include <cpr/cpr.h> - -# pragma comment(lib, "Crypt32.lib") -# pragma comment(lib, "Wldap32.lib") int main() diff --git a/zenserver/cache/structuredcachestore.cpp b/zenserver/cache/structuredcachestore.cpp index 9f63699e5..fcd10bdac 100644 --- a/zenserver/cache/structuredcachestore.cpp +++ b/zenserver/cache/structuredcachestore.cpp @@ -725,23 +725,28 @@ ZenCacheDiskLayer::CacheBucket::PutStandaloneCacheValue(const IoHash& HashKey, c DataFile.MoveTemporaryIntoPlace(FsPath, Ec); - if (Ec) + if (!Ec) { - std::error_code InnerEc; - const uint64_t ExistingFileSize = std::filesystem::file_size(FsPath, InnerEc); + break; + } - if (!InnerEc && ExistingFileSize == Value.Value.Size()) - { - // Concurrent write of same value? - return; - } + std::error_code InnerEc; + const uint64_t ExistingFileSize = std::filesystem::file_size(FsPath, InnerEc); + + if (!InnerEc && ExistingFileSize == Value.Value.Size()) + { + // Concurrent write of same value? + return; } // Semi arbitrary back-off zen::Sleep(1000 * RetryCount); } while (RetryCount--); - throw std::system_error(Ec, "Failed to finalize file '{}'"_format(WideToUtf8(DataFilePath))); + if (Ec) + { + throw std::system_error(Ec, "Failed to finalize file '{}'"_format(WideToUtf8(DataFilePath))); + } } // Update index diff --git a/zenserver/compute/apply.cpp b/zenserver/compute/apply.cpp index a522aa35b..053c262c2 100644 --- a/zenserver/compute/apply.cpp +++ b/zenserver/compute/apply.cpp @@ -16,18 +16,16 @@ #include <zenstore/CAS.h> #include <zenstore/cidstore.h> -// clang-format off #if ZEN_PLATFORM_WINDOWS -# include <zencore/prewindows.h> +ZEN_THIRD_PARTY_INCLUDES_START # include <AccCtrl.h> # include <AclAPI.h> # include <sddl.h> # include <UserEnv.h> # pragma comment(lib, "UserEnv.lib") # include <atlbase.h> -# include <zencore/postwindows.h> +ZEN_THIRD_PARTY_INCLUDES_END #endif -// clang-format on #include <filesystem> #include <span> diff --git a/zenserver/config.cpp b/zenserver/config.cpp index 937598a64..799891289 100644 --- a/zenserver/config.cpp +++ b/zenserver/config.cpp @@ -7,6 +7,7 @@ #include <zencore/fmtutils.h> #include <zencore/iobuffer.h> #include <zencore/string.h> +#include <zenhttp/zenhttp.h> #pragma warning(push) #pragma warning(disable : 4267) // warning C4267: '=': conversion from 'size_t' to 'US', possible loss of data diff --git a/zenserver/config.h b/zenserver/config.h index eaafc31bb..d68549616 100644 --- a/zenserver/config.h +++ b/zenserver/config.h @@ -5,6 +5,10 @@ #include <filesystem> #include <string> +#ifndef ZEN_ENABLE_MESH +# define ZEN_ENABLE_MESH 0 +#endif + struct ZenServerOptions { bool IsDebug = false; diff --git a/zenserver/diag/formatters.h b/zenserver/diag/formatters.h index d4eeeb31c..d55765612 100644 --- a/zenserver/diag/formatters.h +++ b/zenserver/diag/formatters.h @@ -2,13 +2,10 @@ #pragma once +ZEN_THIRD_PARTY_INCLUDES_START #include <fmt/format.h> - -#pragma warning(push) -#pragma warning(disable : 4004) -#pragma warning(disable : 4996) #include <cpr/cpr.h> -#pragma warning(pop) +ZEN_THIRD_PARTY_INCLUDES_END template<> struct fmt::formatter<cpr::Response> diff --git a/zenserver/diag/logging.cpp b/zenserver/diag/logging.cpp index 7a7773cba..6e2559f1f 100644 --- a/zenserver/diag/logging.cpp +++ b/zenserver/diag/logging.cpp @@ -4,6 +4,7 @@ #include "config.h" +ZEN_THIRD_PARTY_INCLUDES_START #include <spdlog/async.h> #include <spdlog/async_logger.h> #include <spdlog/pattern_formatter.h> @@ -13,10 +14,10 @@ #include <spdlog/sinks/msvc_sink.h> #include <spdlog/sinks/rotating_file_sink.h> #include <spdlog/sinks/stdout_color_sinks.h> -#include <spdlog/spdlog.h> +ZEN_THIRD_PARTY_INCLUDES_END + #include <zencore/string.h> #include <memory> -#include "spdlog/sinks/basic_file_sink.h" // Custom logging -- test code, this should be tweaked diff --git a/zenserver/experimental/usnjournal.h b/zenserver/experimental/usnjournal.h index 9c1008d52..688823953 100644 --- a/zenserver/experimental/usnjournal.h +++ b/zenserver/experimental/usnjournal.h @@ -2,9 +2,12 @@ #pragma once +#include <zencore/zencore.h> #include <zencore/windows.h> +ZEN_THIRD_PARTY_INCLUDES_START #include <winioctl.h> +ZEN_THIRD_PARTY_INCLUDES_END #include <filesystem> diff --git a/zenserver/upstream/jupiter.cpp b/zenserver/upstream/jupiter.cpp index 1c43f1bc6..556a2124d 100644 --- a/zenserver/upstream/jupiter.cpp +++ b/zenserver/upstream/jupiter.cpp @@ -6,21 +6,16 @@ #include "diag/formatters.h" #include "diag/logging.h" -#include <fmt/format.h> #include <zencore/compactbinary.h> #include <zencore/iobuffer.h> #include <zencore/iohash.h> #include <zencore/string.h> #include <zencore/thread.h> -// For some reason, these don't seem to stick, so we disable the warnings -//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1 -//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1 -#pragma warning(push) -#pragma warning(disable : 4004) -#pragma warning(disable : 4996) +ZEN_THIRD_PARTY_INCLUDES_START #include <cpr/cpr.h> -#pragma warning(pop) +#include <fmt/format.h> +ZEN_THIRD_PARTY_INCLUDES_END #if ZEN_PLATFORM_WINDOWS # pragma comment(lib, "Crypt32.lib") diff --git a/zenserver/upstream/zen.cpp b/zenserver/upstream/zen.cpp index 6141fd397..14333f45a 100644 --- a/zenserver/upstream/zen.cpp +++ b/zenserver/upstream/zen.cpp @@ -12,16 +12,9 @@ #include "diag/formatters.h" #include "diag/logging.h" -// cpr //////////////////////////////////////////////////////////////////// -// -// For some reason, these don't seem to stick, so we disable the warnings -//# define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING 1 -//# define _SILENCE_ALL_CXX17_DEPRECATION_WARNINGS 1 -#pragma warning(push) -#pragma warning(disable : 4004) -#pragma warning(disable : 4996) +ZEN_THIRD_PARTY_INCLUDES_START #include <cpr/cpr.h> -#pragma warning(pop) +ZEN_THIRD_PARTY_INCLUDES_END #include <xxhash.h> #include <gsl/gsl-lite.hpp> diff --git a/zenserver/zenserver.cpp b/zenserver/zenserver.cpp index a1cd01d33..c9b52604d 100644 --- a/zenserver/zenserver.cpp +++ b/zenserver/zenserver.cpp @@ -16,17 +16,21 @@ #include <zenstore/cidstore.h> #include <zenutil/zenserverprocess.h> -#include <fmt/format.h> - #if ZEN_USE_MIMALLOC +ZEN_THIRD_PARTY_INCLUDES_START # include <mimalloc-new-delete.h> # include <mimalloc.h> +ZEN_THIRD_PARTY_INCLUDES_END #endif +ZEN_THIRD_PARTY_INCLUDES_START +#include <fmt/format.h> #include <asio.hpp> +#include <lua.hpp> +ZEN_THIRD_PARTY_INCLUDES_END + #include <exception> #include <list> -#include <lua.hpp> #include <optional> #include <regex> #include <set> @@ -64,7 +68,9 @@ #if USE_SENTRY # define SENTRY_BUILD_STATIC 1 +ZEN_THIRD_PARTY_INCLUDES_START # include <sentry.h> +ZEN_THIRD_PARTY_INCLUDES_END // Sentry currently does not automatically add all required Windows // libraries to the linker when consumed via vcpkg diff --git a/zenstore/filecas.cpp b/zenstore/filecas.cpp index ebab7338e..3941499f1 100644 --- a/zenstore/filecas.cpp +++ b/zenstore/filecas.cpp @@ -22,16 +22,11 @@ #include <functional> #include <unordered_map> -// clang-format off +ZEN_THIRD_PARTY_INCLUDES_START #if ZEN_PLATFORM_WINDOWS -# include <zencore/prewindows.h> - - struct IUnknown; // Workaround for "combaseapi.h(229): error C2187: syntax error: 'identifier' was unexpected here" when using /permissive- # include <atlfile.h> - -# include <zencore/postwindows.h> #endif -// clang-format on +ZEN_THIRD_PARTY_INCLUDES_END namespace zen { |