summaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-02-10 13:33:13 -0400
committerGravatar Fernando Sahmkow2020-06-18 16:29:19 -0400
commit1bd706344e2381e11245b2f0bdc291429e46c634 (patch)
tree4abae5a2088df1eb023967d83c0b808eceb30cea /src/common
parentCommon: Correct fcontext fibers. (diff)
downloadyuzu-1bd706344e2381e11245b2f0bdc291429e46c634.tar.gz
yuzu-1bd706344e2381e11245b2f0bdc291429e46c634.tar.xz
yuzu-1bd706344e2381e11245b2f0bdc291429e46c634.zip
Common/Tests: Clang Format.
Diffstat (limited to 'src/common')
-rw-r--r--src/common/fiber.cpp21
-rw-r--r--src/common/fiber.h2
-rw-r--r--src/common/wall_clock.cpp12
-rw-r--r--src/common/wall_clock.h4
4 files changed, 21 insertions, 18 deletions
diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp
index e91d86dbe..a46be73c1 100644
--- a/src/common/fiber.cpp
+++ b/src/common/fiber.cpp
@@ -12,7 +12,6 @@
12 12
13namespace Common { 13namespace Common {
14 14
15
16#ifdef _MSC_VER 15#ifdef _MSC_VER
17 16
18struct Fiber::FiberImpl { 17struct Fiber::FiberImpl {
@@ -27,14 +26,14 @@ void Fiber::start() {
27 UNREACHABLE(); 26 UNREACHABLE();
28} 27}
29 28
30void __stdcall Fiber::FiberStartFunc(void* fiber_parameter) 29void __stdcall Fiber::FiberStartFunc(void* fiber_parameter) {
31{ 30 auto fiber = static_cast<Fiber*>(fiber_parameter);
32 auto fiber = static_cast<Fiber *>(fiber_parameter); 31 fiber->start();
33 fiber->start();
34} 32}
35 33
36Fiber::Fiber(std::function<void(void*)>&& entry_point_func, void* start_parameter) 34Fiber::Fiber(std::function<void(void*)>&& entry_point_func, void* start_parameter)
37 : guard{}, entry_point{std::move(entry_point_func)}, start_parameter{start_parameter}, previous_fiber{} { 35 : guard{}, entry_point{std::move(entry_point_func)}, start_parameter{start_parameter},
36 previous_fiber{} {
38 impl = std::make_unique<FiberImpl>(); 37 impl = std::make_unique<FiberImpl>();
39 impl->handle = CreateFiber(0, &FiberStartFunc, this); 38 impl->handle = CreateFiber(0, &FiberStartFunc, this);
40} 39}
@@ -99,14 +98,14 @@ void Fiber::start(boost::context::detail::transfer_t& transfer) {
99 UNREACHABLE(); 98 UNREACHABLE();
100} 99}
101 100
102void Fiber::FiberStartFunc(boost::context::detail::transfer_t transfer) 101void Fiber::FiberStartFunc(boost::context::detail::transfer_t transfer) {
103{ 102 auto fiber = static_cast<Fiber*>(transfer.data);
104 auto fiber = static_cast<Fiber *>(transfer.data); 103 fiber->start(transfer);
105 fiber->start(transfer);
106} 104}
107 105
108Fiber::Fiber(std::function<void(void*)>&& entry_point_func, void* start_parameter) 106Fiber::Fiber(std::function<void(void*)>&& entry_point_func, void* start_parameter)
109 : guard{}, entry_point{std::move(entry_point_func)}, start_parameter{start_parameter}, previous_fiber{} { 107 : guard{}, entry_point{std::move(entry_point_func)}, start_parameter{start_parameter},
108 previous_fiber{} {
110 impl = std::make_unique<FiberImpl>(); 109 impl = std::make_unique<FiberImpl>();
111 impl->context = boost::context::detail::make_fcontext(impl->stack.data(), impl->stack.size(), 110 impl->context = boost::context::detail::make_fcontext(impl->stack.data(), impl->stack.size(),
112 FiberStartFunc); 111 FiberStartFunc);
diff --git a/src/common/fiber.h b/src/common/fiber.h
index 89a01fdd8..b530bf4d2 100644
--- a/src/common/fiber.h
+++ b/src/common/fiber.h
@@ -12,7 +12,7 @@
12 12
13#ifndef _MSC_VER 13#ifndef _MSC_VER
14namespace boost::context::detail { 14namespace boost::context::detail {
15 struct transfer_t; 15struct transfer_t;
16} 16}
17#endif 17#endif
18 18
diff --git a/src/common/wall_clock.cpp b/src/common/wall_clock.cpp
index 8f5e17fa4..e6161c72c 100644
--- a/src/common/wall_clock.cpp
+++ b/src/common/wall_clock.cpp
@@ -58,7 +58,8 @@ private:
58 58
59#ifdef ARCHITECTURE_x86_64 59#ifdef ARCHITECTURE_x86_64
60 60
61std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, u32 emulated_clock_frequency) { 61std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
62 u32 emulated_clock_frequency) {
62 const auto& caps = GetCPUCaps(); 63 const auto& caps = GetCPUCaps();
63 u64 rtsc_frequency = 0; 64 u64 rtsc_frequency = 0;
64 if (caps.invariant_tsc) { 65 if (caps.invariant_tsc) {
@@ -70,15 +71,18 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, u
70 } 71 }
71 } 72 }
72 if (rtsc_frequency == 0) { 73 if (rtsc_frequency == 0) {
73 return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency); 74 return std::make_unique<StandardWallClock>(emulated_cpu_frequency,
75 emulated_clock_frequency);
74 } else { 76 } else {
75 return std::make_unique<X64::NativeClock>(emulated_cpu_frequency, emulated_clock_frequency, rtsc_frequency); 77 return std::make_unique<X64::NativeClock>(emulated_cpu_frequency, emulated_clock_frequency,
78 rtsc_frequency);
76 } 79 }
77} 80}
78 81
79#else 82#else
80 83
81std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, u32 emulated_clock_frequency) { 84std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
85 u32 emulated_clock_frequency) {
82 return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency); 86 return std::make_unique<StandardWallClock>(emulated_cpu_frequency, emulated_clock_frequency);
83} 87}
84 88
diff --git a/src/common/wall_clock.h b/src/common/wall_clock.h
index fc34429bb..ed284cf50 100644
--- a/src/common/wall_clock.h
+++ b/src/common/wall_clock.h
@@ -13,7 +13,6 @@ namespace Common {
13 13
14class WallClock { 14class WallClock {
15public: 15public:
16
17 /// Returns current wall time in nanoseconds 16 /// Returns current wall time in nanoseconds
18 virtual std::chrono::nanoseconds GetTimeNS() = 0; 17 virtual std::chrono::nanoseconds GetTimeNS() = 0;
19 18
@@ -46,6 +45,7 @@ private:
46 bool is_native; 45 bool is_native;
47}; 46};
48 47
49std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency, u32 emulated_clock_frequency); 48std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
49 u32 emulated_clock_frequency);
50 50
51} // namespace Common 51} // namespace Common