diff options
| author | 2019-03-14 00:29:54 -0400 | |
|---|---|---|
| committer | 2019-03-14 20:55:52 -0400 | |
| commit | 555cd26ec2b848634370a14d41b7e79b6c6beecd (patch) | |
| tree | 4ec6b8245280f94b44969356c9f2a44b22abd00e /src/core/hle/kernel/mutex.cpp | |
| parent | Merge pull request #2230 from lioncash/global (diff) | |
| download | yuzu-555cd26ec2b848634370a14d41b7e79b6c6beecd.tar.gz yuzu-555cd26ec2b848634370a14d41b7e79b6c6beecd.tar.xz yuzu-555cd26ec2b848634370a14d41b7e79b6c6beecd.zip | |
core/hle/kernel: Make Mutex a per-process class.
Makes it an instantiable class like it is in the actual kernel. This
will also allow removing reliance on global accessors in a following
change, now that we can encapsulate a reference to the system instance
in the class.
Diffstat (limited to 'src/core/hle/kernel/mutex.cpp')
| -rw-r--r-- | src/core/hle/kernel/mutex.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index 0743670ad..260e25fde 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp | |||
| @@ -2,7 +2,6 @@ | |||
| 2 | // Licensed under GPLv2 or any later version | 2 | // Licensed under GPLv2 or any later version |
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <map> | ||
| 6 | #include <utility> | 5 | #include <utility> |
| 7 | #include <vector> | 6 | #include <vector> |
| 8 | 7 | ||
| @@ -10,8 +9,10 @@ | |||
| 10 | #include "core/core.h" | 9 | #include "core/core.h" |
| 11 | #include "core/hle/kernel/errors.h" | 10 | #include "core/hle/kernel/errors.h" |
| 12 | #include "core/hle/kernel/handle_table.h" | 11 | #include "core/hle/kernel/handle_table.h" |
| 12 | #include "core/hle/kernel/kernel.h" | ||
| 13 | #include "core/hle/kernel/mutex.h" | 13 | #include "core/hle/kernel/mutex.h" |
| 14 | #include "core/hle/kernel/object.h" | 14 | #include "core/hle/kernel/object.h" |
| 15 | #include "core/hle/kernel/process.h" | ||
| 15 | #include "core/hle/kernel/thread.h" | 16 | #include "core/hle/kernel/thread.h" |
| 16 | #include "core/hle/result.h" | 17 | #include "core/hle/result.h" |
| 17 | #include "core/memory.h" | 18 | #include "core/memory.h" |
| @@ -57,13 +58,17 @@ static void TransferMutexOwnership(VAddr mutex_addr, SharedPtr<Thread> current_t | |||
| 57 | } | 58 | } |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | ResultCode Mutex::TryAcquire(HandleTable& handle_table, VAddr address, Handle holding_thread_handle, | 61 | Mutex::Mutex(Core::System& system) : system{system} {} |
| 62 | Mutex::~Mutex() = default; | ||
| 63 | |||
| 64 | ResultCode Mutex::TryAcquire(VAddr address, Handle holding_thread_handle, | ||
| 61 | Handle requesting_thread_handle) { | 65 | Handle requesting_thread_handle) { |
| 62 | // The mutex address must be 4-byte aligned | 66 | // The mutex address must be 4-byte aligned |
| 63 | if ((address % sizeof(u32)) != 0) { | 67 | if ((address % sizeof(u32)) != 0) { |
| 64 | return ERR_INVALID_ADDRESS; | 68 | return ERR_INVALID_ADDRESS; |
| 65 | } | 69 | } |
| 66 | 70 | ||
| 71 | const auto& handle_table = system.Kernel().CurrentProcess()->GetHandleTable(); | ||
| 67 | SharedPtr<Thread> holding_thread = handle_table.Get<Thread>(holding_thread_handle); | 72 | SharedPtr<Thread> holding_thread = handle_table.Get<Thread>(holding_thread_handle); |
| 68 | SharedPtr<Thread> requesting_thread = handle_table.Get<Thread>(requesting_thread_handle); | 73 | SharedPtr<Thread> requesting_thread = handle_table.Get<Thread>(requesting_thread_handle); |
| 69 | 74 | ||