Compare commits

..

3 Commits

Author SHA1 Message Date
lizzie cf1d905786 2026-09-15 07:28:16
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2026-09-15 07:28:17 +00:00
lizzie 60003ea642 2026-09-15 06:40:57
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2026-09-15 06:40:58 +00:00
lizzie 43607d0b7e 2026-09-15 06:36:27
Signed-off-by: lizzie <lizzie@eden-emu.dev>
2026-09-15 06:36:27 +00:00
6 changed files with 65 additions and 4 deletions
+1
View File
@@ -110,6 +110,7 @@ add_library(
socket_types.h
sparse_large_vector.cpp
sparse_large_vector.h
spin_lock.h
stb.cpp
stb.h
steady_clock.cpp
+50
View File
@@ -0,0 +1,50 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#ifdef _MSC_VER
#include <intrin.h>
#elif defined(ARCHITECTURE_x86_64)
#include <xmmintrin.h>
#endif
#include <atomic>
namespace Common {
/// @brief A lock similar to mutex that forces a thread to spin wait instead calling the
/// supervisor. Should be used on short sequences of code.
struct SpinLock {
SpinLock() noexcept = default;
SpinLock(const SpinLock&) noexcept = delete;
SpinLock& operator=(const SpinLock&) noexcept = delete;
SpinLock(SpinLock&&) noexcept = delete;
SpinLock& operator=(SpinLock&&) noexcept = delete;
inline void lock() noexcept {
while (lck.test_and_set(std::memory_order_acquire)) {
#if defined(ARCHITECTURE_x86_64)
_mm_pause();
#elif defined(ARCHITECTURE_arm64) && defined(_MSC_VER)
__yield();
#elif defined(ARCHITECTURE_arm64)
asm("yield");
#endif
}
}
inline void unlock() noexcept {
lck.clear(std::memory_order_release);
}
[[nodiscard]] inline bool try_lock() noexcept {
return !lck.test_and_set(std::memory_order_acquire);
}
std::atomic_flag lck = ATOMIC_FLAG_INIT;
};
} // namespace Common
+4 -3
View File
@@ -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 2020 yuzu Emulator Project
@@ -12,6 +12,7 @@
#include "common/atomic_ops.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/spin_lock.h"
namespace Kernel {
@@ -29,7 +30,7 @@ public:
};
public:
KSlabHeapImpl() = default;
constexpr KSlabHeapImpl() = default;
void Initialize() {
ASSERT(m_head == nullptr);
@@ -67,7 +68,7 @@ public:
private:
std::atomic<Node*> m_head{};
std::mutex m_lock;
Common::SpinLock m_lock;
};
} // namespace impl
+2 -1
View File
@@ -19,6 +19,7 @@
#include "common/intrusive_red_black_tree.h"
#include "common/scratch_buffer.h"
#include "common/spin_lock.h"
#include "core/arm/arm_interface.h"
#include "core/hle/kernel/k_affinity_mask.h"
#include "core/hle/kernel/k_light_lock.h"
@@ -919,7 +920,7 @@ private:
bool m_resource_limit_release_hint{};
bool m_is_kernel_address_key{};
StackParameters m_stack_parameters{};
std::mutex m_context_guard{};
Common::SpinLock m_context_guard{};
// For emulation
std::shared_ptr<Common::Fiber> m_host_context{};
+4
View File
@@ -444,6 +444,10 @@ if (YUZU_ROOM)
target_link_libraries(yuzu PRIVATE yuzu-room)
endif()
if (LINKER STREQUAL "lld")
target_link_options(yuzu-cmd PRIVATE "LINKER:--icf=all")
endif()
if (NOT MSVC AND (APPLE OR NOT YUZU_STATIC_BUILD))
# needed for vma
target_compile_options(yuzu PRIVATE
+4
View File
@@ -67,6 +67,10 @@ endif()
create_target_directory_groups(yuzu-cmd)
if (LINKER STREQUAL "lld")
target_link_options(yuzu-cmd PRIVATE "LINKER:--icf=all")
endif()
# needed for vma
if (NOT MSVC)
target_compile_options(yuzu-cmd PRIVATE