fix windows compilation (2) (#1411)

* fix windows compialtion (2)

* loader: guard LoadExec close_range path with __linux__ for macOS

---------

Co-authored-by: ReverendOzmund <catmilker@proton.me>
This commit is contained in:
nmzik 2026-10-11 11:11:02 +02:00 committed by GitHub
parent 6f0cddd440
commit 16a7fe689a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 9 additions and 4 deletions

View File

@ -40,6 +40,11 @@ if (NOT (WIN32 OR LINUX OR APPLE))
message(FATAL_ERROR "only Windows, Linux, and macOS builds are supported")
endif()
if(WIN32)
# Prevent Windows headers from defining min/max macros in all targets.
add_compile_definitions(NOMINMAX)
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

View File

@ -405,7 +405,7 @@ void CompileSrtWalker(ResourcePlan& program) {
if (reg < program.user_data_base ||
RegIndex(high->Arg(0).ScalarRegister()) != reg + 1u) return;
const auto base = reg - program.user_data_base;
user_data_count = std::max<uint32_t>(user_data_count, base + 2u);
user_data_count = std::max(user_data_count, base + 2u);
uses = &roots[base];
} else {
const auto lo = offsets.find(low);
@ -794,7 +794,7 @@ bool SrtWalker::EvaluateInst(const Inst& inst, uint64_t& result) {
return false;
case ValueOpcode::UMin32:
if (binary()) {
result = std::min<uint32_t>(static_cast<uint32_t>(a), static_cast<uint32_t>(b));
result = std::min(static_cast<uint32_t>(a), static_cast<uint32_t>(b));
return true;
}
return false;

View File

@ -14,7 +14,7 @@
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#elif KYTY_PLATFORM == KYTY_PLATFORM_LINUX
#elif defined(__linux__)
#include <linux/close_range.h>
#include <unistd.h>
#endif
@ -45,7 +45,7 @@ int LoadExec(const char* path, const char* const argv[]) {
!Common::File::IsFileExisting(Libs::LibKernel::FileSystem::GetRealFilename(path))) {
return SYSTEM_SERVICE_ERROR_PARAMETER;
}
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS || KYTY_PLATFORM == KYTY_PLATFORM_LINUX
#if KYTY_PLATFORM == KYTY_PLATFORM_WINDOWS || defined(__linux__)
std::vector<std::string> arguments {"--guest-exec", path};
size_t bytes = 0;
for (size_t i = 0; argv != nullptr && argv[i] != nullptr; ++i) {