diff options
| author | 2020-02-26 14:39:27 -0400 | |
|---|---|---|
| committer | 2020-06-18 16:29:24 -0400 | |
| commit | 7d2b1a6ec4a1c0daea0bac83a83c85f263609224 (patch) | |
| tree | 4bfd899d0f5a4f6e4d24a529c74a46ce5efed061 /src | |
| parent | Host Timing: Correct clang format. (diff) | |
| download | yuzu-7d2b1a6ec4a1c0daea0bac83a83c85f263609224.tar.gz yuzu-7d2b1a6ec4a1c0daea0bac83a83c85f263609224.tar.xz yuzu-7d2b1a6ec4a1c0daea0bac83a83c85f263609224.zip | |
Common/Fiber: Correct f_context based Fibers.
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/fiber.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/common/fiber.cpp b/src/common/fiber.cpp index e9c0946b6..3ef820c62 100644 --- a/src/common/fiber.cpp +++ b/src/common/fiber.cpp | |||
| @@ -81,10 +81,10 @@ std::shared_ptr<Fiber> Fiber::ThreadToFiber() { | |||
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | #else | 83 | #else |
| 84 | constexpr std::size_t default_stack_size = 1024 * 1024 * 4; // 4MB | 84 | constexpr std::size_t default_stack_size = 1024 * 1024; // 4MB |
| 85 | 85 | ||
| 86 | struct alignas(64) Fiber::FiberImpl { | 86 | struct Fiber::FiberImpl { |
| 87 | std::array<u8, default_stack_size> stack; | 87 | alignas(64) std::array<u8, default_stack_size> stack; |
| 88 | boost::context::detail::fcontext_t context; | 88 | boost::context::detail::fcontext_t context; |
| 89 | }; | 89 | }; |
| 90 | 90 | ||
| @@ -106,8 +106,10 @@ Fiber::Fiber(std::function<void(void*)>&& entry_point_func, void* start_paramete | |||
| 106 | : guard{}, entry_point{std::move(entry_point_func)}, start_parameter{start_parameter}, | 106 | : guard{}, entry_point{std::move(entry_point_func)}, start_parameter{start_parameter}, |
| 107 | previous_fiber{} { | 107 | previous_fiber{} { |
| 108 | impl = std::make_unique<FiberImpl>(); | 108 | impl = std::make_unique<FiberImpl>(); |
| 109 | impl->context = boost::context::detail::make_fcontext(impl->stack.data(), impl->stack.size(), | 109 | void* stack_start = |
| 110 | FiberStartFunc); | 110 | static_cast<void*>(static_cast<std::uintptr_t>(impl->stack.data()) + default_stack_size); |
| 111 | impl->context = | ||
| 112 | boost::context::detail::make_fcontext(stack_start, impl->stack.size(), FiberStartFunc); | ||
| 111 | } | 113 | } |
| 112 | 114 | ||
| 113 | Fiber::Fiber() { | 115 | Fiber::Fiber() { |
| @@ -136,7 +138,7 @@ void Fiber::YieldTo(std::shared_ptr<Fiber> from, std::shared_ptr<Fiber> to) { | |||
| 136 | ASSERT_MSG(to != nullptr, "Next fiber is null!"); | 138 | ASSERT_MSG(to != nullptr, "Next fiber is null!"); |
| 137 | to->guard.lock(); | 139 | to->guard.lock(); |
| 138 | to->previous_fiber = from; | 140 | to->previous_fiber = from; |
| 139 | auto transfer = boost::context::detail::jump_fcontext(to->impl->context, nullptr); | 141 | auto transfer = boost::context::detail::jump_fcontext(to->impl->context, to.get()); |
| 140 | auto previous_fiber = from->previous_fiber; | 142 | auto previous_fiber = from->previous_fiber; |
| 141 | ASSERT(previous_fiber != nullptr); | 143 | ASSERT(previous_fiber != nullptr); |
| 142 | previous_fiber->impl->context = transfer.fctx; | 144 | previous_fiber->impl->context = transfer.fctx; |