mirror of
https://git.eden-emu.dev/eden-emu/eden.git
synced 2026-10-09 06:46:57 +00:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d14c1f13d8 |
+20
-25
@@ -322,47 +322,42 @@ endif()
|
||||
|
||||
# Build/optimization presets
|
||||
if (CXX_GCC OR CXX_CLANG)
|
||||
if (ARCHITECTURE_x86_64)
|
||||
# GCC/clang will -mtune=generic by default
|
||||
if ("${YUZU_BUILD_PRESET}" STREQUAL "native")
|
||||
add_compile_options(
|
||||
$<$<COMPILE_LANGUAGE:C,CXX>:-march=native>
|
||||
$<$<COMPILE_LANGUAGE:C,CXX>:-mtune=native>)
|
||||
elseif (ARCHITECTURE_x86_64)
|
||||
# See https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html
|
||||
# Generic supports Pentium Pro instruction set and above
|
||||
# TODO: if a value is unknown, pass that as march and mtune
|
||||
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")
|
||||
set(march x86-64)
|
||||
set(mtune generic)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-march=x86-64>)
|
||||
elseif (${YUZU_BUILD_PRESET} STREQUAL "v3")
|
||||
set(march x86-64-v3)
|
||||
set(mtune generic)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-march=x86-64-v3>)
|
||||
elseif (${YUZU_BUILD_PRESET} STREQUAL "zen2")
|
||||
set(march znver2)
|
||||
set(mtune znver2)
|
||||
add_compile_options(
|
||||
$<$<COMPILE_LANGUAGE:C,CXX>:-march=znver2>
|
||||
$<$<COMPILE_LANGUAGE:C,CXX>:-mtune=znver4>)
|
||||
elseif (${YUZU_BUILD_PRESET} STREQUAL "zen4")
|
||||
set(march znver4)
|
||||
set(mtune znver4)
|
||||
add_compile_options(
|
||||
$<$<COMPILE_LANGUAGE:C,CXX>:-march=znver4>
|
||||
$<$<COMPILE_LANGUAGE:C,CXX>:-mtune=znver4>)
|
||||
endif()
|
||||
elseif(ARCHITECTURE_arm64)
|
||||
# See https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html
|
||||
set(YUZU_BUILD_PRESET "custom" CACHE STRING "Build preset to use. One of: custom, generic, optimized, armv9, native")
|
||||
set(mtune generic)
|
||||
set(YUZU_BUILD_PRESET "custom" CACHE STRING "Build preset to use. One of: custom, generic, optimized, armv9, m1, native")
|
||||
if (${YUZU_BUILD_PRESET} STREQUAL "generic")
|
||||
set(march armv8-a)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-march=armv8-a>)
|
||||
elseif (${YUZU_BUILD_PRESET} STREQUAL "optimized")
|
||||
set(march armv8.2-a+lse+rcpc)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-march=armv8.2-a+lse+rcpc>)
|
||||
elseif (${YUZU_BUILD_PRESET} STREQUAL "armv9")
|
||||
set(march armv9-a)
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-march=armv9-a>)
|
||||
elseif (${YUZU_BUILD_PRESET} STREQUAL "m1")
|
||||
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:-mcpu=apple-m1>)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if ("${YUZU_BUILD_PRESET}" STREQUAL "native")
|
||||
set(march native)
|
||||
set(mtune native)
|
||||
endif()
|
||||
|
||||
if (DEFINED march AND DEFINED mtune)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${march} -mtune=${mtune}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${march} -mtune=${mtune}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Configure C++ standard
|
||||
|
||||
+13
-12
@@ -1,6 +1,3 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
@@ -146,16 +143,20 @@ public:
|
||||
return m_str;
|
||||
}
|
||||
|
||||
size_t GetLength() const {
|
||||
return std::strlen(this->GetString());
|
||||
constexpr size_t GetLength() const {
|
||||
if (std::is_constant_evaluated()) {
|
||||
return Strlen(this->GetString());
|
||||
} else {
|
||||
return std::strlen(this->GetString());
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool IsEmpty() const {
|
||||
return *m_str == '\x00';
|
||||
}
|
||||
|
||||
bool IsMatchHead(const char* p, size_t len) const {
|
||||
return std::strncmp(this->GetString(), p, len) == 0;
|
||||
constexpr bool IsMatchHead(const char* p, size_t len) const {
|
||||
return Strncmp(this->GetString(), p, len) == 0;
|
||||
}
|
||||
|
||||
Result Initialize(const Path& rhs) {
|
||||
@@ -168,7 +169,7 @@ public:
|
||||
R_TRY(this->Preallocate(len + 1));
|
||||
|
||||
// Copy the path
|
||||
const size_t copied = strlcpy(m_write_buffer.Get(), rhs.GetString(), len + 1);
|
||||
const size_t copied = Strlcpy<char>(m_write_buffer.Get(), rhs.GetString(), len + 1);
|
||||
R_UNLESS(copied == len, ResultUnexpectedInPathA);
|
||||
|
||||
// Set normalized
|
||||
@@ -330,14 +331,14 @@ public:
|
||||
// Get our write buffer
|
||||
auto* dst = m_write_buffer.Get();
|
||||
if (old_write_buffer.Get() != nullptr && cur_len > 0) {
|
||||
strlcpy(dst, old_write_buffer.Get(), cur_len + 1);
|
||||
Strlcpy<char>(dst, old_write_buffer.Get(), cur_len + 1);
|
||||
}
|
||||
|
||||
// Add separator
|
||||
dst[cur_len] = '/';
|
||||
|
||||
// Copy the child path
|
||||
const size_t copied = strlcpy(dst + cur_len + 1, c, child_len + 1);
|
||||
const size_t copied = Strlcpy<char>(dst + cur_len + 1, c, child_len + 1);
|
||||
R_UNLESS(copied == child_len, ResultUnexpectedInPathA);
|
||||
|
||||
R_SUCCEED();
|
||||
@@ -374,7 +375,7 @@ public:
|
||||
if (m_write_buffer.Get() == nullptr) {
|
||||
if (const auto len = std::strlen(m_str); len > 0) {
|
||||
R_TRY(this->Preallocate(len));
|
||||
strlcpy(m_write_buffer.Get(), m_str, len + 1);
|
||||
Strlcpy<char>(m_write_buffer.Get(), m_str, len + 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -496,7 +497,7 @@ private:
|
||||
R_TRY(this->Preallocate(size + 1));
|
||||
|
||||
// Copy the path
|
||||
const size_t copied = strlcpy(m_write_buffer.Get(), path, size + 1);
|
||||
const size_t copied = Strlcpy<char>(m_write_buffer.Get(), path, size + 1);
|
||||
R_UNLESS(copied >= size, ResultUnexpectedInPathA);
|
||||
} else {
|
||||
// We can just clear the buffer
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
@@ -1217,7 +1217,7 @@ public:
|
||||
replaced_src = static_cast<char*>(Allocate(replaced_src_len));
|
||||
}
|
||||
|
||||
strlcpy(replaced_src, src, replaced_src_len);
|
||||
Strlcpy<char>(replaced_src, src, replaced_src_len);
|
||||
|
||||
Replace(replaced_src, replaced_src_len, AlternateDirectorySeparator,
|
||||
DirectorySeparator);
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
@@ -10,6 +7,85 @@
|
||||
|
||||
namespace FileSys {
|
||||
|
||||
template <typename T>
|
||||
constexpr int Strlen(const T* str) {
|
||||
ASSERT(str != nullptr);
|
||||
|
||||
int length = 0;
|
||||
while (*str++) {
|
||||
++length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr int Strnlen(const T* str, std::size_t count) {
|
||||
return Strnlen(str, static_cast<int>(count));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr int Strnlen(const T* str, int count) {
|
||||
ASSERT(str != nullptr);
|
||||
ASSERT(count >= 0);
|
||||
|
||||
int length = 0;
|
||||
while (count-- && *str++) {
|
||||
++length;
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr int Strncmp(const T* lhs, const T* rhs, std::size_t count) {
|
||||
return Strncmp(lhs, rhs, static_cast<int>(count));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
constexpr int Strncmp(const T* lhs, const T* rhs, int count) {
|
||||
ASSERT(lhs != nullptr);
|
||||
ASSERT(rhs != nullptr);
|
||||
ASSERT(count >= 0);
|
||||
|
||||
if (count == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
T l, r;
|
||||
do {
|
||||
l = *(lhs++);
|
||||
r = *(rhs++);
|
||||
} while (l && (l == r) && (--count));
|
||||
|
||||
return l - r;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static constexpr int Strlcpy(T* dst, const T* src, std::size_t count) {
|
||||
return Strlcpy<T>(dst, src, static_cast<int>(count));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static constexpr int Strlcpy(T* dst, const T* src, int count) {
|
||||
ASSERT(dst != nullptr);
|
||||
ASSERT(src != nullptr);
|
||||
|
||||
const T* cur = src;
|
||||
if (count > 0) {
|
||||
while ((--count) && *cur) {
|
||||
*(dst++) = *(cur++);
|
||||
}
|
||||
*dst = 0;
|
||||
}
|
||||
|
||||
while (*cur) {
|
||||
cur++;
|
||||
}
|
||||
|
||||
return static_cast<int>(cur - src);
|
||||
}
|
||||
|
||||
enum CharacterEncodingResult {
|
||||
CharacterEncodingResult_Success = 0,
|
||||
CharacterEncodingResult_InsufficientLength = 1,
|
||||
|
||||
Reference in New Issue
Block a user