diff options
author | bunnei <bunneidev@gmail.com> | 2014-12-20 22:36:01 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2014-12-20 22:36:01 +0100 |
commit | 2e5869c9395c2304cfc43a28bf734c345f845b65 (patch) | |
tree | 0c382725b245a82d9e0569deab332a64477fe438 /src/core/hle/kernel/kernel.h | |
parent | Merge pull request #296 from lioncash/dyn (diff) | |
parent | Kernel: Implement support for current thread pseudo-handle (diff) | |
download | yuzu-2e5869c9395c2304cfc43a28bf734c345f845b65.tar yuzu-2e5869c9395c2304cfc43a28bf734c345f845b65.tar.gz yuzu-2e5869c9395c2304cfc43a28bf734c345f845b65.tar.bz2 yuzu-2e5869c9395c2304cfc43a28bf734c345f845b65.tar.lz yuzu-2e5869c9395c2304cfc43a28bf734c345f845b65.tar.xz yuzu-2e5869c9395c2304cfc43a28bf734c345f845b65.tar.zst yuzu-2e5869c9395c2304cfc43a28bf734c345f845b65.zip |
Diffstat (limited to 'src/core/hle/kernel/kernel.h')
-rw-r--r-- | src/core/hle/kernel/kernel.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 7123485be..683fffeee 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -14,6 +14,10 @@ typedef s32 Result; namespace Kernel { +// From kernel.h. Declarations duplicated here to avoid a circular header dependency. +class Thread; +Thread* GetCurrentThread(); + enum KernelHandle { CurrentThread = 0xFFFF8000, CurrentProcess = 0xFFFF8001, @@ -81,6 +85,10 @@ public: template <class T> T* Get(Handle handle) { + if (handle == CurrentThread) { + return reinterpret_cast<T*>(GetCurrentThread()); + } + if (handle < HANDLE_OFFSET || handle >= HANDLE_OFFSET + MAX_COUNT || !occupied[handle - HANDLE_OFFSET]) { if (handle != 0) { LOG_ERROR(Kernel, "Bad object handle %08x", handle); @@ -99,6 +107,10 @@ public: // ONLY use this when you know the handle is valid. template <class T> T *GetFast(Handle handle) { + if (handle == CurrentThread) { + return reinterpret_cast<T*>(GetCurrentThread()); + } + const Handle realHandle = handle - HANDLE_OFFSET; _dbg_assert_(Kernel, realHandle >= 0 && realHandle < MAX_COUNT && occupied[realHandle]); return static_cast<T*>(pool[realHandle]); |