Compare commits

..

11 commits

Author SHA1 Message Date
5772537164
[gamemode] default disable on msvc, move to UI category
All checks were successful
eden-license / license-header (pull_request) Successful in 37s
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2025-09-13 20:48:40 +00:00
7f6d949509
[gamemode] windows fix
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2025-09-13 20:44:59 +00:00
050efcba37
[gamemode] extra win/lin/macos fixes
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2025-09-13 20:44:59 +00:00
439d3858e9
[gamemode] make option available on all nixes
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2025-09-13 20:44:58 +00:00
efab0b162b
[gamemode] Make available on other platforms
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2025-09-13 20:44:58 +00:00
28d26b0d76
[ci, docs] Refactor building with Windows (#400)
* this a initial PR to improve documentation of building under windows

Reviewed-on: #400
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Co-committed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
2025-09-12 16:07:35 +02:00
ad6045d9a4
[vk] Fix regression on PR 321 (#394)
Reviewed-on: #394
Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: MaranBr <maranbr@outlook.com>
Co-committed-by: MaranBr <maranbr@outlook.com>
2025-09-12 16:02:25 +02:00
3fbfd64722
[fs] Fix integrity check validation for new updates (#395)
This fixes the integrity check validation for new updates.

Reviewed-on: #395
Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: MaranBr <maranbr@outlook.com>
Co-committed-by: MaranBr <maranbr@outlook.com>
2025-09-12 16:02:12 +02:00
13ecc1e481
[cmake] fix issues when using CPMUTIL_FORCE_SYSTEM (#399)
Reviewed-on: #399
Reviewed-by: crueter <crueter@eden-emu.dev>
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Co-authored-by: Marcin Serwin <marcin@serwin.dev>
Co-committed-by: Marcin Serwin <marcin@serwin.dev>
2025-09-10 18:36:42 +02:00
2502352180
[core, desktop] "fixes" from building on mxe/x86_64-w64-mingw32 (#396)
* well, i couldn't build the executable, but in anyway those build
  errors can come back later to bite our backs
* include missing include
* safeguard _MSC_VER only headers

* saw some of those changes on another PR but I cant find it at moment

Signed-off-by: Caio Oliveira <caiooliveirafarias0@gmail.com>

Reviewed-on: #396
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
Co-committed-by: Caio Oliveira <caiooliveirafarias0@gmail.com>
2025-09-10 02:22:07 +02:00
9d2681ecc9
[cmake] enable clang-cl and WoA builds (#348)
Compilation and CMake fixes for both Windows on ARM and clang-cl, meaning Windows can now be built on both MSVC and clang on both amd64 and aarch64.

Compiling on clang is *dramatically* faster so this should be useful for CI.

Co-authored-by: crueter <crueter@eden-emu.dev>
Co-authored-by: crueter <crueter@crueter.xyz>
Reviewed-on: #348
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Reviewed-by: crueter <crueter@eden-emu.dev>
Co-authored-by: lizzie <lizzie@eden-emu.dev>
Co-committed-by: lizzie <lizzie@eden-emu.dev>
2025-09-09 20:47:49 +02:00
289 changed files with 1269 additions and 1180 deletions

View file

@ -1,59 +1,45 @@
#!/bin/bash -e
#!/bin/bash -ex
# SPDX-FileCopyrightText: 2025 eden Emulator Project
# SPDX-FileCopyrightText: 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
if [ "$DEVEL" != "true" ]; then
export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" -DENABLE_QT_UPDATE_CHECKER=ON)
if [ "$COMPILER" == "clang" ]
then
EXTRA_CMAKE_FLAGS+=(
-DCMAKE_CXX_COMPILER=clang-cl
-DCMAKE_C_COMPILER=clang-cl
-DCMAKE_CXX_FLAGS="-O3"
-DCMAKE_C_FLAGS="-O3"
)
BUILD_TYPE="RelWithDebInfo"
fi
if [ "$CCACHE" = "true" ]; then
export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" -DUSE_CCACHE=ON)
fi
[ -z "$WINDEPLOYQT" ] && { echo "WINDEPLOYQT environment variable required."; exit 1; }
if [ "$BUNDLE_QT" = "true" ]; then
export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" -DYUZU_USE_BUNDLED_QT=ON)
else
export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" -DYUZU_USE_BUNDLED_QT=OFF)
fi
if [ -z "$BUILD_TYPE" ]; then
export BUILD_TYPE="Release"
fi
if [ "$WINDEPLOYQT" == "" ]; then
echo "You must supply the WINDEPLOYQT environment variable."
exit 1
fi
if [ "$USE_WEBENGINE" = "true" ]; then
WEBENGINE=ON
else
WEBENGINE=OFF
fi
if [ "$USE_MULTIMEDIA" = "false" ]; then
MULTIMEDIA=OFF
else
MULTIMEDIA=ON
fi
export EXTRA_CMAKE_FLAGS=("${EXTRA_CMAKE_FLAGS[@]}" $@)
echo $EXTRA_CMAKE_FLAGS
mkdir -p build && cd build
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE="$BUILD_TYPE" \
-DENABLE_QT_TRANSLATION=ON \
-DCMAKE_BUILD_TYPE="${BUILD_TYPE:-Release}" \
-DENABLE_QT_TRANSLATION=ON \
-DUSE_DISCORD_PRESENCE=ON \
-DYUZU_USE_BUNDLED_SDL2=ON \
-DBUILD_TESTING=OFF \
-DYUZU_TESTS=OFF \
-DDYNARMIC_TESTS=OFF \
-DYUZU_CMD=OFF \
-DYUZU_ROOM_STANDALONE=OFF \
-DYUZU_USE_QT_MULTIMEDIA=$MULTIMEDIA \
-DYUZU_USE_QT_WEB_ENGINE=$WEBENGINE \
-DYUZU_USE_QT_MULTIMEDIA=${USE_MULTIMEDIA:-false} \
-DYUZU_USE_QT_WEB_ENGINE=${USE_WEBENGINE:-false} \
-DYUZU_ENABLE_LTO=ON \
-DCMAKE_EXE_LINKER_FLAGS=" /LTCG" \
-DDYNARMIC_ENABLE_LTO=ON \
"${EXTRA_CMAKE_FLAGS[@]}"
-DYUZU_USE_BUNDLED_QT=${BUNDLE_QT:-false} \
-DUSE_CCACHE=${CCACHE:-false} \
-DENABLE_QT_UPDATE_CHECKER=${DEVEL:-true} \
"${EXTRA_CMAKE_FLAGS[@]}" \
"$@"
ninja
@ -62,4 +48,5 @@ rm -f bin/*.pdb
set -e
$WINDEPLOYQT --release --no-compiler-runtime --no-opengl-sw --no-system-dxc-compiler --no-system-d3d-compiler --dir pkg bin/eden.exe
cp bin/* pkg

42
.ci/windows/install-msvc.ps1 Executable file
View file

@ -0,0 +1,42 @@
# SPDX-FileCopyrightText: 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
$ErrorActionPreference = "Stop"
# Check if running as administrator
if (-not ([bool](net session 2>$null))) {
Write-Host "This script must be run with administrator privileges!"
Exit 1
}
$VSVer = "17"
$ExeFile = "vs_BuildTools.exe"
$Uri = "https://aka.ms/vs/$VSVer/release/$ExeFile"
$Destination = "./$ExeFile"
Write-Host "Downloading Visual Studio Build Tools from $Uri"
$WebClient = New-Object System.Net.WebClient
$WebClient.DownloadFile($Uri, $Destination)
Write-Host "Finished downloading $ExeFile"
$VSROOT = "C:/VSBuildTools/$VSVer"
$Arguments = @(
"--installPath `"$VSROOT`"", # set custom installation path
"--quiet", # suppress UI
"--wait", # wait for installation to complete
"--norestart", # prevent automatic restart
"--add Microsoft.VisualStudio.Workload.VCTools", # add C++ build tools workload
"--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64", # add core x86/x64 C++ tools
"--add Microsoft.VisualStudio.Component.Windows10SDK.19041" # add specific Windows SDK
)
Write-Host "Installing Visual Studio Build Tools"
$InstallProcess = Start-Process -FilePath $Destination -NoNewWindow -PassThru -Wait -ArgumentList $Arguments
$ExitCode = $InstallProcess.ExitCode
if ($ExitCode -ne 0) {
Write-Host "Error installing Visual Studio Build Tools (Error: $ExitCode)"
Exit $ExitCode
}
Write-Host "Finished installing Visual Studio Build Tools"

View file

@ -3,6 +3,12 @@
$ErrorActionPreference = "Stop"
# Check if running as administrator
if (-not ([bool](net session 2>$null))) {
Write-Host "This script must be run with administrator privileges!"
Exit 1
}
$VulkanSDKVer = "1.4.321.1"
$ExeFile = "vulkansdk-windows-X64-$VulkanSDKVer.exe"
$Uri = "https://sdk.lunarg.com/sdk/download/$VulkanSDKVer/windows/$ExeFile"

View file

@ -0,0 +1,13 @@
diff --git a/libs/cobalt/include/boost/cobalt/concepts.hpp b/libs/cobalt/include/boost/cobalt/concepts.hpp
index d49f2ec..a9bdb80 100644
--- a/libs/cobalt/include/boost/cobalt/concepts.hpp
+++ b/libs/cobalt/include/boost/cobalt/concepts.hpp
@@ -62,7 +62,7 @@ struct enable_awaitables
template <typename T>
concept with_get_executor = requires (T& t)
{
- {t.get_executor()} -> asio::execution::executor;
+ t.get_executor();
};

View file

@ -0,0 +1,11 @@
--- a/libs/context/CMakeLists.txt 2025-09-08 00:42:31.303651800 -0400
+++ b/libs/context/CMakeLists.txt 2025-09-08 00:42:40.592184300 -0400
@@ -146,7 +146,7 @@
set(ASM_LANGUAGE ASM)
endif()
elseif(BOOST_CONTEXT_ASSEMBLER STREQUAL armasm)
- set(ASM_LANGUAGE ASM_ARMASM)
+ set(ASM_LANGUAGE ASM_MARMASM)
else()
set(ASM_LANGUAGE ASM_MASM)
endif()

View file

@ -0,0 +1,14 @@
diff --git a/libs/context/CMakeLists.txt b/libs/context/CMakeLists.txt
index 8210f65..0e59dd7 100644
--- a/libs/context/CMakeLists.txt
+++ b/libs/context/CMakeLists.txt
@@ -186,7 +186,8 @@ if(BOOST_CONTEXT_IMPLEMENTATION STREQUAL "fcontext")
set_property(SOURCE ${ASM_SOURCES} APPEND PROPERTY COMPILE_OPTIONS "/safeseh")
endif()
- else() # masm
+ # armasm doesn't support most of these options
+ elseif(NOT BOOST_CONTEXT_ASSEMBLER STREQUAL armasm) # masm
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set_property(SOURCE ${ASM_SOURCES} APPEND PROPERTY COMPILE_OPTIONS "-x" "assembler-with-cpp")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")

View file

@ -1,47 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8c1761f..52c4ca4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -69,42 +69,3 @@ endif()
if(CPP_JWT_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
-
-# ##############################################################################
-# INSTALL
-# ##############################################################################
-
-include(GNUInstallDirs)
-include(CMakePackageConfigHelpers)
-set(CPP_JWT_CONFIG_INSTALL_DIR ${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME})
-
-install(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}Targets)
-install(
- EXPORT ${PROJECT_NAME}Targets
- DESTINATION ${CPP_JWT_CONFIG_INSTALL_DIR}
- NAMESPACE ${PROJECT_NAME}::
- COMPONENT dev)
-configure_package_config_file(cmake/Config.cmake.in ${PROJECT_NAME}Config.cmake
- INSTALL_DESTINATION ${CPP_JWT_CONFIG_INSTALL_DIR}
- NO_SET_AND_CHECK_MACRO)
-write_basic_package_version_file(${PROJECT_NAME}ConfigVersion.cmake
- COMPATIBILITY SameMajorVersion
- ARCH_INDEPENDENT)
-install(
- FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake
- ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
- DESTINATION ${CPP_JWT_CONFIG_INSTALL_DIR}
- COMPONENT dev)
-
-if(NOT CPP_JWT_USE_VENDORED_NLOHMANN_JSON)
- set(CPP_JWT_VENDORED_NLOHMANN_JSON_INSTALL_PATTERN PATTERN "json" EXCLUDE)
-endif()
-install(
- DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/jwt/
- DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/jwt
- COMPONENT dev
- FILES_MATCHING
- PATTERN "*.hpp"
- PATTERN "*.ipp"
- PATTERN "test" EXCLUDE
- ${CPP_JWT_VENDORED_NLOHMANN_JSON_INSTALL_PATTERN})

View file

@ -1,13 +0,0 @@
diff --git a/include/jwt/algorithm.hpp b/include/jwt/algorithm.hpp
index 0e3b843..1156e6a 100644
--- a/include/jwt/algorithm.hpp
+++ b/include/jwt/algorithm.hpp
@@ -64,6 +64,8 @@ using verify_func_t = verify_result_t (*) (const jwt::string_view key,
const jwt::string_view head,
const jwt::string_view jwt_sign);
+verify_result_t is_secret_a_public_key(const jwt::string_view secret);
+
namespace algo {
//Me: TODO: All these can be done using code generaion.

View file

@ -1,10 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5dad9e9..760a1b2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required (VERSION 3.2.0)
+cmake_minimum_required (VERSION 3.10)
project (DiscordRPC)
include(GNUInstallDirs)

View file

@ -1,40 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 760a1b2..540d643 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -12,20 +12,6 @@ file(GLOB_RECURSE ALL_SOURCE_FILES
src/*.cpp src/*.h src/*.c
)
-# Set CLANG_FORMAT_SUFFIX if you are using custom clang-format, e.g. clang-format-5.0
-find_program(CLANG_FORMAT_CMD clang-format${CLANG_FORMAT_SUFFIX})
-
-if (CLANG_FORMAT_CMD)
- add_custom_target(
- clangformat
- COMMAND ${CLANG_FORMAT_CMD}
- -i -style=file -fallback-style=none
- ${ALL_SOURCE_FILES}
- DEPENDS
- ${ALL_SOURCE_FILES}
- )
-endif(CLANG_FORMAT_CMD)
-
# thirdparty stuff
execute_process(
COMMAND mkdir ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 290d761..cd2cc92 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -120,10 +120,6 @@ if (${BUILD_SHARED_LIBS})
target_compile_definitions(discord-rpc PRIVATE -DDISCORD_BUILDING_SDK)
endif(${BUILD_SHARED_LIBS})
-if (CLANG_FORMAT_CMD)
- add_dependencies(discord-rpc clangformat)
-endif(CLANG_FORMAT_CMD)
-
# install
install(

View file

@ -1,31 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 540d643..5d12f3d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,12 +17,14 @@ execute_process(
COMMAND mkdir ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty
ERROR_QUIET
)
+# new commit that fixes c++17
+set(RAPIDJSON_SHA 3b2441b87f99ab65f37b141a7b548ebadb607b96)
-find_file(RAPIDJSONTEST NAMES rapidjson rapidjson-1.1.0 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty CMAKE_FIND_ROOT_PATH_BOTH)
+find_file(RAPIDJSONTEST NAMES rapidjson rapidjson-${RAPIDJSON_SHA} PATHS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty CMAKE_FIND_ROOT_PATH_BOTH)
if (NOT RAPIDJSONTEST)
message("no rapidjson, download")
- set(RJ_TAR_FILE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/v1.1.0.tar.gz)
- file(DOWNLOAD https://github.com/miloyip/rapidjson/archive/v1.1.0.tar.gz ${RJ_TAR_FILE})
+ set(RJ_TAR_FILE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/${RAPIDJSON_SHA}.tar.gz)
+ file(DOWNLOAD https://github.com/miloyip/rapidjson/archive/${RAPIDJSON_SHA}.tar.gz ${RJ_TAR_FILE})
execute_process(
COMMAND ${CMAKE_COMMAND} -E tar xzf ${RJ_TAR_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty
@@ -30,7 +32,7 @@ if (NOT RAPIDJSONTEST)
file(REMOVE ${RJ_TAR_FILE})
endif(NOT RAPIDJSONTEST)
-find_file(RAPIDJSON NAMES rapidjson rapidjson-1.1.0 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty CMAKE_FIND_ROOT_PATH_BOTH)
+find_file(RAPIDJSON NAMES rapidjson rapidjson-${RAPIDJSON_SHA} PATHS ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty CMAKE_FIND_ROOT_PATH_BOTH)
add_library(rapidjson STATIC IMPORTED ${RAPIDJSON})

View file

@ -1,22 +0,0 @@
From e59d30b7b12e1d04cc2fc9c6219e35bda447c17e Mon Sep 17 00:00:00 2001
From: Lizzie <159065448+Lizzie841@users.noreply.github.com>
Date: Fri, 16 May 2025 04:12:13 +0100
Subject: [PATCH] Update CMakeLists.txt
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b5f4c4f..c5c6f31 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,7 +24,7 @@ target_include_directories(
target_compile_features(unordered_dense INTERFACE cxx_std_17)
-if(_unordered_dense_is_toplevel_project)
+if(_unordered_dense_is_toplevel_project OR UNORDERED_DENSE_INSTALL)
# locations are provided by GNUInstallDirs
install(
TARGETS unordered_dense

View file

@ -15,6 +15,21 @@ elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(PLATFORM_LINUX ON)
endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
set(CXX_CLANG ON)
if (MSVC)
set(CXX_CLANG_CL ON)
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CXX_GCC ON)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set(CXX_CL ON)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "IntelLLVM")
set(CXX_ICC ON)
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
set(CXX_APPLE ON)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules")
if (PLATFORM_SUN)
@ -29,6 +44,77 @@ if (PLATFORM_SUN)
endif()
endif()
# Detect current compilation architecture and create standard definitions
# =======================================================================
include(CheckSymbolExists)
function(detect_architecture symbol arch)
if (NOT DEFINED ARCHITECTURE)
set(CMAKE_REQUIRED_QUIET 1)
check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch})
unset(CMAKE_REQUIRED_QUIET)
# The output variable needs to be unique across invocations otherwise
# CMake's crazy scope rules will keep it defined
if (ARCHITECTURE_${arch})
set(ARCHITECTURE "${arch}" PARENT_SCOPE)
set(ARCHITECTURE_${arch} 1 PARENT_SCOPE)
add_definitions(-DARCHITECTURE_${arch}=1)
endif()
endif()
endfunction()
if (NOT ENABLE_GENERIC)
if (MSVC)
detect_architecture("_M_AMD64" x86_64)
detect_architecture("_M_IX86" x86)
detect_architecture("_M_ARM" arm)
detect_architecture("_M_ARM64" arm64)
else()
detect_architecture("__x86_64__" x86_64)
detect_architecture("__i386__" x86)
detect_architecture("__arm__" arm)
detect_architecture("__aarch64__" arm64)
endif()
endif()
if (NOT DEFINED ARCHITECTURE)
set(ARCHITECTURE "GENERIC")
set(ARCHITECTURE_GENERIC 1)
add_definitions(-DARCHITECTURE_GENERIC=1)
endif()
message(STATUS "Target architecture: ${ARCHITECTURE}")
if (MSVC AND ARCHITECTURE_x86)
message(FATAL_ERROR "Attempting to build with the x86 environment is not supported. \
This can typically happen if you used the Developer Command Prompt from the start menu;\
instead, run vcvars64.bat directly, located at C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat")
endif()
if (CXX_CLANG_CL)
add_compile_options(
# clang-cl prints literally 10000+ warnings without this
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-command-line-argument>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unsafe-buffer-usage>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-unused-value>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-extra-semi-stmt>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-sign-conversion>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-reserved-identifier>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-deprecated-declarations>
$<$<COMPILE_LANGUAGE:C,CXX>:-Wno-cast-function-type-mismatch>
$<$<COMPILE_LANGUAGE:C,CXX>:/EHsc> # thanks microsoft
)
if (ARCHITECTURE_x86_64)
add_compile_options(
# Required CPU features for amd64
$<$<COMPILE_LANGUAGE:C,CXX>:-msse4.1>
$<$<COMPILE_LANGUAGE:C,CXX>:-mcx16>
)
endif()
endif()
set(CPM_SOURCE_CACHE ${CMAKE_SOURCE_DIR}/.cache/cpm)
include(DownloadExternals)
@ -36,7 +122,7 @@ include(CMakeDependentOption)
include(CTest)
# Disable Warnings as Errors for MSVC
if (MSVC)
if (CXX_CL)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX-")
endif()
@ -58,7 +144,7 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_EXTERNAL_SDL2 "Compile external SDL2" ${EXT_DEFA
cmake_dependent_option(ENABLE_LIBUSB "Enable the use of LibUSB" ON "NOT ANDROID" OFF)
option(ENABLE_OPENGL "Enable OpenGL" ON)
cmake_dependent_option(ENABLE_OPENGL "Enable OpenGL" ON "NOT WIN32 OR NOT ARCHITECTURE_arm64" OFF)
mark_as_advanced(FORCE ENABLE_OPENGL)
option(ENABLE_QT "Enable the Qt frontend" ON)
@ -118,6 +204,8 @@ CMAKE_DEPENDENT_OPTION(YUZU_USE_FASTER_LD "Check if a faster linker is available
CMAKE_DEPENDENT_OPTION(USE_SYSTEM_MOLTENVK "Use the system MoltenVK lib (instead of the bundled one)" OFF "APPLE" OFF)
set(YUZU_TZDB_PATH "" CACHE STRING "Path to a pre-downloaded timezone database")
set(DEFAULT_ENABLE_OPENSSL ON)
if (ANDROID OR WIN32 OR APPLE OR PLATFORM_SUN)
# - Windows defaults to the Schannel backend.
@ -212,54 +300,6 @@ if (NOT EXISTS ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.
file(WRITE ${PROJECT_BINARY_DIR}/dist/compatibility_list/compatibility_list.json "")
endif()
# Detect current compilation architecture and create standard definitions
# =======================================================================
include(CheckSymbolExists)
function(detect_architecture symbol arch)
if (NOT DEFINED ARCHITECTURE)
set(CMAKE_REQUIRED_QUIET 1)
check_symbol_exists("${symbol}" "" ARCHITECTURE_${arch})
unset(CMAKE_REQUIRED_QUIET)
# The output variable needs to be unique across invocations otherwise
# CMake's crazy scope rules will keep it defined
if (ARCHITECTURE_${arch})
set(ARCHITECTURE "${arch}" PARENT_SCOPE)
set(ARCHITECTURE_${arch} 1 PARENT_SCOPE)
add_compile_definitions(ARCHITECTURE_${arch}=1)
endif()
endif()
endfunction()
if (NOT ENABLE_GENERIC)
if (MSVC)
detect_architecture("_M_AMD64" x86_64)
detect_architecture("_M_IX86" x86)
detect_architecture("_M_ARM" arm)
detect_architecture("_M_ARM64" arm64)
else()
detect_architecture("__x86_64__" x86_64)
detect_architecture("__i386__" x86)
detect_architecture("__arm__" arm)
detect_architecture("__aarch64__" arm64)
endif()
endif()
if (NOT DEFINED ARCHITECTURE)
set(ARCHITECTURE "GENERIC")
set(ARCHITECTURE_GENERIC 1)
add_compile_definitions(ARCHITECTURE_GENERIC=1)
endif()
message(STATUS "Target architecture: ${ARCHITECTURE}")
if (MSVC AND ARCHITECTURE_x86)
message(FATAL_ERROR "Attempting to build with the x86 environment is not supported. \
This can typically happen if you used the Developer Command Prompt from the start menu;\
instead, run vcvars64.bat directly, located at C:/Program Files/Microsoft Visual Studio/2022/Community/VC/Auxiliary/Build/vcvars64.bat")
endif()
if (UNIX)
add_compile_definitions(YUZU_UNIX=1)
endif()
@ -274,7 +314,7 @@ if (YUZU_ROOM)
endif()
# Build/optimization presets
if (PLATFORM_LINUX)
if (PLATFORM_LINUX OR CXX_CLANG)
if (ARCHITECTURE_x86_64)
set(YUZU_BUILD_PRESET "custom" CACHE STRING "Build preset to use. One of: custom, generic, v3, zen2, zen4, native")
if (${YUZU_BUILD_PRESET} STREQUAL "generic")
@ -341,6 +381,7 @@ if (YUZU_USE_CPM)
# boost
set(BOOST_INCLUDE_LIBRARIES algorithm icl pool container heap asio headers process filesystem crc variant)
AddJsonPackage(boost)
# really annoying thing where boost::headers doesn't work with cpm
@ -350,13 +391,10 @@ if (YUZU_USE_CPM)
if (Boost_ADDED)
if (MSVC OR ANDROID)
add_compile_definitions(YUZU_BOOST_v1)
else()
message(WARNING "Using bundled Boost on a non-MSVC or Android system is not recommended. You are strongly encouraged to install Boost through your system's package manager.")
endif()
if (NOT MSVC)
if (NOT MSVC OR CXX_CLANG)
# boost sucks
# Solaris (and probably other NIXes) need explicit pthread definition
if (PLATFORM_SUN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthreads")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthreads")
@ -409,6 +447,14 @@ if (YUZU_USE_CPM)
# Opus
AddJsonPackage(opus)
if (Opus_ADDED)
if (MSVC AND CXX_CLANG)
target_compile_options(opus PRIVATE
-Wno-implicit-function-declaration
)
endif()
endif()
else()
# Enforce the search mode of non-required packages for better and shorter failure messages
find_package(fmt 8 REQUIRED)
@ -421,6 +467,7 @@ else()
find_package(Opus 1.3 MODULE REQUIRED)
find_package(ZLIB 1.2 REQUIRED)
find_package(zstd 1.5 REQUIRED MODULE)
find_package(Boost 1.79.0 REQUIRED headers context system fiber)
if (YUZU_TESTS)
find_package(Catch2 3.0.1 REQUIRED)
@ -441,6 +488,10 @@ endif()
# DiscordRPC
if (USE_DISCORD_PRESENCE)
if (ARCHITECTURE_arm64)
add_compile_definitions(RAPIDJSON_ENDIAN=RAPIDJSON_LITTLEENDIAN)
endif()
AddJsonPackage(discord-rpc)
target_include_directories(discord-rpc INTERFACE ${discord-rpc_SOURCE_DIR}/include)
@ -548,6 +599,10 @@ find_package(libusb)
find_package(VulkanMemoryAllocator)
find_package(SPIRV-Tools)
if (ARCHITECTURE_x86 OR ARCHITECTURE_x86_64)
find_package(xbyak)
endif()
if (ENABLE_WEB_SERVICE)
find_package(httplib)
endif()
@ -748,6 +803,27 @@ if (MSVC AND CMAKE_GENERATOR STREQUAL "Ninja")
)
endif()
# Adjustments for clang-cl
if (MSVC AND CXX_CLANG)
if (ARCHITECTURE_x86_64)
set(FILE_ARCH x86_64)
elseif (ARCHITECTURE_arm64)
set(FILE_ARCH aarch64)
else()
message(FATAL_ERROR "clang-cl: Unsupported architecture ${ARCHITECTURE}")
endif()
AddJsonPackage(llvm-mingw)
set(LIB_PATH "${llvm-mingw_SOURCE_DIR}/libclang_rt.builtins-${FILE_ARCH}.a")
add_library(llvm-mingw-runtime STATIC IMPORTED)
set_target_properties(llvm-mingw-runtime PROPERTIES
IMPORTED_LOCATION "${LIB_PATH}"
)
link_libraries(llvm-mingw-runtime)
endif()
if (YUZU_USE_FASTER_LD AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# We will assume that if the compiler is GCC, it will attempt to use ld.bfd by default.
# Try to pick a faster linker.

View file

@ -11,10 +11,17 @@ function(download_bundled_external remote_path lib_name cpm_key prefix_var versi
set(package_repo "no_platform")
set(package_extension "no_platform")
# TODO(crueter): Need to convert ffmpeg to a CI.
if (WIN32 OR FORCE_WIN_ARCHIVES)
set(CACHE_KEY "windows")
set(package_repo "ext-windows-bin/raw/master/")
set(package_extension ".7z")
if (ARCHITECTURE_arm64)
set(CACHE_KEY "windows")
set(package_repo "ext-windows-arm64-bin/raw/master/")
set(package_extension ".zip")
elseif(ARCHITECTURE_x86_64)
set(CACHE_KEY "windows")
set(package_repo "ext-windows-bin/raw/master/")
set(package_extension ".7z")
endif()
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(CACHE_KEY "linux")
set(package_repo "ext-linux-bin/raw/master/")

View file

@ -0,0 +1,11 @@
# SPDX-FileCopyrightText: 2025 Eden Emulator Project
# SPDX-License-Identifier: GPL-3.0-or-later
include(FindPackageHandleStandardArgs)
find_package(PkgConfig QUIET)
pkg_search_module(sirit QUIET IMPORTED_TARGET sirit)
find_package_handle_standard_args(sirit
REQUIRED_VARS sirit_LINK_LIBRARIES
VERSION_VAR sirit_VERSION
)

View file

@ -35,4 +35,6 @@ set(REPO_NAME "Eden")
set(BUILD_ID ${GIT_BRANCH})
set(BUILD_FULLNAME "${REPO_NAME} ${BUILD_VERSION} ")
set(CXX_COMPILER "${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION}")
configure_file(scm_rev.cpp.in scm_rev.cpp @ONLY)

View file

@ -12,16 +12,25 @@ set(__windows_copy_files YES)
# Any number of files to copy from SOURCE_DIR to DEST_DIR can be specified after DEST_DIR.
# This copying happens post-build.
function(windows_copy_files TARGET SOURCE_DIR DEST_DIR)
# windows commandline expects the / to be \ so switch them
string(REPLACE "/" "\\\\" SOURCE_DIR ${SOURCE_DIR})
string(REPLACE "/" "\\\\" DEST_DIR ${DEST_DIR})
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
function(windows_copy_files TARGET SOURCE_DIR DEST_DIR)
# windows commandline expects the / to be \ so switch them
string(REPLACE "/" "\\\\" SOURCE_DIR ${SOURCE_DIR})
string(REPLACE "/" "\\\\" DEST_DIR ${DEST_DIR})
# /NJH /NJS /NDL /NFL /NC /NS /NP - Silence any output
# cmake adds an extra check for command success which doesn't work too well with robocopy
# so trick it into thinking the command was successful with the || cmd /c "exit /b 0"
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR}
COMMAND robocopy ${SOURCE_DIR} ${DEST_DIR} ${ARGN} /NJH /NJS /NDL /NFL /NC /NS /NP || cmd /c "exit /b 0"
)
endfunction()
# /NJH /NJS /NDL /NFL /NC /NS /NP - Silence any output
# cmake adds an extra check for command success which doesn't work too well with robocopy
# so trick it into thinking the command was successful with the || cmd /c "exit /b 0"
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR}
COMMAND robocopy ${SOURCE_DIR} ${DEST_DIR} ${ARGN} /NJH /NJS /NDL /NFL /NC /NS /NP || cmd /c "exit /b 0"
)
endfunction()
else()
function(windows_copy_files TARGET SOURCE_DIR DEST_DIR)
add_custom_command(TARGET ${TARGET} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E make_directory ${DEST_DIR}
COMMAND cp -ra ${SOURCE_DIR}/. ${DEST_DIR}
)
endfunction()
endif()

View file

@ -11,10 +11,15 @@
"package": "Boost",
"repo": "boostorg/boost",
"tag": "boost-%VERSION%",
"artifact": "%TAG%-cmake.7z",
"hash": "e5b049e5b61964480ca816395f63f95621e66cb9bcf616a8b10e441e0e69f129e22443acb11e77bc1e8170f8e4171b9b7719891efc43699782bfcd4b3a365f01",
"git_version": "1.88.0",
"version": "1.57"
"artifact": "%TAG%-cmake.tar.xz",
"hash": "4fb7f6fde92762305aad8754d7643cd918dd1f3f67e104e9ab385b18c73178d72a17321354eb203b790b6702f2cf6d725a5d6e2dfbc63b1e35f9eb59fb42ece9",
"git_version": "1.89.0",
"version": "1.57",
"patches": [
"0001-clang-cl.patch",
"0002-use-marmasm.patch",
"0003-armasm-options.patch"
]
},
"fmt": {
"repo": "fmtlib/fmt",
@ -77,16 +82,13 @@
},
"opus": {
"package": "Opus",
"repo": "xiph/opus",
"sha": "5ded705cf4",
"hash": "0dc89e58ddda1f3bc6a7037963994770c5806c10e66f5cc55c59286fc76d0544fe4eca7626772b888fd719f434bc8a92f792bdb350c807968b2ac14cfc04b203",
"repo": "crueter/opus",
"sha": "ab19c44fad",
"hash": "79d0d015b19e74ce6076197fc32b86fe91d724a0b5a79e86adfc4bdcb946ece384e252adbbf742b74d03040913b70bb0e9556eafa59ef20e42d2f3f4d6f2859a",
"version": "1.3",
"find_args": "MODULE",
"options": [
"OPUS_BUILD_TESTING OFF",
"OPUS_BUILD_PROGRAMS OFF",
"OPUS_INSTALL_PKG_CONFIG_MODULE OFF",
"OPUS_INSTALL_CMAKE_CONFIG_MODULE OFF"
"OPUS_PRESUME_NEON ON"
]
},
"cubeb": {
@ -103,8 +105,8 @@
},
"boost_headers": {
"repo": "boostorg/headers",
"sha": "0456900fad",
"hash": "50cd75dcdfc5f082225cdace058f47b4fb114a47585f7aee1d22236a910a80b667186254c214fa2fcebac67ae6d37ba4b6e695e1faea8affd6fd42a03cf996e3",
"sha": "95930ca8f5",
"hash": "d1dece16f3b209109de02123c537bfe1adf07a62b16c166367e7e5d62e0f7c323bf804c89b3192dd6871bc58a9d879d25a1cc3f7b9da0e497cf266f165816e2a",
"bundled": true
},
"discord-rpc": {
@ -143,5 +145,13 @@
"version": "2.32.8",
"min_version": "2.26.4",
"cmake_filename": "sdl2"
},
"llvm-mingw": {
"repo": "misc/llvm-mingw",
"git_host": "git.crueter.xyz",
"tag": "20250828",
"version": "20250828",
"artifact": "clang-rt-builtins.tar.zst",
"hash": "d902392caf94e84f223766e2cc51ca5fab6cae36ab8dc6ef9ef6a683ab1c483bfcfe291ef0bd38ab16a4ecc4078344fa8af72da2f225ab4c378dee23f6186181"
}
}

262
docs/build/Windows.md vendored
View file

@ -1,149 +1,195 @@
# THIS GUIDE IS INTENDED FOR DEVELOPERS ONLY, SUPPORT WILL ONLY BE GIVEN IF YOU'RE A DEVELOPER.
# ⚠️ This guide is for developers ONLY! Support will be provided to developers ONLY.
## Method I: MSVC Build for Windows
## 📋 Current building methods:
### Minimal Dependencies
* [ Minimal Dependencies](#minimal-dependencies)
* [⚡ Method I: MSVC Build for Windows](#method-i-msvc-build-for-windows)
* [🐧 Method II: MinGW-w64 Build with MSYS2](#method-ii-mingw-w64-build-with-msys2)
* [🖥️ Method III: CLion Environment Setup](#method-iii-clion-environment-setup)
* [💻 Building from the command line with MSVC](#building-from-the-command-line-with-msvc)
* [📜 Building with Scripts](#building-with-scripts)
On Windows, all library dependencies are automatically included within the `externals` folder, or can be downloaded on-demand. To build Eden, you need to install:
---
* **[Visual Studio 2022 Community](https://visualstudio.microsoft.com/downloads/)** - **Make sure to select C++ support in the installer. Make sure to update to the latest version if already installed.**
* **[CMake](https://cmake.org/download/)** - Used to generate Visual Studio project files. Does not matter if either 32-bit or 64-bit version is installed.
* **[Vulkan SDK](https://vulkan.lunarg.com/sdk/home#windows)** - **Make sure to select Latest SDK.**
- A convenience script to install the latest SDK is provided in `.ci\windows\install-vulkan-sdk.ps1`.
![2](https://i.imgur.com/giDwuTm.png)
## Minimal Dependencies
* **Git** - We recommend [Git for Windows](https://gitforwindows.org).
On Windows, **all** library dependencies are **automatically included** within the `externals` folder.
![3](https://i.imgur.com/UeSzkBw.png)
You still need to install:
* While installing Git Bash, you should tell it to include Git in your system path. (Choose the "Git from the command line and also from 3rd-party software" option.) If you missed that, don't worry, you'll just have to manually tell CMake where your git.exe is, since it's used to include version info into the built executable.
* **[CMake](https://cmake.org/download/)** - Used to generate Visual Studio project files.
* **[Vulkan SDK](https://vulkan.lunarg.com/sdk/home#windows)** - Make sure to select **Latest SDK**.
![4](https://i.imgur.com/x0rRs1t.png)
* *A convenience script to install the latest SDK is provided in `.ci/windows/install-vulkan-sdk.ps1`*
* **[Git for Windows](https://gitforwindows.org)** - We recommend installing Git for command line use and version control integration.
### Cloning Eden with Git
<img src="https://i.imgur.com/x0rRs1t.png" width="500">
**Master:**
```cmd
git clone --recursive https://git.eden-emu.dev/eden-emu/eden
cd eden
```
* *While installing Git Bash, select "Git from the command line and also from 3rd-party software". If missed, manually set `git.exe` path in CMake.*
![9](https://i.imgur.com/CcxIAht.png)
---
* *(Note: eden by default downloads to `C:\Users\<user-name>\eden` (Master)
## ⚡ Method I: MSVC Build for Windows
### Building
### a. Prerequisites to MSVC Build
* Open the CMake GUI application and point it to the `eden` (Master)
* **[Visual Studio 2022 Community](https://visualstudio.microsoft.com/downloads/)** - Make sure to **select C++ support** in the installer, or **update to the latest version** if already installed.
![10](https://i.imgur.com/qOslIWv.png)
* *A convenience script to install the **minimal** version (Visual Build Tools) is provided in `.ci/windows/install-msvc.ps1`*
* For the build directory, use a `/build` subdirectory inside the source directory or some other directory of your choice. (Tell CMake to create it.)
---
### b. Clone the eden repository with Git
Open Terminal on
```cmd
git clone https://git.eden-emu.dev/eden-emu/eden
cd eden
```
* *By default `eden` downloads to `C:\Users\<user-name>\eden`*
---
### c. Building
* Open the CMake GUI application and point it to the `eden`
<img src="https://i.imgur.com/qOslIWv.png" width="500">
* For the build directory, use a `build/` subdirectory inside the source directory or some other directory of your choice. (Tell CMake to create it.)
* Click the "Configure" button and choose `Visual Studio 17 2022`, with `x64` for the optional platform.
![12](https://i.imgur.com/DKiREaK.png)
* *(Note: If you used GitHub's own app to clone, run `git submodule update --init --recursive` to get the remaining dependencies)*
<img src="https://i.imgur.com/DKiREaK.png" width="500">
* *(You may also want to disable `YUZU_TESTS` in this case since Catch2 is not yet supported with this.)*
![13](https://user-images.githubusercontent.com/22451773/180585999-07316d6e-9751-4d11-b957-1cf57cd7cd58.png)
<img src="https://user-images.githubusercontent.com/22451773/180585999-07316d6e-9751-4d11-b957-1cf57cd7cd58.png" width="500">
* Click "Generate" to create the project files.
![15](https://i.imgur.com/5LKg92k.png)
<img src="https://i.imgur.com/5LKg92k.png" width="500">
* Open the solution file `yuzu.sln` in Visual Studio 2022, which is located in the build folder.
![16](https://i.imgur.com/208yMml.png)
<img src="https://i.imgur.com/208yMml.png" width="500">
* Depending if you want a graphical user interface or not (`eden` has the graphical user interface, while `eden-cmd` doesn't), select `eden` or `eden-cmd` in the Solution Explorer, right-click and `Set as StartUp Project`.
* * Depending on whether you want a graphical user interface or not, select in the Solution Explorer:
* `eden` (GUI)
* `eden-cmd` (command-line only)
* Then **right-click** and choose `Set as StartUp Project`.
![17](https://i.imgur.com/nPMajnn.png) ![18](https://i.imgur.com/BDMLzRZ.png)
<img src="https://i.imgur.com/nPMajnn.png" height="500">
<img src="https://i.imgur.com/BDMLzRZ.png" height="500">
* Select the appropriate build type, Debug for debug purposes or Release for performance (in case of doubt choose Release).
* Select the appropriate build type, `Debug` for debug purposes or `Release` for performance (in case of doubt choose `Release`).
![19](https://i.imgur.com/qxg4roC.png)
<img src="https://i.imgur.com/qxg4roC.png" width="500">
* Right-click the project you want to build and press Build in the submenu or press F5.
* **Right-click** the project you want to build and press **Build** in the submenu or press `F5`.
![20](https://i.imgur.com/CkQgOFW.png)
<img src="https://i.imgur.com/CkQgOFW.png" height="500">
## Method II: MinGW-w64 Build with MSYS2
---
### Prerequisites to install
## 🐧 Method II: MinGW-w64 Build with MSYS2
* [MSYS2](https://www.msys2.org)
* [Vulkan SDK](https://vulkan.lunarg.com/sdk/home#windows) - **Make sure to select Latest SDK.**
* Make sure to follow the instructions and update to the latest version by running `pacman -Syu` as many times as needed.
### a. Prerequisites to MinGW-w64
### Install eden dependencies for MinGW-w64
* **[MSYS2](https://www.msys2.org)** - A versatile and up-to-date development environment for Windows, providing a Unix-like shell, package manager, and toolchain.
* Open the `MSYS2 MinGW 64-bit` (mingw64.exe) shell
* Download and install all dependencies using: `pacman -Syu git make mingw-w64-x86_64-SDL2 mingw-w64-x86_64-cmake mingw-w64-x86_64-python-pip mingw-w64-x86_64-qt6 mingw-w64-x86_64-toolchain autoconf libtool automake-wrapper`
* Add MinGW binaries to the PATH: `echo 'PATH=/mingw64/bin:$PATH' >> ~/.bashrc`
* Add glslangValidator to the PATH: `echo 'PATH=$(readlink -e /c/VulkanSDK/*/Bin/):$PATH' >> ~/.bashrc`
---
### Clone the eden repository with Git
### b. Install eden dependencies for MinGW-w64
```bash
git clone --recursive https://git.eden-emu.dev/eden-emu/eden
cd eden
```
* Open the `MSYS2 MinGW 64-bit` shell (`mingw64.exe`)
* Download and install all dependencies using:
* `pacman -Syu git make mingw-w64-x86_64-SDL2 mingw-w64-x86_64-cmake mingw-w64-x86_64-python-pip mingw-w64-x86_64-qt6 mingw-w64-x86_64-toolchain autoconf libtool automake-wrapper`
* Add MinGW binaries to the PATH:
* `echo 'PATH=/mingw64/bin:$PATH' >> ~/.bashrc`
* Add VulkanSDK to the PATH:
* `echo 'PATH=$(readlink -e /c/VulkanSDK/*/Bin/):$PATH' >> ~/.bashrc`
### Run the following commands to build eden (dynamically linked build)
---
### c. Clone the eden repository with Git
```cmd
git clone https://git.eden-emu.dev/eden-emu/eden
cd eden
```
---
### d. Building dynamically-linked eden
* This process will generate a *dynamically* linked build
```bash
# Make build dir and enter
mkdir build && cd build
cmake -G "MSYS Makefiles" -DYUZU_TESTS=OFF ..
# Generate CMake Makefiles
cmake .. -G "MSYS Makefiles" -DYUZU_TESTS=OFF
# Build
make -j$(nproc)
# test eden out with
# Run eden!
./bin/eden.exe
```
* *(Note: This build is not a static build meaning that you need to include all of the DLLs with the .exe in order to use it!)*
* *Warning: This build is not a **static** build meaning that you **need** to include all of the DLLs with the .exe in order to use it or other systems!*
e.g.
```Bash
cp externals/ffmpeg-*/bin/*.dll bin/
---
### Additional notes
* Eden doesn't require the rather large Qt dependency, but you will lack a GUI frontend
```bash
# ...
# Generate CMake Makefiles (withou QT)
cmake .. -G "MSYS Makefiles" -DYUZU_TESTS=OFF -DENABLE_QT=no
$ ...
```
Bonus Note: Running programs from inside `MSYS2 MinGW x64` shell has a different %PATH% than directly from explorer. This different %PATH% has the locations of the other DLLs required.
![image](https://user-images.githubusercontent.com/190571/165000848-005e8428-8a82-41b1-bb4d-4ce7797cdac8.png)
* Running programs from inside `MSYS2 MinGW x64` shell has a different `%PATH%` than directly from explorer.
* This different `%PATH%` has the locations of the other DLLs required.
<img src="https://user-images.githubusercontent.com/190571/165000848-005e8428-8a82-41b1-bb4d-4ce7797cdac8.png" width="500">
### Building without Qt (Optional)
---
Doesn't require the rather large Qt dependency, but you will lack a GUI frontend:
## 🖥️ Method III: CLion Environment Setup
* Pass the `-DENABLE_QT=no` flag to cmake
## Method III: CLion Environment Setup
### Minimal Dependencies
To build eden, you need to install the following:
### a. Prerequisites to CLion
* [CLion](https://www.jetbrains.com/clion/) - This IDE is not free; for a free alternative, check Method I
* [Vulkan SDK](https://vulkan.lunarg.com/sdk/home#windows) - Make sure to select the Latest SDK.
### Cloning eden with CLion
---
### b. Cloning eden with CLion
* Clone the Repository:
![1](https://user-images.githubusercontent.com/42481638/216899046-0d41d7d6-8e4d-4ed2-9587-b57088af5214.png)
![2](https://user-images.githubusercontent.com/42481638/216899061-b2ea274a-e88c-40ae-bf0b-4450b46e9fea.png)
![3](https://user-images.githubusercontent.com/42481638/216899076-0e5988c4-d431-4284-a5ff-9ecff973db76.png)
<img src="https://user-images.githubusercontent.com/42481638/216899046-0d41d7d6-8e4d-4ed2-9587-b57088af5214.png" width="500">
<img src="https://user-images.githubusercontent.com/42481638/216899061-b2ea274a-e88c-40ae-bf0b-4450b46e9fea.png" width="500">
<img src="https://user-images.githubusercontent.com/42481638/216899076-0e5988c4-d431-4284-a5ff-9ecff973db76.png" width="500">
---
### Building & Setup
### c. Building & Setup
* Once Cloned, You will be taken to a prompt like the image below:
![4](https://user-images.githubusercontent.com/42481638/216899092-3fe4cec6-a540-44e3-9e1e-3de9c2fffc2f.png)
<img src="https://user-images.githubusercontent.com/42481638/216899092-3fe4cec6-a540-44e3-9e1e-3de9c2fffc2f.png" width="500">
* Set the settings to the image below:
* Change `Build type: Release`
@ -152,42 +198,62 @@ To build eden, you need to install the following:
* Change `Generator: Let CMake decide`
* Change `Build directory: build`
![5](https://user-images.githubusercontent.com/42481638/216899164-6cee8482-3d59-428f-b1bc-e6dc793c9b20.png)
<img src="https://user-images.githubusercontent.com/42481638/216899164-6cee8482-3d59-428f-b1bc-e6dc793c9b20.png" width="500">
* Click OK; now Clion will build a directory and index your code to allow for IntelliSense. Please be patient.
* Once this process has been completed (No loading bar bottom right), you can now build eden
* In the top right, click on the drop-down menu, select all configurations, then select eden
![6](https://user-images.githubusercontent.com/42481638/216899226-975048e9-bc6d-4ec1-bc2d-bd8a1e15ed04.png)
<img src="https://user-images.githubusercontent.com/42481638/216899226-975048e9-bc6d-4ec1-bc2d-bd8a1e15ed04.png" height="500" >
* Now run by clicking the play button or pressing Shift+F10, and eden will auto-launch once built.
![7](https://user-images.githubusercontent.com/42481638/216899275-d514ec6a-e563-470e-81e2-3e04f0429b68.png)
<img src="https://user-images.githubusercontent.com/42481638/216899275-d514ec6a-e563-470e-81e2-3e04f0429b68.png" width="500">
## Building from the command line with MSVC
---
## 💻 Building from the command line with MSVC
```cmd
git clone --recursive https://git.eden-emu.dev/eden-emu/eden
# Clone eden and enter
git clone https://git.eden-emu.dev/eden-emu/eden
cd eden
mkdir build
cd build
cmake .. -G "Visual Studio 17 2022" -A x64
# Make build dir and enter
mkdir build && cd build
# Generate CMake Makefiles
cmake .. -G "Visual Studio 17 2022" -A x64 -DYUZU_TESTS=OFF
# Build
cmake --build . --config Release
```
### Building with Scripts
A convenience script for building is provided in `.ci/windows/build.sh`. You must run this with Bash, e.g. Git Bash or MinGW TTY. To use this script, you must have windeployqt installed (usually bundled with Qt) and set the `WINDEPLOYQT` environment variable to its canonical Bash location, e.g. `WINDEPLOYQT="/c/Qt/6.9.1/msvc2022_64/bin/windeployqt6.exe" .ci/windows/build.sh`.
## 📜 Building with Scripts
Extra CMake flags should be placed in the arguments of the script.
* A convenience script for building is provided in `.ci/windows/build.sh`.
* You must run this with Bash, e.g. Git Bash or MinGW TTY.
* To use this script, you must have `windeployqt` installed (usually bundled with Qt) and set the `WINDEPLOYQT` environment variable to its canonical Bash location:
* `WINDEPLOYQT="/c/Qt/6.9.1/msvc2022_64/bin/windeployqt6.exe" .ci/windows/build.sh`.
* You can use `aqtinstall`, more info on <https://github.com/miurahr/aqtinstall> and <https://ddalcino.github.io/aqt-list-server/>
Additional environment variables can be used to control building:
- `BUILD_TYPE`: Sets the build type to use. Defaults to `Release`
The following environment variables are boolean flags. Set to `true` to enable or `false` to disable:
- `DEVEL` (default FALSE): Disable Qt update checker
- `USE_WEBENGINE` (default FALSE): Enable Qt WebEngine
- `USE_MULTIMEDIA` (default TRUE): Enable Qt Multimedia
- `BUNDLE_QT` (default FALSE): Use bundled Qt
* Note that using system Qt requires you to include the Qt CMake directory in `CMAKE_PREFIX_PATH`, e.g. `.ci/windows/build.sh -DCMAKE_PREFIX_PATH=C:/Qt/6.9.0/msvc2022_64/lib/cmake/Qt6`
* Extra CMake flags should be placed in the arguments of the script.
#### Additional environment variables can be used to control building:
* `BUILD_TYPE` (default `Release`): Sets the build type to use.
* The following environment variables are boolean flags. Set to `true` to enable or `false` to disable:
* `DEVEL` (default FALSE): Disable Qt update checker
* `USE_WEBENGINE` (default FALSE): Enable Qt WebEngine
* `USE_MULTIMEDIA` (default TRUE): Enable Qt Multimedia
* `BUNDLE_QT` (default FALSE): Use bundled Qt
* Note that using **system Qt** requires you to include the Qt CMake directory in `CMAKE_PREFIX_PATH`
* `.ci/windows/build.sh -DCMAKE_PREFIX_PATH=C:/Qt/6.9.0/msvc2022_64/lib/cmake/Qt6`
* After building, a zip can be packaged via `.ci/windows/package.sh`. You must have 7-zip installed and in your PATH.
* The resulting zip will be placed into `artifacts` in the source directory.
After building, a zip can be packaged via `.ci/windows/package.sh`. Note that you must have 7-zip installed and in your PATH. The resulting zip will be placed into `artifacts` in the source directory.

View file

@ -63,7 +63,14 @@ if (mbedtls_ADDED)
if (NOT MSVC)
target_compile_options(mbedcrypto PRIVATE
-Wno-unused-but-set-variable
-Wno-string-concatenation)
-Wno-string-concatenation
)
elseif(CXX_CLANG)
foreach(TARGET mbedtls mbedcrypto mbedx509)
target_compile_options(${TARGET} PRIVATE
-w
)
endforeach()
endif()
endif()
@ -84,6 +91,8 @@ if(MSVC AND USE_CCACHE AND sirit_ADDED)
list(FILTER _opts EXCLUDE REGEX "/Zi")
list(APPEND _opts "/Z7")
set_target_properties(sirit PROPERTIES COMPILE_OPTIONS "${_opts}")
elseif(MSVC AND CXX_CLANG)
target_compile_options(sirit PRIVATE -Wno-error=unused-command-line-argument)
endif()
# httplib
@ -136,8 +145,16 @@ add_subdirectory(nx_tzdb)
# VMA
AddJsonPackage(vulkan-memory-allocator)
if (VulkanMemoryAllocator_ADDED AND MSVC)
target_compile_options(VulkanMemoryAllocator INTERFACE /wd4189)
if (VulkanMemoryAllocator_ADDED)
if (CXX_CLANG)
target_compile_options(VulkanMemoryAllocator INTERFACE
-Wno-unused-variable
)
elseif(MSVC)
target_compile_options(VulkanMemoryAllocator INTERFACE
/wd4189
)
endif()
endif()
if (NOT TARGET LLVM::Demangle)

View file

@ -1,12 +1,9 @@
{
"mbedtls": {
"repo": "Mbed-TLS/mbedtls",
"sha": "8c88150ca1",
"hash": "769ad1e94c570671071e1f2a5c0f1027e0bf6bcdd1a80ea8ac970f2c86bc45ce4e31aa88d6d8110fc1bed1de81c48bc624df1b38a26f8b340a44e109d784a966",
"find_args": "MODULE",
"patches": [
"0001-cmake-version.patch"
]
"repo": "eden-emulator/mbedtls",
"sha": "ce4f81f4a9",
"hash": "f2e7f887651b28745e508149214d409fd7cfdb92cb94b4146b47ff1e0fc09e47143f203ac18e34c2c1814b5bd031d04c74828676c0d4342920a2ddb7fd35e9a5",
"find_args": "MODULE"
},
"spirv-headers": {
"package": "SPIRV-Headers",
@ -18,6 +15,7 @@
"repo": "eden-emulator/sirit",
"sha": "db1f1e8ab5",
"hash": "73eb3a042848c63a10656545797e85f40d142009dfb7827384548a385e1e28e1ac72f42b25924ce530d58275f8638554281e884d72f9c7aaf4ed08690a414b05",
"find_args": "MODULE",
"options": [
"SIRIT_USE_SYSTEM_SPIRV_HEADERS ON"
]
@ -29,18 +27,12 @@
},
"cpp-jwt": {
"version": "1.4",
"repo": "arun11299/cpp-jwt",
"sha": "a54fa08a3b",
"hash": "a90f7e594ada0c7e49d5ff9211c71097534e7742a8e44bf0851b0362642a7271d53f5d83d04eeaae2bad17ef3f35e09e6818434d8eaefa038f3d1f7359d0969a",
"repo": "crueter/cpp-jwt",
"sha": "9eaea6328f",
"hash": "e237d92c59ebbf0dc8ac0bae3bc80340e1e9cf430e1c1c9638443001118e16de2b3e9036ac4b98105427667b0386d97831415170b68c432438dcad9ef8052de7",
"find_args": "CONFIG",
"options": [
"CPP_JWT_BUILD_EXAMPLES OFF",
"CPP_JWT_BUILD_TESTS OFF",
"CPP_JWT_USE_VENDORED_NLOHMANN_JSON OFF"
],
"patches": [
"0001-no-install.patch",
"0002-missing-decl.patch"
]
},
"vulkan-utility-headers": {
@ -107,12 +99,6 @@
"repo": "martinus/unordered_dense",
"sha": "73f3cbb237",
"hash": "c08c03063938339d61392b687562909c1a92615b6ef39ec8df19ea472aa6b6478e70d7d5e33d4a27b5d23f7806daf57fe1bacb8124c8a945c918c7663a9e8532",
"find_args": "CONFIG",
"options": [
"UNORDERED_DENSE_INSTALL OFF"
],
"patches": [
"0001-cmake.patch"
]
"find_args": "CONFIG"
}
}

View file

@ -33,9 +33,12 @@ if (CAN_BUILD_NX_TZDB AND NOT YUZU_DOWNLOAD_TIME_ZONE_DATA)
set(NX_TZDB_TZ_DIR "${NX_TZDB_BASE_DIR}/zoneinfo")
endif()
# TODO(crueter): This is a terrible solution, but MSVC fails to link without it
# Need to investigate further but I still can't reproduce...
if (MSVC)
if(NOT YUZU_TZDB_PATH STREQUAL "")
set(NX_TZDB_BASE_DIR "${YUZU_TZDB_PATH}")
set(NX_TZDB_TZ_DIR "${NX_TZDB_BASE_DIR}/zoneinfo")
elseif (MSVC)
# TODO(crueter): This is a terrible solution, but MSVC fails to link without it
# Need to investigate further but I still can't reproduce...
set(NX_TZDB_VERSION "250725")
set(NX_TZDB_ARCHIVE "${CPM_SOURCE_CACHE}/nx_tzdb/${NX_TZDB_VERSION}.zip")

View file

@ -183,7 +183,7 @@
}
/* Compiler barrier */
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
#define SSE2NEON_BARRIER() _ReadWriteBarrier()
#else
#define SSE2NEON_BARRIER() \
@ -859,7 +859,7 @@ FORCE_INLINE uint64x2_t _sse2neon_vmull_p64(uint64x1_t _a, uint64x1_t _b)
{
poly64_t a = vget_lane_p64(vreinterpret_p64_u64(_a), 0);
poly64_t b = vget_lane_p64(vreinterpret_p64_u64(_b), 0);
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
__n64 a1 = {a}, b1 = {b};
return vreinterpretq_u64_p128(vmull_p64(a1, b1));
#else
@ -1770,7 +1770,7 @@ FORCE_INLINE void _mm_free(void *addr)
FORCE_INLINE uint64_t _sse2neon_get_fpcr(void)
{
uint64_t value;
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
value = _ReadStatusReg(ARM64_FPCR);
#else
__asm__ __volatile__("mrs %0, FPCR" : "=r"(value)); /* read */
@ -1780,7 +1780,7 @@ FORCE_INLINE uint64_t _sse2neon_get_fpcr(void)
FORCE_INLINE void _sse2neon_set_fpcr(uint64_t value)
{
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
_WriteStatusReg(ARM64_FPCR, value);
#else
__asm__ __volatile__("msr FPCR, %0" ::"r"(value)); /* write */
@ -2249,7 +2249,7 @@ FORCE_INLINE __m128 _mm_or_ps(__m128 a, __m128 b)
FORCE_INLINE void _mm_prefetch(char const *p, int i)
{
(void) i;
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
switch (i) {
case _MM_HINT_NTA:
__prefetch2(p, 1);
@ -4820,7 +4820,7 @@ FORCE_INLINE __m128i _mm_packus_epi16(const __m128i a, const __m128i b)
// https://www.intel.com/content/www/us/en/docs/intrinsics-guide/index.html#text=_mm_pause
FORCE_INLINE void _mm_pause(void)
{
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
__isb(_ARM64_BARRIER_SY);
#else
__asm__ __volatile__("isb\n");
@ -5716,7 +5716,7 @@ FORCE_INLINE __m128d _mm_undefined_pd(void)
#pragma GCC diagnostic ignored "-Wuninitialized"
#endif
__m128d a;
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
a = _mm_setzero_pd();
#endif
return a;
@ -8130,7 +8130,7 @@ FORCE_INLINE int _sse2neon_sido_negative(int res, int lb, int imm8, int bound)
FORCE_INLINE int _sse2neon_clz(unsigned int x)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
unsigned long cnt = 0;
if (_BitScanReverse(&cnt, x))
return 31 - cnt;
@ -8142,7 +8142,7 @@ FORCE_INLINE int _sse2neon_clz(unsigned int x)
FORCE_INLINE int _sse2neon_ctz(unsigned int x)
{
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
unsigned long cnt = 0;
if (_BitScanForward(&cnt, x))
return cnt;
@ -9058,7 +9058,7 @@ FORCE_INLINE __m128i _mm_aeskeygenassist_si128(__m128i a, const int rcon)
// AESE does ShiftRows and SubBytes on A
uint8x16_t u8 = vaeseq_u8(vreinterpretq_u8_m128i(a), vdupq_n_u8(0));
#ifndef _MSC_VER
#if !defined(_MSC_VER) || defined(__clang__)
uint8x16_t dest = {
// Undo ShiftRows step from AESE and extract X1 and X3
u8[0x4], u8[0x1], u8[0xE], u8[0xB], // SubBytes(X1)
@ -9245,7 +9245,7 @@ FORCE_INLINE uint64_t _rdtsc(void)
* bits wide and it is attributed with the flag 'cap_user_time_short'
* is true.
*/
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
val = _ReadStatusReg(ARM64_SYSREG(3, 3, 14, 0, 2));
#else
__asm__ __volatile__("mrs %0, cntvct_el0" : "=r"(val));

View file

@ -18,7 +18,7 @@ set_property(DIRECTORY APPEND PROPERTY
COMPILE_DEFINITIONS $<$<CONFIG:Debug>:_DEBUG> $<$<NOT:$<CONFIG:Debug>>:NDEBUG>)
# Set compilation flags
if (MSVC)
if (MSVC AND NOT CXX_CLANG)
set(CMAKE_CONFIGURATION_TYPES Debug Release CACHE STRING "" FORCE)
# Silence "deprecation" warnings
@ -69,10 +69,6 @@ if (MSVC)
/external:anglebrackets # Treats all headers included by #include <header>, where the header file is enclosed in angle brackets (< >), as external headers
/external:W0 # Sets the default warning level to 0 for external headers, effectively disabling warnings for them.
# Warnings
/W4
/WX-
/we4062 # Enumerator 'identifier' in a switch of enum 'enumeration' is not handled
/we4189 # 'identifier': local variable is initialized but not referenced
/we4265 # 'class': class has virtual functions, but destructor is not virtual
@ -97,6 +93,14 @@ if (MSVC)
/wd4702 # unreachable code (when used with LTO)
)
if (NOT CXX_CLANG)
add_compile_options(
# Warnings
/W4
/WX-
)
endif()
if (USE_CCACHE OR YUZU_USE_PRECOMPILED_HEADERS)
# when caching, we need to use /Z7 to downgrade debug info to use an older but more cacheable format
# Precompiled headers are deleted if not using /Z7. See https://github.com/nanoant/CMakePCHCompiler/issues/21
@ -118,9 +122,13 @@ if (MSVC)
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG /MANIFEST:NO" CACHE STRING "" FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /MANIFEST:NO /INCREMENTAL:NO /OPT:REF,ICF" CACHE STRING "" FORCE)
else()
add_compile_options(
-fwrapv
if (NOT MSVC)
add_compile_options(
-fwrapv
)
endif()
add_compile_options(
-Werror=all
-Werror=extra
-Werror=missing-declarations
@ -133,14 +141,19 @@ else()
-Wno-missing-field-initializers
)
if (CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES IntelLLVM) # Clang or AppleClang
if (CXX_CLANG OR CXX_ICC) # Clang or AppleClang
if (NOT MSVC)
add_compile_options(
-Werror=shadow-uncaptured-local
-Werror=implicit-fallthrough
-Werror=type-limits
)
endif()
add_compile_options(
-Wno-braced-scalar-init
-Wno-unused-private-field
-Wno-nullability-completeness
-Werror=shadow-uncaptured-local
-Werror=implicit-fallthrough
-Werror=type-limits
)
endif()
@ -148,12 +161,12 @@ else()
add_compile_options("-mcx16")
endif()
if (APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
if (APPLE AND CXX_CLANG)
add_compile_options("-stdlib=libc++")
endif()
# GCC bugs
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11" AND CXX_GCC)
# These diagnostics would be great if they worked, but are just completely broken
# and produce bogus errors on external libraries like fmt.
add_compile_options(

View file

@ -193,7 +193,7 @@ void AudioRenderer::Main(std::stop_token stop_token) {
}
}
max_time = std::min(command_buffer.time_limit, max_time);
max_time = (std::min)(command_buffer.time_limit, max_time);
command_list_processor.SetProcessTimeMax(max_time);
if (index == 0) {

View file

@ -73,9 +73,9 @@ constexpr s32 HighestVoicePriority = 0;
constexpr u32 BufferAlignment = 0x40;
constexpr u32 WorkbufferAlignment = 0x1000;
constexpr s32 FinalMixId = 0;
constexpr s32 InvalidDistanceFromFinalMix = std::numeric_limits<s32>::min();
constexpr s32 InvalidDistanceFromFinalMix = (std::numeric_limits<s32>::min)();
constexpr s32 UnusedSplitterId = -1;
constexpr s32 UnusedMixId = std::numeric_limits<s32>::max();
constexpr s32 UnusedMixId = (std::numeric_limits<s32>::max)();
constexpr u32 InvalidNodeId = 0xF0000000;
constexpr s32 InvalidProcessOrder = -1;
constexpr u32 MaxBiquadFilters = 2;

View file

@ -51,7 +51,7 @@ public:
*/
void RegisterBuffers(boost::container::static_vector<AudioBuffer, N>& out_buffers) {
std::scoped_lock l{lock};
const s32 to_register{std::min(std::min(appended_count, BufferAppendLimit),
const s32 to_register{(std::min)((std::min)(appended_count, BufferAppendLimit),
BufferAppendLimit - registered_count)};
for (s32 i = 0; i < to_register; i++) {
@ -175,7 +175,7 @@ public:
}
size_t buffers_to_flush{
std::min(static_cast<u32>(registered_count + appended_count), max_buffers)};
(std::min)(static_cast<u32>(registered_count + appended_count), max_buffers)};
if (buffers_to_flush == 0) {
return 0;
}

View file

@ -45,7 +45,7 @@ u32 AudioDevice::ListAudioDeviceName(std::span<AudioDeviceName> out_buffer) cons
names = device_names;
}
const u32 out_count{static_cast<u32>(std::min(out_buffer.size(), names.size()))};
const u32 out_count{static_cast<u32>((std::min)(out_buffer.size(), names.size()))};
for (u32 i = 0; i < out_count; i++) {
out_buffer[i] = names[i];
}
@ -53,7 +53,7 @@ u32 AudioDevice::ListAudioDeviceName(std::span<AudioDeviceName> out_buffer) cons
}
u32 AudioDevice::ListAudioOutputDeviceName(std::span<AudioDeviceName> out_buffer) const {
const u32 out_count{static_cast<u32>(std::min(out_buffer.size(), output_device_names.size()))};
const u32 out_count{static_cast<u32>((std::min)(out_buffer.size(), output_device_names.size()))};
for (u32 i = 0; i < out_count; i++) {
out_buffer[i] = output_device_names[i];

View file

@ -43,7 +43,7 @@ void BehaviorInfo::AppendError(const ErrorInfo& error) {
}
void BehaviorInfo::CopyErrorInfo(std::span<ErrorInfo> out_errors, u32& out_count) const {
out_count = std::min(error_count, MaxErrors);
out_count = (std::min)(error_count, MaxErrors);
for (size_t i = 0; i < MaxErrors; i++) {
if (i < out_count) {

View file

@ -464,7 +464,7 @@ void CommandBuffer::GenerateDeviceSinkCommand(const s32 node_id, const s16 buffe
s16 max_input{0};
for (u32 i = 0; i < parameter.input_count; i++) {
cmd.inputs[i] = buffer_offset + parameter.inputs[i];
max_input = std::max(max_input, cmd.inputs[i]);
max_input = (std::max)(max_input, cmd.inputs[i]);
}
if (state.upsampler_info != nullptr) {

View file

@ -56,11 +56,11 @@ public:
// Voices
u64 voice_size{0};
if (behavior.IsWaveBufferVer2Supported()) {
voice_size = std::max(std::max(sizeof(AdpcmDataSourceVersion2Command),
voice_size = (std::max)((std::max)(sizeof(AdpcmDataSourceVersion2Command),
sizeof(PcmInt16DataSourceVersion2Command)),
sizeof(PcmFloatDataSourceVersion2Command));
} else {
voice_size = std::max(std::max(sizeof(AdpcmDataSourceVersion1Command),
voice_size = (std::max)((std::max)(sizeof(AdpcmDataSourceVersion1Command),
sizeof(PcmInt16DataSourceVersion1Command)),
sizeof(PcmFloatDataSourceVersion1Command));
}
@ -82,7 +82,7 @@ public:
// Sinks
size +=
params.sinks * std::max(sizeof(DeviceSinkCommand), sizeof(CircularBufferSinkCommand));
params.sinks * (std::max)(sizeof(DeviceSinkCommand), sizeof(CircularBufferSinkCommand));
// Performance
size += (params.effects + params.voices + params.sinks + params.sub_mixes + 1 +

View file

@ -29,8 +29,8 @@ constexpr std::array<u8, 3> PitchBySrcQuality = {4, 8, 4};
template <typename T>
static u32 DecodePcm(Core::Memory::Memory& memory, std::span<s16> out_buffer,
const DecodeArg& req) {
constexpr s32 min{std::numeric_limits<s16>::min()};
constexpr s32 max{std::numeric_limits<s16>::max()};
constexpr s32 min{(std::numeric_limits<s16>::min)()};
constexpr s32 max{(std::numeric_limits<s16>::max)()};
if (req.buffer == 0 || req.buffer_size == 0) {
return 0;
@ -41,7 +41,7 @@ static u32 DecodePcm(Core::Memory::Memory& memory, std::span<s16> out_buffer,
}
auto samples_to_decode{
std::min(req.samples_to_read, req.end_offset - req.start_offset - req.offset)};
(std::min)(req.samples_to_read, req.end_offset - req.start_offset - req.offset)};
u32 channel_count{static_cast<u32>(req.channel_count)};
switch (req.channel_count) {
@ -55,7 +55,7 @@ static u32 DecodePcm(Core::Memory::Memory& memory, std::span<s16> out_buffer,
if constexpr (std::is_floating_point_v<T>) {
for (u32 i = 0; i < samples_to_decode; i++) {
auto sample{static_cast<s32>(samples[i * channel_count + req.target_channel] *
std::numeric_limits<s16>::max())};
(std::numeric_limits<s16>::max)())};
out_buffer[i] = static_cast<s16>(std::clamp(sample, min, max));
}
} else {
@ -79,7 +79,7 @@ static u32 DecodePcm(Core::Memory::Memory& memory, std::span<s16> out_buffer,
if constexpr (std::is_floating_point_v<T>) {
for (u32 i = 0; i < samples_to_decode; i++) {
auto sample{static_cast<s32>(samples[i * channel_count + req.target_channel] *
std::numeric_limits<s16>::max())};
(std::numeric_limits<s16>::max)())};
out_buffer[i] = static_cast<s16>(std::clamp(sample, min, max));
}
} else {
@ -125,7 +125,7 @@ static u32 DecodeAdpcm(Core::Memory::Memory& memory, std::span<s16> out_buffer,
}
auto start_pos{req.start_offset + req.offset};
auto samples_to_process{std::min(req.end_offset - start_pos, req.samples_to_read)};
auto samples_to_process{(std::min)(req.end_offset - start_pos, req.samples_to_read)};
if (samples_to_process == 0) {
return 0;
}
@ -139,7 +139,7 @@ static u32 DecodeAdpcm(Core::Memory::Memory& memory, std::span<s16> out_buffer,
position_in_frame += 2;
}
const auto size{std::max((samples_to_process / 8U) * SamplesPerFrame, 8U)};
const auto size{(std::max)((samples_to_process / 8U) * SamplesPerFrame, 8U)};
Core::Memory::CpuGuestMemory<u8, Core::Memory::GuestMemoryFlags::UnsafeRead> wavebuffer(
memory, req.buffer + position_in_frame / 2, size);
@ -260,7 +260,7 @@ void DecodeFromWaveBuffers(Core::Memory::Memory& memory, const DecodeFromWaveBuf
auto max_remaining_sample_count{
((Common::FixedPoint<17, 15>(TempBufferSize) - fraction) / sample_rate_ratio)
.to_uint_floor()};
max_remaining_sample_count = std::min(max_remaining_sample_count, remaining_sample_count);
max_remaining_sample_count = (std::min)(max_remaining_sample_count, remaining_sample_count);
auto wavebuffers_consumed{voice_state.wave_buffers_consumed};
auto wavebuffer_index{voice_state.wave_buffer_index};
@ -273,7 +273,7 @@ void DecodeFromWaveBuffers(Core::Memory::Memory& memory, const DecodeFromWaveBuf
std::array<s16, TempBufferSize> temp_buffer{};
while (remaining_sample_count > 0) {
const auto samples_to_write{std::min(remaining_sample_count, max_remaining_sample_count)};
const auto samples_to_write{(std::min)(remaining_sample_count, max_remaining_sample_count)};
const auto samples_to_read{
(fraction + samples_to_write * sample_rate_ratio).to_uint_floor()};

View file

@ -86,7 +86,7 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr send_info_,
u32 write_count{write_count_};
u32 read_pos{0};
while (write_count > 0) {
u32 to_write{std::min(count_max - target_write_offset, write_count)};
u32 to_write{(std::min)(count_max - target_write_offset, write_count)};
if (to_write > 0) {
const auto write_addr = send_buffer + target_write_offset * sizeof(s32);
memory.WriteBlockUnsafe(write_addr, &input[read_pos], to_write * sizeof(s32));
@ -157,7 +157,7 @@ static u32 ReadAuxBufferDsp(Core::Memory::Memory& memory, CpuAddr return_info_,
u32 read_count{read_count_};
u32 write_pos{0};
while (read_count > 0) {
u32 to_read{std::min(count_max - target_read_offset, read_count)};
u32 to_read{(std::min)(count_max - target_read_offset, read_count)};
if (to_read > 0) {
const auto read_addr = return_buffer + target_read_offset * sizeof(s32);
memory.ReadBlockUnsafe(read_addr, &output[write_pos], to_read * sizeof(s32));

View file

@ -20,8 +20,8 @@ namespace AudioCore::Renderer {
void ApplyBiquadFilterFloat(std::span<s32> output, std::span<const s32> input,
std::array<s16, 3>& b_, std::array<s16, 2>& a_,
VoiceState::BiquadFilterState& state, const u32 sample_count) {
constexpr f64 min{std::numeric_limits<s32>::min()};
constexpr f64 max{std::numeric_limits<s32>::max()};
constexpr f64 min{(std::numeric_limits<s32>::min)()};
constexpr f64 max{(std::numeric_limits<s32>::max)()};
std::array<f64, 3> b{Common::FixedPoint<50, 14>::from_base(b_[0]).to_double(),
Common::FixedPoint<50, 14>::from_base(b_[1]).to_double(),
Common::FixedPoint<50, 14>::from_base(b_[2]).to_double()};
@ -61,8 +61,8 @@ void ApplyBiquadFilterFloat(std::span<s32> output, std::span<const s32> input,
static void ApplyBiquadFilterInt(std::span<s32> output, std::span<const s32> input,
std::array<s16, 3>& b, std::array<s16, 2>& a,
VoiceState::BiquadFilterState& state, const u32 sample_count) {
constexpr s64 min{std::numeric_limits<s32>::min()};
constexpr s64 max{std::numeric_limits<s32>::max()};
constexpr s64 min{(std::numeric_limits<s32>::min)()};
constexpr s64 max{(std::numeric_limits<s32>::max)()};
for (u32 i = 0; i < sample_count; i++) {
const s64 in_sample{input[i]};

View file

@ -79,7 +79,7 @@ static u32 WriteAuxBufferDsp(Core::Memory::Memory& memory, const CpuAddr send_in
u32 write_count{write_count_};
u32 write_pos{0};
while (write_count > 0) {
u32 to_write{std::min(count_max - target_write_offset, write_count)};
u32 to_write{(std::min)(count_max - target_write_offset, write_count)};
if (to_write > 0) {
memory.WriteBlockUnsafe(send_buffer + target_write_offset * sizeof(s32),

View file

@ -76,9 +76,9 @@ static void UpdateI3dl2ReverbEffectParameter(const I3dl2ReverbInfo::ParameterVer
state.dry_gain = params.dry_gain;
Common::FixedPoint<50, 14> early_gain{
std::min(params.room_gain + params.reflection_gain, 5000.0f) / 2000.0f};
(std::min)(params.room_gain + params.reflection_gain, 5000.0f) / 2000.0f};
state.early_gain = pow_10(early_gain.to_float());
Common::FixedPoint<50, 14> late_gain{std::min(params.room_gain + params.reverb_gain, 5000.0f) /
Common::FixedPoint<50, 14> late_gain{(std::min)(params.room_gain + params.reverb_gain, 5000.0f) /
2000.0f};
state.late_gain = pow_10(late_gain.to_float());
@ -94,7 +94,7 @@ static void UpdateI3dl2ReverbEffectParameter(const I3dl2ReverbInfo::ParameterVer
const Common::FixedPoint<50, 14> c{
std::sqrt(std::pow(b.to_float(), 2.0f) + (std::pow(a.to_float(), 2.0f) * -4.0f))};
state.lowpass_1 = std::min(((b - c) / (a * 2.0f)).to_float(), 0.99723f);
state.lowpass_1 = (std::min)(((b - c) / (a * 2.0f)).to_float(), 0.99723f);
state.lowpass_2 = 1.0f - state.lowpass_1;
}

View file

@ -50,8 +50,8 @@ static void ApplyLightLimiterEffect(const LightLimiterInfo::ParameterVersion2& p
std::span<std::span<const s32>> inputs,
std::span<std::span<s32>> outputs, const u32 sample_count,
LightLimiterInfo::StatisticsInternal* statistics) {
constexpr s64 min{std::numeric_limits<s32>::min()};
constexpr s64 max{std::numeric_limits<s32>::max()};
constexpr s64 min{(std::numeric_limits<s32>::min)()};
constexpr s64 max{(std::numeric_limits<s32>::max)()};
const auto recip_estimate = [](f64 a) -> f64 {
s32 q, s;
@ -117,9 +117,9 @@ static void ApplyLightLimiterEffect(const LightLimiterInfo::ParameterVersion2& p
if (statistics) {
statistics->channel_max_sample[channel] =
std::max(statistics->channel_max_sample[channel], abs_sample.to_float());
(std::max)(statistics->channel_max_sample[channel], abs_sample.to_float());
statistics->channel_compression_gain_min[channel] =
std::min(statistics->channel_compression_gain_min[channel],
(std::min)(statistics->channel_compression_gain_min[channel],
state.compression_gain[channel].to_float());
}
}

View file

@ -94,7 +94,7 @@ static void UpdateReverbEffectParameter(const ReverbInfo::ParameterVersion2& par
for (u32 i = 0; i < ReverbInfo::MaxDelayTaps; i++) {
auto early_delay{
((pre_delay_time + EarlyDelayTimes[params.early_mode][i]) * sample_rate).to_int()};
early_delay = std::min(early_delay, state.pre_delay_line.sample_count_max);
early_delay = (std::min)(early_delay, state.pre_delay_line.sample_count_max);
state.early_delay_times[i] = early_delay + 1;
state.early_gains[i] = Common::FixedPoint<50, 14>::from_base(params.early_gain) *
EarlyDelayGains[params.early_mode][i];
@ -107,7 +107,7 @@ static void UpdateReverbEffectParameter(const ReverbInfo::ParameterVersion2& par
auto pre_time{
((pre_delay_time + EarlyDelayTimes[params.early_mode][10]) * sample_rate).to_int()};
state.pre_delay_time = std::min(pre_time, state.pre_delay_line.sample_count_max);
state.pre_delay_time = (std::min)(pre_time, state.pre_delay_line.sample_count_max);
if (!unk_initialized) {
unk_value = cos((1280.0f / sample_rate).to_float());
@ -117,13 +117,13 @@ static void UpdateReverbEffectParameter(const ReverbInfo::ParameterVersion2& par
for (u32 i = 0; i < ReverbInfo::MaxDelayLines; i++) {
const auto fdn_delay{(FdnDelayTimes[params.late_mode][i] * sample_rate).to_int()};
state.fdn_delay_lines[i].sample_count =
std::min(fdn_delay, state.fdn_delay_lines[i].sample_count_max);
(std::min)(fdn_delay, state.fdn_delay_lines[i].sample_count_max);
state.fdn_delay_lines[i].buffer_end =
&state.fdn_delay_lines[i].buffer[state.fdn_delay_lines[i].sample_count - 1];
const auto decay_delay{(DecayDelayTimes[params.late_mode][i] * sample_rate).to_int()};
state.decay_delay_lines[i].sample_count =
std::min(decay_delay, state.decay_delay_lines[i].sample_count_max);
(std::min)(decay_delay, state.decay_delay_lines[i].sample_count_max);
state.decay_delay_lines[i].buffer_end =
&state.decay_delay_lines[i].buffer[state.decay_delay_lines[i].sample_count - 1];

View file

@ -43,7 +43,7 @@ void DepopForMixBuffersCommand::Dump(
}
void DepopForMixBuffersCommand::Process(const AudioRenderer::CommandListProcessor& processor) {
auto end_index{std::min(processor.buffer_count, input + count)};
auto end_index{(std::min)(processor.buffer_count, input + count)};
std::span<s32> depop_buff{reinterpret_cast<s32*>(depop_buffer), end_index};
for (u32 index = input; index < end_index; index++) {

View file

@ -215,7 +215,7 @@ auto UpsampleCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListProc
void UpsampleCommand::Process(const AudioRenderer::CommandListProcessor& processor) {
const auto info{reinterpret_cast<UpsamplerInfo*>(upsampler_info)};
const auto input_count{std::min(info->input_count, buffer_count)};
const auto input_count{(std::min)(info->input_count, buffer_count)};
const std::span<const s16> inputs_{reinterpret_cast<const s16*>(inputs), input_count};
for (u32 i = 0; i < input_count; i++) {

View file

@ -21,8 +21,8 @@ void CircularBufferSinkCommand::Dump(
}
void CircularBufferSinkCommand::Process(const AudioRenderer::CommandListProcessor& processor) {
constexpr s32 min{std::numeric_limits<s16>::min()};
constexpr s32 max{std::numeric_limits<s16>::max()};
constexpr s32 min{(std::numeric_limits<s16>::min)()};
constexpr s32 max{(std::numeric_limits<s16>::max)()};
std::array<s16, TargetSampleCount * MaxChannels> output{};
for (u32 channel = 0; channel < input_count; channel++) {

View file

@ -20,8 +20,8 @@ void DeviceSinkCommand::Dump([[maybe_unused]] const AudioRenderer::CommandListPr
}
void DeviceSinkCommand::Process(const AudioRenderer::CommandListProcessor& processor) {
constexpr s32 min = std::numeric_limits<s16>::min();
constexpr s32 max = std::numeric_limits<s16>::max();
constexpr s32 min = (std::numeric_limits<s16>::min)();
constexpr s32 max = (std::numeric_limits<s16>::max)();
auto stream{processor.GetOutputSinkStream()};
stream->SetSystemChannels(input_count);

View file

@ -126,7 +126,7 @@ bool MixContext::TSortInfo(const SplitterContext& splitter_context) {
}
auto sorted_results{node_states.GetSortedResuls()};
const auto result_size{std::min(count, static_cast<s32>(sorted_results.second))};
const auto result_size{(std::min)(count, static_cast<s32>(sorted_results.second))};
for (s32 i = 0; i < result_size; i++) {
sorted_mix_infos[i] = &mix_infos[sorted_results.first[i]];
}

View file

@ -168,9 +168,9 @@ protected:
/// Node id for this sink
u32 node_id{};
/// State buffer for this sink
std::array<u8, std::max(sizeof(DeviceState), sizeof(CircularBufferState))> state{};
std::array<u8, (std::max)(sizeof(DeviceState), sizeof(CircularBufferState))> state{};
/// Parameter buffer for this sink
std::array<u8, std::max(sizeof(DeviceInParameter), sizeof(CircularBufferInParameter))>
std::array<u8, (std::max)(sizeof(DeviceInParameter), sizeof(CircularBufferInParameter))>
parameter{};
};

View file

@ -170,7 +170,7 @@ void SplitterContext::RecomposeDestination(SplitterInfo& out_info,
auto dest_count{info_header->destination_count};
if (!splitter_bug_fixed) {
dest_count = std::min(dest_count, GetDestCountPerInfoForCompat());
dest_count = (std::min)(dest_count, GetDestCountPerInfoForCompat());
}
if (dest_count == 0) {

View file

@ -718,7 +718,7 @@ u64 System::GenerateCommand(std::span<u8> in_command_buffer,
const auto estimated_time{start_estimated_time - end_estimated_time};
const auto time_limit{static_cast<u32>(std::max(dsp_time_limit + estimated_time, 0.0f))};
const auto time_limit{static_cast<u32>((std::max)(dsp_time_limit + estimated_time, 0.0f))};
num_voices_dropped =
DropVoices(command_buffer, static_cast<u32>(start_estimated_time), time_limit);
}

View file

@ -73,7 +73,7 @@ public:
minimum_latency = TargetSampleCount * 2;
}
minimum_latency = std::max(minimum_latency, TargetSampleCount * 2);
minimum_latency = (std::max)(minimum_latency, TargetSampleCount * 2);
LOG_INFO(Service_Audio,
"Opening cubeb stream {} type {} with: rate {} channels {} (system channels {}) "
@ -372,7 +372,7 @@ u32 GetCubebLatency() {
LOG_CRITICAL(Audio_Sink, "Error getting minimum latency, error: {}", latency_error);
latency = TargetSampleCount * 2;
}
latency = std::max(latency, TargetSampleCount * 2);
latency = (std::max)(latency, TargetSampleCount * 2);
cubeb_destroy(ctx);
return latency;
}
@ -426,7 +426,7 @@ bool IsCubebSuitable() {
LOG_ERROR(Audio_Sink, "Cubeb could not get min latency, it is not suitable.");
return false;
}
latency = std::max(latency, TargetSampleCount * 2);
latency = (std::max)(latency, TargetSampleCount * 2);
// Test opening a device with standard parameters
cubeb_devid output_device{0};

View file

@ -31,8 +31,8 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::span<s16> samples) {
return;
}
constexpr s32 min{std::numeric_limits<s16>::min()};
constexpr s32 max{std::numeric_limits<s16>::max()};
constexpr s32 min{(std::numeric_limits<s16>::min)()};
constexpr s32 max{(std::numeric_limits<s16>::max)()};
auto yuzu_volume{Settings::Volume()};
if (yuzu_volume > 1.0f) {
@ -123,8 +123,8 @@ void SinkStream::AppendBuffer(SinkBuffer& buffer, std::span<s16> samples) {
}
std::vector<s16> SinkStream::ReleaseBuffer(u64 num_samples) {
constexpr s32 min = std::numeric_limits<s16>::min();
constexpr s32 max = std::numeric_limits<s16>::max();
constexpr s32 min = (std::numeric_limits<s16>::min)();
constexpr s32 max = (std::numeric_limits<s16>::max)();
auto samples{samples_buffer.Pop(num_samples)};

View file

@ -235,7 +235,7 @@ else()
)
# Get around GCC failing with intrinsics in Debug
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_BUILD_TYPE MATCHES "Debug")
if(CXX_GCC AND CMAKE_BUILD_TYPE MATCHES "Debug")
set_property(
SOURCE stb.cpp
APPEND
@ -243,7 +243,7 @@ else()
endif()
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
if(CXX_CLANG)
target_compile_options(common PRIVATE -fsized-deallocation
-Werror=unreachable-code-aggressive)
target_compile_definitions(

View file

@ -27,8 +27,8 @@ public:
// If we are, join with them, ensuring we stay in bounds.
if (it != m_free_regions.end()) {
start_address = std::min(start_address, it->lower());
end_address = std::max(end_address, it->upper());
start_address = (std::min)(start_address, it->lower());
end_address = (std::max)(end_address, it->upper());
}
// Free the relevant region.

View file

@ -484,9 +484,9 @@ std::string GetParentPath(std::string_view path) {
std::size_t name_index;
if (name_bck_index == std::string_view::npos || name_fwd_index == std::string_view::npos) {
name_index = std::min(name_bck_index, name_fwd_index);
name_index = (std::min)(name_bck_index, name_fwd_index);
} else {
name_index = std::max(name_bck_index, name_fwd_index);
name_index = (std::max)(name_bck_index, name_fwd_index);
}
return std::string(path.substr(0, name_index));
@ -506,7 +506,7 @@ std::string_view GetPathWithoutTop(std::string_view path) {
const auto name_bck_index = path.find('\\');
const auto name_fwd_index = path.find('/');
return path.substr(std::min(name_bck_index, name_fwd_index) + 1);
return path.substr((std::min)(name_bck_index, name_fwd_index) + 1);
}
} // namespace Common::FS

View file

@ -144,8 +144,7 @@ void HeapTracker::Protect(size_t virtual_offset, size_t size, MemoryPermission p
}
// Clamp to end.
next = std::min(next, end);
next = (std::min)(next, end);
// Reprotect, if we need to.
if (should_protect) {
m_buffer.Protect(cur, next - cur, perm);
@ -211,8 +210,8 @@ void HeapTracker::RebuildSeparateHeapAddressSpace() {
// Despite being worse in theory, this has proven to be better in practice than more
// regularly dumping a smaller amount, because it significantly reduces average case
// lock contention.
const size_t desired_count = std::min(m_resident_map_count, m_max_resident_map_count) / 2;
const size_t evict_count = m_resident_map_count - desired_count;
std::size_t const desired_count = (std::min)(m_resident_map_count, m_max_resident_map_count) / 2;
std::size_t const evict_count = m_resident_map_count - desired_count;
auto it = m_resident_mappings.begin();
for (size_t i = 0; i < evict_count && it != m_resident_mappings.end(); i++) {

View file

@ -199,8 +199,8 @@ public:
std::scoped_lock lock{placeholder_mutex};
auto [it, end] = placeholders.equal_range({virtual_offset, virtual_end});
while (it != end) {
const size_t offset = std::max(it->lower(), virtual_offset);
const size_t protect_length = std::min(it->upper(), virtual_end) - offset;
const size_t offset = (std::max)(it->lower(), virtual_offset);
const size_t protect_length = (std::min)(it->upper(), virtual_end) - offset;
DWORD old_flags{};
if (!VirtualProtect(virtual_base + offset, protect_length, new_flags, &old_flags)) {
LOG_CRITICAL(HW_Memory, "Failed to change virtual memory protect rules");
@ -266,8 +266,8 @@ private:
}
const size_t placeholder_begin = it->lower();
const size_t placeholder_end = it->upper();
const size_t unmap_begin = std::max(virtual_offset, placeholder_begin);
const size_t unmap_end = std::min(virtual_offset + length, placeholder_end);
const size_t unmap_begin = (std::max)(virtual_offset, placeholder_begin);
const size_t unmap_end = (std::min)(virtual_offset + length, placeholder_end);
ASSERT(unmap_begin >= placeholder_begin && unmap_begin < placeholder_end);
ASSERT(unmap_end <= placeholder_end && unmap_end > placeholder_begin);
@ -655,8 +655,8 @@ private:
*virtual_offset = 0;
*length = 0;
} else {
*virtual_offset = std::max(intended_start, address_space_start);
*length = std::min(intended_end, address_space_end) - *virtual_offset;
*virtual_offset = (std::max)(intended_start, address_space_start);
*length = (std::min)(intended_end, address_space_end) - *virtual_offset;
}
}

View file

@ -18,7 +18,7 @@ constexpr const char* TrimSourcePath(std::string_view source) {
const auto rfind = [source](const std::string_view match) {
return source.rfind(match) == source.npos ? 0 : (source.rfind(match) + match.size());
};
auto idx = std::max({rfind("src/"), rfind("src\\"), rfind("../"), rfind("..\\")});
auto idx = (std::max)({rfind("src/"), rfind("src\\"), rfind("../"), rfind("..\\")});
return source.data() + idx;
}

View file

@ -85,10 +85,10 @@ struct Rectangle {
}
[[nodiscard]] constexpr bool Intersect(const Rectangle<T>& with, Rectangle<T>* result) const {
result->left = std::max(left, with.left);
result->top = std::max(top, with.top);
result->right = std::min(right, with.right);
result->bottom = std::min(bottom, with.bottom);
result->left = (std::max)(left, with.left);
result->top = (std::max)(top, with.top);
result->right = (std::min)(right, with.right);
result->bottom = (std::min)(bottom, with.bottom);
return !result->IsEmpty();
}
};

View file

@ -25,9 +25,9 @@ template <typename T>
inline bool CanAddWithoutOverflow(T lhs, T rhs) {
#ifdef _MSC_VER
if (lhs >= 0 && rhs >= 0) {
return WrappingAdd(lhs, rhs) >= std::max(lhs, rhs);
return WrappingAdd(lhs, rhs) >= (std::max)(lhs, rhs);
} else if (lhs < 0 && rhs < 0) {
return WrappingAdd(lhs, rhs) <= std::min(lhs, rhs);
return WrappingAdd(lhs, rhs) <= (std::min)(lhs, rhs);
} else {
return true;
}

View file

@ -18,7 +18,7 @@ private:
public:
explicit RangeMap(ValueT null_value_) : null_value{null_value_} {
container.emplace(std::numeric_limits<KeyT>::min(), null_value);
container.emplace((std::numeric_limits<KeyT>::min)(), null_value);
};
~RangeMap() = default;
@ -66,7 +66,7 @@ private:
}
const auto it_end = std::next(it);
if (it_end == container.end()) {
return std::numeric_limits<KeyT>::max() - address;
return (std::numeric_limits<KeyT>::max)() - address;
}
return it_end->first - address;
}

View file

@ -274,7 +274,7 @@ void OverlapRangeSet<AddressType>::Subtract(AddressType base_address, size_t siz
template <typename AddressType>
void OverlapRangeSet<AddressType>::DeleteAll(AddressType base_address, size_t size) {
m_impl->template Subtract<false>(base_address, size, std::numeric_limits<s32>::max(),
m_impl->template Subtract<false>(base_address, size, (std::numeric_limits<s32>::max)(),
[](AddressType, AddressType) {});
}

View file

@ -29,7 +29,7 @@ class RingBuffer {
// T must be safely memcpy-able and have a trivial default constructor.
static_assert(std::is_trivial_v<T>);
// Ensure capacity is sensible.
static_assert(capacity < std::numeric_limits<std::size_t>::max() / 2);
static_assert(capacity < (std::numeric_limits<std::size_t>::max)() / 2);
static_assert((capacity & (capacity - 1)) == 0, "capacity must be a power of two");
// Ensure lock-free.
static_assert(std::atomic_size_t::is_always_lock_free);
@ -43,9 +43,9 @@ public:
std::lock_guard lock(rb_mutex);
const std::size_t slots_free = capacity + read_index - write_index;
const std::size_t push_count = std::min(slot_count, slots_free);
const std::size_t push_count = (std::min)(slot_count, slots_free);
const std::size_t pos = write_index % capacity;
const std::size_t first_copy = std::min(capacity - pos, push_count);
const std::size_t first_copy = (std::min)(capacity - pos, push_count);
const std::size_t second_copy = push_count - first_copy;
const char* in = static_cast<const char*>(new_slots);
@ -69,9 +69,9 @@ public:
std::lock_guard lock(rb_mutex);
const std::size_t slots_filled = write_index - read_index;
const std::size_t pop_count = std::min(slots_filled, max_slots);
const std::size_t pop_count = (std::min)(slots_filled, max_slots);
const std::size_t pos = read_index % capacity;
const std::size_t first_copy = std::min(capacity - pos, pop_count);
const std::size_t first_copy = (std::min)(capacity - pos, pop_count);
const std::size_t second_copy = pop_count - first_copy;
char* out = static_cast<char*>(output);
@ -84,7 +84,7 @@ public:
}
std::vector<T> Pop(std::size_t max_slots = ~std::size_t(0)) {
std::vector<T> out(std::min(max_slots, capacity));
std::vector<T> out((std::min)(max_slots, capacity));
const std::size_t count = Pop(out.data(), out.size());
out.resize(count);
return out;

View file

@ -1,12 +1,11 @@
// SPDX-FileCopyrightText: 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "common/scm_rev.h"
#include <fstream>
#include <string>
#include <fmt/ranges.h>
#define GIT_REV "@GIT_REV@"
#define GIT_BRANCH "@GIT_BRANCH@"
#define GIT_DESC "@GIT_DESC@"
@ -18,64 +17,21 @@
#define TITLE_BAR_FORMAT_IDLE "@TITLE_BAR_FORMAT_IDLE@"
#define TITLE_BAR_FORMAT_RUNNING "@TITLE_BAR_FORMAT_RUNNING@"
#define IS_DEV_BUILD @IS_DEV_BUILD@
#define COMPILER_ID "@CXX_COMPILER@"
namespace Common {
const char* g_scm_rev;
const char* g_scm_branch;
const char* g_scm_desc;
const char g_build_name[] = BUILD_NAME;
const char g_build_date[] = BUILD_DATE;
const char g_build_fullname[] = BUILD_FULLNAME;
const char g_build_version[] = BUILD_VERSION;
const char g_build_id[] = BUILD_ID;
const char g_title_bar_format_idle[] = TITLE_BAR_FORMAT_IDLE;
const char g_title_bar_format_running[] = TITLE_BAR_FORMAT_RUNNING;
const bool g_is_dev_build = IS_DEV_BUILD;
constexpr const char g_scm_rev[] = GIT_REV;
constexpr const char g_scm_branch[] = GIT_BRANCH;
constexpr const char g_scm_desc[] = GIT_DESC;
constexpr const char g_build_name[] = BUILD_NAME;
constexpr const char g_build_date[] = BUILD_DATE;
constexpr const char g_build_fullname[] = BUILD_FULLNAME;
constexpr const char g_build_version[] = BUILD_VERSION;
constexpr const char g_build_id[] = BUILD_ID;
constexpr const char g_title_bar_format_idle[] = TITLE_BAR_FORMAT_IDLE;
constexpr const char g_title_bar_format_running[] = TITLE_BAR_FORMAT_RUNNING;
constexpr const bool g_is_dev_build = IS_DEV_BUILD;
constexpr const char g_compiler_id[] = COMPILER_ID;
/// Anonymizes SCM data
/// This is quite weak. But better than nothing.
class scm_encrypt {
std::string m_scm_rev, m_scm_branch, m_scm_desc;
public:
scm_encrypt() {
// Get a key that is easy to obtain when asking the person directly but (usually) hard to
// guess
std::string key;
#ifdef __linux__
if (!std::getline(std::ifstream("/proc/sys/kernel/hostname"), key))
key = "linux_error_key";
#else
// Not a good fallback, but better than nothing I guess?
key = g_build_date;
#endif
// Copy strings in place
m_scm_rev = GIT_REV;
m_scm_branch = GIT_BRANCH;
m_scm_desc = GIT_DESC;
// XOR each string with key
auto key_it = key.begin();
for (auto& string : {&m_scm_rev, &m_scm_branch, &m_scm_desc}) {
for (auto& c : *string) {
c ^= *key_it;
if (++key_it == key.end())
key_it = key.begin();
}
}
// Make each string human-readable
for (auto& string : {&m_scm_rev, &m_scm_branch, &m_scm_desc}) {
const std::string original = *string;
string->clear();
for (const auto c : original) {
string->append(fmt::format("{:x}", unsigned(c)));
}
string->pop_back();
}
// Set pointers
g_scm_rev = m_scm_rev.c_str();
g_scm_branch = m_scm_branch.c_str();
g_scm_desc = m_scm_desc.c_str();
}
} scm_encrypt_instance;
} // namespace Common

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -5,9 +8,9 @@
namespace Common {
extern const char* g_scm_rev;
extern const char* g_scm_branch;
extern const char* g_scm_desc;
extern const char g_scm_rev[];
extern const char g_scm_branch[];
extern const char g_scm_desc[];
extern const char g_build_name[];
extern const char g_build_date[];
extern const char g_build_fullname[];
@ -17,5 +20,6 @@ extern const char g_title_bar_format_idle[];
extern const char g_title_bar_format_running[];
extern const char g_shader_cache_version[];
extern const bool g_is_dev_build;
extern const char g_compiler_id[];
} // namespace Common

View file

@ -37,14 +37,14 @@ struct ResolutionScalingInfo {
if (value == 0) {
return 0;
}
return std::max((value * static_cast<s32>(up_scale)) >> static_cast<s32>(down_shift), 1);
return (std::max)((value * static_cast<s32>(up_scale)) >> static_cast<s32>(down_shift), 1);
}
u32 ScaleUp(u32 value) const {
if (value == 0U) {
return 0U;
}
return std::max((value * up_scale) >> down_shift, 1U);
return (std::max)((value * up_scale) >> down_shift, 1U);
}
};
@ -612,8 +612,8 @@ struct Values {
false, true, &custom_rtc_enabled};
SwitchableSetting<s64, true> custom_rtc_offset{linkage,
0,
std::numeric_limits<int>::min(),
std::numeric_limits<int>::max(),
(std::numeric_limits<int>::min)(),
(std::numeric_limits<int>::max)(),
"custom_rtc_offset",
Category::System,
Specialization::Countable,
@ -645,8 +645,14 @@ struct Values {
true,
true};
// Linux
SwitchableSetting<bool> enable_gamemode{linkage, true, "enable_gamemode", Category::Linux};
// Linux/MinGW may support (requires libdl support)
SwitchableSetting<bool> enable_gamemode{linkage,
#ifndef _MSC_VER
true,
#else
false,
#endif
"enable_gamemode", Category::UiGeneral};
// Controls
InputSetting<std::array<PlayerInput, 10>> players;

View file

@ -44,7 +44,6 @@ enum class Category : u32 {
Multiplayer,
Services,
Paths,
Linux,
LibraryApplet,
MaxEnum,
};

View file

@ -223,7 +223,7 @@ public:
if constexpr (std::is_enum_v<Type>) {
return EnumMetadata<Type>::Index();
} else {
return std::numeric_limits<u32>::max();
return (std::numeric_limits<u32>::max)();
}
}
@ -237,14 +237,14 @@ public:
[[nodiscard]] std::string MinVal() const override final {
if constexpr (std::is_arithmetic_v<Type> && !ranged) {
return this->ToString(std::numeric_limits<Type>::min());
return this->ToString((std::numeric_limits<Type>::min)());
} else {
return this->ToString(minimum);
}
}
[[nodiscard]] std::string MaxVal() const override final {
if constexpr (std::is_arithmetic_v<Type> && !ranged) {
return this->ToString(std::numeric_limits<Type>::max());
return this->ToString((std::numeric_limits<Type>::max)());
} else {
return this->ToString(maximum);
}

View file

@ -17,7 +17,7 @@
namespace Common {
struct SlotId {
static constexpr u32 INVALID_INDEX = std::numeric_limits<u32>::max();
static constexpr u32 INVALID_INDEX = (std::numeric_limits<u32>::max)();
constexpr auto operator<=>(const SlotId&) const noexcept = default;

View file

@ -66,7 +66,7 @@ void SetCurrentThreadPriority(ThreadPriority new_priority) {
const auto scheduling_type = SCHED_OTHER;
s32 max_prio = sched_get_priority_max(scheduling_type);
s32 min_prio = sched_get_priority_min(scheduling_type);
u32 level = std::max(static_cast<u32>(new_priority) + 1, 4U);
u32 level = (std::max)(static_cast<u32>(new_priority) + 1, 4U);
struct sched_param params;
if (max_prio > min_prio) {
@ -101,7 +101,7 @@ void SetCurrentThreadName(const char* name) {
#elif defined(__linux__)
// Linux limits thread names to 15 characters and will outright reject any
// attempt to set a longer name with ERANGE.
std::string truncated(name, std::min(strlen(name), static_cast<size_t>(15)));
std::string truncated(name, (std::min)(strlen(name), static_cast<size_t>(15)));
if (int e = pthread_setname_np(pthread_self(), truncated.c_str())) {
errno = e;
LOG_ERROR(Common, "Failed to set thread name to '{}': {}", truncated, GetLastErrorMsg());

View file

@ -124,7 +124,7 @@ public:
this->state.data[3] = ParamTmat;
{
const int num_init_iterations = std::max(seed_count + 1, MinimumInitIterations) - 1;
const int num_init_iterations = (std::max)(seed_count + 1, MinimumInitIterations) - 1;
GenerateInitialValuePlus(&this->state, 0, seed_count);

View file

@ -20,7 +20,7 @@ namespace Common {
// This function multiplies 2 u64 values and divides it by a u64 value.
[[nodiscard]] static inline u64 MultiplyAndDivide64(u64 a, u64 b, u64 d) {
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
u128 r{};
r[0] = _umul128(a, b, &r[1]);
u64 remainder;
@ -41,7 +41,7 @@ namespace Common {
// This function multiplies 2 u64 values and produces a u128 value;
[[nodiscard]] static inline u128 Multiply64Into128(u64 a, u64 b) {
u128 result;
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
result[0] = _umul128(a, b, &result[1]);
#else
unsigned __int128 tmp = a;
@ -65,7 +65,7 @@ namespace Common {
#endif
#else
// This one is bit more inaccurate.
return MultiplyAndDivide64(std::numeric_limits<u64>::max(), numerator, divisor);
return MultiplyAndDivide64((std::numeric_limits<u64>::max)(), numerator, divisor);
#endif
}

View file

@ -24,7 +24,7 @@ constexpr auto PauseCycles = 100'000U;
} // Anonymous namespace
#ifdef _MSC_VER
#if defined(_MSC_VER) && !defined(__clang__)
__forceinline static void TPAUSE() {
static constexpr auto RequestC02State = 0U;
_tpause(RequestC02State, FencedRDTSC() + PauseCycles);

View file

@ -1187,6 +1187,7 @@ else()
-Wno-cast-function-type
$<$<CXX_COMPILER_ID:Clang>:-fsized-deallocation>
$<$<CXX_COMPILER_ID:Clang>:-Wno-cast-function-type-mismatch>
)
endif()
@ -1199,7 +1200,7 @@ else()
target_link_libraries(core PUBLIC Boost::headers)
endif()
target_link_libraries(core PRIVATE fmt::fmt nlohmann_json::nlohmann_json RenderDoc::API mbedtls)
target_link_libraries(core PRIVATE fmt::fmt nlohmann_json::nlohmann_json RenderDoc::API mbedtls mbedcrypto)
if (MINGW)
target_link_libraries(core PRIVATE ${MSWSOCK_LIBRARY})
endif()

View file

@ -283,9 +283,9 @@ Loader::AppLoader::Modules FindModules(Kernel::KProcess* process) {
// Ignore leading directories.
char* path_pointer = module_path.path.data();
char* path_end =
path_pointer + std::min(PathLengthMax, module_path.path_length);
path_pointer + (std::min)(PathLengthMax, module_path.path_length);
for (s32 i = 0; i < std::min(PathLengthMax, module_path.path_length) &&
for (s32 i = 0; i < (std::min)(PathLengthMax, module_path.path_length) &&
module_path.path[i] != '\0';
i++) {
if (module_path.path[i] == '/' || module_path.path[i] == '\\') {

View file

@ -58,6 +58,8 @@ CallbackOrAccessOneWord DynarmicCP15::CompileSendOneWord(bool two, unsigned opc1
_mm_lfence();
#elif defined(ARCHITECTURE_x86_64)
asm volatile("mfence\n\tlfence\n\t" : : : "memory");
#elif defined(_MSC_VER) && defined(ARCHITECTURE_arm64)
_Memory_barrier();
#elif defined(ARCHITECTURE_arm64)
asm volatile("dsb sy\n\t" : : : "memory");
#else
@ -75,6 +77,8 @@ CallbackOrAccessOneWord DynarmicCP15::CompileSendOneWord(bool two, unsigned opc1
_mm_mfence();
#elif defined(ARCHITECTURE_x86_64)
asm volatile("mfence\n\t" : : : "memory");
#elif defined(_MSC_VER) && defined(ARCHITECTURE_arm64)
_Memory_barrier();
#elif defined(ARCHITECTURE_arm64)
asm volatile("dmb sy\n\t" : : : "memory");
#else

View file

@ -4,9 +4,14 @@
#pragma once
#include <atomic>
#include <signal.h>
#include <unistd.h>
#include <span>
#include "core/hle/kernel/k_thread.h"
#include "core/memory.h"
#include "common/logging/log.h"
#include "core/arm/nce/visitor_base.h"
namespace Core {

View file

@ -11,6 +11,8 @@
#include "core/core.h"
#include "core/core_timing.h"
#include "core/hle/kernel/svc.h"
#include "core/memory.h"
#include "core/hle/kernel/k_thread.h"
namespace Core::NCE {

View file

@ -185,7 +185,7 @@ struct System::Impl {
Service::PSC::Time::LocationName name{};
auto new_name = Settings::GetTimeZoneString(Settings::values.time_zone_index.GetValue());
std::memcpy(name.data(), new_name.data(), std::min(name.size(), new_name.size()));
std::memcpy(name.data(), new_name.data(), (std::min)(name.size(), new_name.size()));
timezone_service->SetDeviceLocationName(name);

View file

@ -34,8 +34,8 @@ std::size_t XTSEncryptionLayer::Read(u8* data, std::size_t length, std::size_t o
buffer.resize(XTS_SECTOR_SIZE);
cipher.XTSTranscode(buffer.data(), buffer.size(), buffer.data(), offset / XTS_SECTOR_SIZE,
XTS_SECTOR_SIZE, Op::Decrypt);
std::memcpy(data, buffer.data(), std::min(buffer.size(), length));
return std::min(buffer.size(), length);
std::memcpy(data, buffer.data(), (std::min)(buffer.size(), length));
return (std::min)(buffer.size(), length);
}
// offset does not fall on block boundary (0x4000)

View file

@ -664,7 +664,7 @@ void GDBStub::HandleRcmd(const std::vector<u8>& command) {
if (svc_mem_info.state != Kernel::Svc::MemoryState::Inaccessible ||
svc_mem_info.base_address + svc_mem_info.size - 1 !=
std::numeric_limits<u64>::max()) {
(std::numeric_limits<u64>::max)()) {
const char* state = GetMemoryStateName(svc_mem_info.state);
const char* perm = GetMemoryPermissionString(svc_mem_info);
const char l = True(svc_mem_info.attribute & MemoryAttribute::Locked) ? 'L' : '-';
@ -710,7 +710,7 @@ std::vector<char>::const_iterator GDBStub::CommandEnd() const {
const auto end{std::find(current_command.begin(), current_command.end(), GDB_STUB_END)};
// Require the checksum to be present
return std::min(end + 2, current_command.end());
return (std::min)(end + 2, current_command.end());
}
std::optional<std::string> GDBStub::DetachCommand() {

View file

@ -12,7 +12,7 @@ static T HexToValue(std::string_view hex) {
static_assert(std::is_trivially_copyable_v<T>);
T value{};
const auto mem{Common::HexStringToVector(hex, false)};
std::memcpy(&value, mem.data(), std::min(mem.size(), sizeof(T)));
std::memcpy(&value, mem.data(), (std::min)(mem.size(), sizeof(T)));
return value;
}

View file

@ -388,7 +388,7 @@ void DeviceMemoryManager<Traits>::WalkBlock(DAddr addr, std::size_t size, auto o
while (remaining_size) {
const size_t next_pages = static_cast<std::size_t>(continuity_tracker[page_index]);
const std::size_t copy_amount =
std::min((next_pages << Memory::YUZU_PAGEBITS) - page_offset, remaining_size);
(std::min)((next_pages << Memory::YUZU_PAGEBITS) - page_offset, remaining_size);
const auto current_vaddr =
static_cast<u64>((page_index << Memory::YUZU_PAGEBITS) + page_offset);
SCOPE_EXIT{

View file

@ -34,12 +34,9 @@ NCA::NCA(VirtualFile file_, const NCA* base_nca)
}
reader = std::make_shared<NcaReader>();
if (Result rc =
reader->Initialize(file, GetCryptoConfiguration(), GetNcaCompressionConfiguration());
R_FAILED(rc)) {
if (Result rc = reader->Initialize(file, GetCryptoConfiguration(), GetNcaCompressionConfiguration()); R_FAILED(rc)) {
if (rc != ResultInvalidNcaSignature) {
LOG_ERROR(Loader, "File reader errored out during header read: {:#x}",
rc.GetInnerValue());
LOG_ERROR(Loader, "File reader errored out during header read: {:#x}", rc.GetInnerValue());
}
status = Loader::ResultStatus::ErrorBadNCAHeader;
return;
@ -84,10 +81,8 @@ NCA::NCA(VirtualFile file_, const NCA* base_nca)
std::vector<VirtualFile> filesystems(fs_count);
for (s32 i = 0; i < fs_count; i++) {
NcaFsHeaderReader header_reader;
const Result rc = fs.OpenStorage(&filesystems[i], &header_reader, i);
if (R_FAILED(rc)) {
LOG_ERROR(Loader, "File reader errored out during read of section {}: {:#x}", i,
rc.GetInnerValue());
if (Result rc = fs.OpenStorage(&filesystems[i], &header_reader, i); R_FAILED(rc)) {
LOG_DEBUG(Loader, "File reader errored out during read of section {}: {:#x}", i, rc.GetInnerValue());
status = Loader::ResultStatus::ErrorBadNCAHeader;
return;
}

View file

@ -683,7 +683,7 @@ public:
const auto max_mount_len =
out_mount_name_buffer_size == 0
? MountNameLengthMax + 1
: std::min(MountNameLengthMax + 1, out_mount_name_buffer_size);
: (std::min)(MountNameLengthMax + 1, out_mount_name_buffer_size);
// Parse the path until we see a drive separator
size_t mount_len = 0;

View file

@ -48,7 +48,7 @@ public:
private:
Result DoRead(s64* out_count, DirectoryEntry* out_entries, s64 max_entries) {
const u64 actual_entries =
std::min(static_cast<u64>(max_entries), entries.size() - next_entry_index);
(std::min)(static_cast<u64>(max_entries), entries.size() - next_entry_index);
const auto* begin = reinterpret_cast<u8*>(entries.data() + next_entry_index);
const auto* end = reinterpret_cast<u8*>(entries.data() + next_entry_index + actual_entries);
const auto range_size = static_cast<std::size_t>(std::distance(begin, end));

View file

@ -93,7 +93,7 @@ protected:
R_TRY(this->DoGetSize(std::addressof(file_size)));
R_UNLESS(offset <= file_size, ResultOutOfRange);
*out = static_cast<size_t>(std::min(file_size - offset, static_cast<s64>(size)));
*out = static_cast<size_t>((std::min)(file_size - offset, static_cast<s64>(size)));
R_SUCCEED();
}

View file

@ -213,7 +213,7 @@ size_t AesCtrCounterExtendedStorage::Read(u8* buffer, size_t size, size_t offset
// Determine how much is left.
const auto remaining_size = end_offset - cur_offset;
const auto cur_size = static_cast<size_t>(std::min(remaining_size, data_size));
const auto cur_size = static_cast<size_t>((std::min)(remaining_size, data_size));
ASSERT(cur_size <= size);
// If necessary, perform decryption.

View file

@ -94,7 +94,7 @@ size_t AesCtrStorage::Write(const u8* buffer, size_t size, size_t offset) {
while (remaining > 0) {
// Determine data we're writing and where.
const size_t write_size =
use_work_buffer ? std::min(pooled_buffer.GetSize(), remaining) : remaining;
use_work_buffer ? (std::min)(pooled_buffer.GetSize(), remaining) : remaining;
void* write_buf;
if (use_work_buffer) {

View file

@ -65,7 +65,7 @@ size_t AesXtsStorage::Read(u8* buffer, size_t size, size_t offset) const {
// Determine the size of the pre-data read.
const size_t skip_size =
static_cast<size_t>(offset - Common::AlignDown(offset, m_block_size));
const size_t data_size = std::min(size, m_block_size - skip_size);
const size_t data_size = (std::min)(size, m_block_size - skip_size);
// Decrypt into a pooled buffer.
{
@ -84,14 +84,14 @@ size_t AesXtsStorage::Read(u8* buffer, size_t size, size_t offset) const {
AddCounter(ctr.data(), IvSize, 1);
processed_size += data_size;
ASSERT(processed_size == std::min(size, m_block_size - skip_size));
ASSERT(processed_size == (std::min)(size, m_block_size - skip_size));
}
// Decrypt aligned chunks.
char* cur = reinterpret_cast<char*>(buffer) + processed_size;
size_t remaining = size - processed_size;
while (remaining > 0) {
const size_t cur_size = std::min(m_block_size, remaining);
const size_t cur_size = (std::min)(m_block_size, remaining);
m_cipher->SetIV(ctr);
m_cipher->Transcode(cur, cur_size, cur, Core::Crypto::Op::Decrypt);

View file

@ -104,7 +104,7 @@ size_t AlignmentMatchingStorageImpl::Read(VirtualFile base_storage, char* work_b
while (remaining_tail_size > 0) {
const auto aligned_tail_offset = Common::AlignDown(tail_offset, data_alignment);
const auto cur_size =
std::min(static_cast<size_t>(aligned_tail_offset + data_alignment - tail_offset),
(std::min)(static_cast<size_t>(aligned_tail_offset + data_alignment - tail_offset),
remaining_tail_size);
base_storage->Read(reinterpret_cast<u8*>(work_buf), data_alignment, aligned_tail_offset);
@ -186,7 +186,7 @@ size_t AlignmentMatchingStorageImpl::Write(VirtualFile base_storage, char* work_
const auto aligned_tail_offset = Common::AlignDown(tail_offset, data_alignment);
const auto cur_size =
std::min(static_cast<size_t>(aligned_tail_offset + data_alignment - tail_offset),
(std::min)(static_cast<size_t>(aligned_tail_offset + data_alignment - tail_offset),
remaining_tail_size);
base_storage->Read(reinterpret_cast<u8*>(work_buf), data_alignment, aligned_tail_offset);

View file

@ -29,12 +29,12 @@ void GenerateKey(void* dst_key, size_t dst_key_size, const void* src_key, size_t
key_type == static_cast<s32>(KeyType::NcaHeaderKey2)) {
const s32 key_index = static_cast<s32>(KeyType::NcaHeaderKey2) == key_type;
const auto key = instance.GetKey(Core::Crypto::S256KeyType::Header);
std::memcpy(dst_key, key.data() + key_index * 0x10, std::min(dst_key_size, key.size() / 2));
std::memcpy(dst_key, key.data() + key_index * 0x10, (std::min)(dst_key_size, key.size() / 2));
return;
}
const s32 key_generation =
std::max(key_type / NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount, 1) - 1;
(std::max)(key_type / NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount, 1) - 1;
const s32 key_index = key_type % NcaCryptoConfiguration::KeyAreaEncryptionKeyIndexCount;
Core::Crypto::AESCipher<Core::Crypto::Key128> cipher(

View file

@ -4,23 +4,18 @@
// SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#include "core/file_sys/fssystem/fssystem_integrity_verification_storage.h"
#include "common/alignment.h"
#include "core/file_sys/fssystem/fssystem_integrity_verification_storage.h"
namespace FileSys {
constexpr inline u32 ILog2(u32 val)
{
constexpr inline u32 ILog2(u32 val) {
ASSERT(val > 0);
return static_cast<u32>((sizeof(u32) * 8) - 1 - std::countl_zero<u32>(val));
}
void IntegrityVerificationStorage::Initialize(VirtualFile hs,
VirtualFile ds,
s64 verif_block_size,
s64 upper_layer_verif_block_size,
bool is_real_data)
{
void IntegrityVerificationStorage::Initialize(VirtualFile hs, VirtualFile ds, s64 verif_block_size,
s64 upper_layer_verif_block_size, bool is_real_data) {
// Validate preconditions.
ASSERT(verif_block_size >= HashSize);
@ -34,34 +29,28 @@ void IntegrityVerificationStorage::Initialize(VirtualFile hs,
ASSERT(m_verification_block_size == 1ll << m_verification_block_order);
// Set upper layer block sizes.
upper_layer_verif_block_size = std::max(upper_layer_verif_block_size, HashSize);
upper_layer_verif_block_size = (std::max)(upper_layer_verif_block_size, HashSize);
m_upper_layer_verification_block_size = upper_layer_verif_block_size;
m_upper_layer_verification_block_order = ILog2(static_cast<u32>(upper_layer_verif_block_size));
ASSERT(m_upper_layer_verification_block_size == 1ll << m_upper_layer_verification_block_order);
// Validate sizes.
if (m_data_storage != nullptr) {
{
s64 hash_size = m_hash_storage->GetSize();
s64 data_size = m_data_storage->GetSize();
ASSERT(((hash_size / HashSize) * m_verification_block_size) >= data_size);
} else {
LOG_ERROR(Loader,
"Failed to initialize integrity verification store. Game, update, or DLC may not "
"work.");
}
// Set data.
m_is_real_data = is_real_data;
}
void IntegrityVerificationStorage::Finalize()
{
void IntegrityVerificationStorage::Finalize() {
m_hash_storage = VirtualFile();
m_data_storage = VirtualFile();
}
size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset) const
{
size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset) const {
// Succeed if zero size.
if (size == 0) {
return size;
@ -70,13 +59,7 @@ size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset
// Validate arguments.
ASSERT(buffer != nullptr);
if (m_data_storage == nullptr) {
LOG_ERROR(Loader,
"Integrity verification store failed read operation. Game, update or DLC may not "
"work.");
return 0;
}
// Validate the offset.
s64 data_size = m_data_storage->GetSize();
ASSERT(offset <= static_cast<size_t>(data_size));
@ -104,8 +87,7 @@ size_t IntegrityVerificationStorage::Read(u8* buffer, size_t size, size_t offset
return m_data_storage->Read(buffer, read_size, offset);
}
size_t IntegrityVerificationStorage::GetSize() const
{
size_t IntegrityVerificationStorage::GetSize() const {
return m_data_storage->GetSize();
}

View file

@ -1051,8 +1051,8 @@ Result NcaFileSystemDriver::CreatePatchMetaStorage(
ASSERT(out_aes_ctr_ex_meta != nullptr);
ASSERT(out_indirect_meta != nullptr);
ASSERT(base_storage != nullptr);
ASSERT(patch_info.HasAesCtrExTable());
ASSERT(patch_info.HasIndirectTable());
//ASSERT(patch_info.HasAesCtrExTable());
//ASSERT(patch_info.HasIndirectTable());
ASSERT(Common::IsAligned<s64>(patch_info.aes_ctr_ex_size, NcaHeader::XtsBlockSize));
// Validate patch info extents.
@ -1334,8 +1334,8 @@ Result NcaFileSystemDriver::CreateIntegrityVerificationStorageImpl(
R_UNLESS(last_layer_info_offset + layer_info.size <= layer_info_offset,
ResultRomNcaInvalidIntegrityLayerInfoOffset);
}
storage_info.SetDataStorage(std::make_shared<OffsetVfsFile>(
std::move(base_storage), layer_info.size, last_layer_info_offset));
storage_info[level_hash_info.max_layers - 1] = std::make_shared<OffsetVfsFile>(
std::move(base_storage), layer_info.size, last_layer_info_offset);
// Make the integrity romfs storage.
auto integrity_storage = std::make_shared<IntegrityRomFsStorage>();

View file

@ -9,7 +9,7 @@
namespace FileSys {
u8 NcaHeader::GetProperKeyGeneration() const {
return std::max(this->key_generation, this->key_generation_2);
return (std::max)(this->key_generation, this->key_generation_2);
}
bool NcaPatchInfo::HasIndirectTable() const {

View file

@ -34,7 +34,7 @@ void PooledBuffer::AllocateCore(size_t ideal_size, size_t required_size, bool la
ASSERT(required_size <= GetAllocatableSizeMaxCore(large));
const size_t target_size =
std::min(std::max(ideal_size, required_size), GetAllocatableSizeMaxCore(large));
(std::min)((std::max)(ideal_size, required_size), GetAllocatableSizeMaxCore(large));
// Dummy implementation for allocate.
if (target_size > 0) {

View file

@ -18,7 +18,7 @@ private:
virtual ~ZeroStorage() {}
virtual size_t GetSize() const override {
return std::numeric_limits<size_t>::max();
return (std::numeric_limits<size_t>::max)();
}
virtual size_t Read(u8* buffer, size_t size, size_t offset) const override {
@ -62,7 +62,7 @@ public:
private:
void SetZeroStorage() {
return this->SetStorage(1, m_zero_storage, 0, std::numeric_limits<s64>::max());
return this->SetStorage(1, m_zero_storage, 0, (std::numeric_limits<s64>::max)());
}
private:

View file

@ -102,7 +102,7 @@ std::vector<u8> CNMT::Serialize() const {
header.type >= TitleType::Application && header.type <= TitleType::AOC;
const auto dead_zone = header.table_offset + sizeof(CNMTHeader);
std::vector<u8> out(
std::max(sizeof(CNMTHeader) + (has_opt_header ? sizeof(OptionalHeader) : 0), dead_zone) +
(std::max)(sizeof(CNMTHeader) + (has_opt_header ? sizeof(OptionalHeader) : 0), dead_zone) +
content_records.size() * sizeof(ContentRecord) + meta_records.size() * sizeof(MetaRecord));
memcpy(out.data(), &header, sizeof(CNMTHeader));

View file

@ -273,7 +273,7 @@ std::vector<NcaID> PlaceholderCache::List() const {
NcaID PlaceholderCache::Generate() {
std::random_device device;
std::mt19937 gen(device());
std::uniform_int_distribution<u64> distribution(1, std::numeric_limits<u64>::max());
std::uniform_int_distribution<u64> distribution(1, (std::numeric_limits<u64>::max)());
NcaID out{};

View file

@ -75,7 +75,7 @@ std::pair<EntryType, std::string> GetEntry(const RomFSTraversalContext& ctx, siz
}
std::memcpy(&entry, data + offset, sizeof(EntryType));
const size_t name_length = std::min(entry_end + entry.name_length, size) - entry_end;
const size_t name_length = (std::min)(entry_end + entry.name_length, size) - entry_end;
std::string name(reinterpret_cast<const char*>(data + entry_end), name_length);
return {entry, std::move(name)};

View file

@ -507,9 +507,9 @@ bool VfsRawCopy(const VirtualFile& src, const VirtualFile& dest, std::size_t blo
if (!dest->Resize(src->GetSize()))
return false;
std::vector<u8> temp(std::min(block_size, src->GetSize()));
std::vector<u8> temp((std::min)(block_size, src->GetSize()));
for (std::size_t i = 0; i < src->GetSize(); i += block_size) {
const auto read = std::min(block_size, src->GetSize() - i);
const auto read = (std::min)(block_size, src->GetSize() - i);
if (src->Read(temp.data(), read, i) != read) {
return false;

View file

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
@ -442,11 +445,12 @@ std::vector<VirtualFile> RealVfsDirectory::GetFiles() const {
FileTimeStampRaw RealVfsDirectory::GetFileTimeStamp(std::string_view path_) const {
const auto full_path = FS::SanitizePath(path + '/' + std::string(path_));
const auto fs_path = std::filesystem::path{FS::ToU8String(full_path)};
struct stat file_status;
#ifdef _WIN32
struct _stat64 file_status;
const auto stat_result = _wstat64(fs_path.c_str(), &file_status);
#else
struct stat file_status;
const auto stat_result = stat(fs_path.c_str(), &file_status);
#endif

View file

@ -43,7 +43,7 @@ public:
}
std::size_t Read(u8* data, std::size_t length, std::size_t offset) const override {
const auto read = std::min(length, size - offset);
const auto read = (std::min)(length, size - offset);
std::fill(data, data + read, value);
return read;
}
@ -61,7 +61,7 @@ public:
}
std::vector<u8> ReadBytes(std::size_t length, std::size_t offset) const override {
const auto read = std::min(length, size - offset);
const auto read = (std::min)(length, size - offset);
return std::vector<u8>(read, value);
}

View file

@ -37,7 +37,7 @@ bool VectorVfsFile::IsReadable() const {
}
std::size_t VectorVfsFile::Read(u8* data_, std::size_t length, std::size_t offset) const {
const auto read = std::min(length, data.size() - offset);
const auto read = (std::min)(length, data.size() - offset);
std::memcpy(data_, data.data() + offset, read);
return read;
}
@ -45,7 +45,7 @@ std::size_t VectorVfsFile::Read(u8* data_, std::size_t length, std::size_t offse
std::size_t VectorVfsFile::Write(const u8* data_, std::size_t length, std::size_t offset) {
if (offset + length > data.size())
data.resize(offset + length);
const auto write = std::min(length, data.size() - offset);
const auto write = (std::min)(length, data.size() - offset);
std::memcpy(data.data() + offset, data_, write);
return write;
}

Some files were not shown because too many files have changed in this diff Show more