diff options
author | bunnei <bunneidev@gmail.com> | 2017-01-12 16:14:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-12 16:14:30 +0100 |
commit | 7ddfd3054dc67fa727ec7c7267f27a438ac37dc3 (patch) | |
tree | 30bd821242a3f3dad780595673c3d5adf92ebe86 /src/core/hle/kernel/thread.cpp | |
parent | Merge pull request #2308 from mailwl/ac-i (diff) | |
parent | Threads: Check the process' resource limit for the max allowed priority when creating a thread and remove the priority clamping code. (diff) | |
download | yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.tar yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.tar.gz yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.tar.bz2 yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.tar.lz yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.tar.xz yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.tar.zst yuzu-7ddfd3054dc67fa727ec7c7267f27a438ac37dc3.zip |
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r-- | src/core/hle/kernel/thread.cpp | 30 |
1 files changed, 4 insertions, 26 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 8c6fbcd04..3b7555d87 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -353,14 +353,8 @@ static void ResetThreadContext(ARM_Interface::ThreadContext& context, u32 stack_ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, s32 priority, u32 arg, s32 processor_id, VAddr stack_top) { - if (priority < THREADPRIO_HIGHEST || priority > THREADPRIO_LOWEST) { - s32 new_priority = MathUtil::Clamp<s32>(priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); - LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d", name.c_str(), - priority, new_priority); - // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm - // validity of this - priority = new_priority; - } + ASSERT_MSG(priority >= THREADPRIO_HIGHEST && priority <= THREADPRIO_LOWEST, + "Invalid thread priority"); if (!Memory::IsValidVirtualAddress(entry_point)) { LOG_ERROR(Kernel_SVC, "(name=%s): invalid entry %08x", name.c_str(), entry_point); @@ -444,25 +438,9 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, return MakeResult<SharedPtr<Thread>>(std::move(thread)); } -// TODO(peachum): Remove this. Range checking should be done, and an appropriate error should be -// returned. -static void ClampPriority(const Thread* thread, s32* priority) { - if (*priority < THREADPRIO_HIGHEST || *priority > THREADPRIO_LOWEST) { - DEBUG_ASSERT_MSG( - false, "Application passed an out of range priority. An error should be returned."); - - s32 new_priority = MathUtil::Clamp<s32>(*priority, THREADPRIO_HIGHEST, THREADPRIO_LOWEST); - LOG_WARNING(Kernel_SVC, "(name=%s): invalid priority=%d, clamping to %d", - thread->name.c_str(), *priority, new_priority); - // TODO(bunnei): Clamping to a valid priority is not necessarily correct behavior... Confirm - // validity of this - *priority = new_priority; - } -} - void Thread::SetPriority(s32 priority) { - ClampPriority(this, &priority); - + ASSERT_MSG(priority <= THREADPRIO_LOWEST && priority >= THREADPRIO_HIGHEST, + "Invalid priority value."); // If thread was ready, adjust queues if (status == THREADSTATUS_READY) ready_queue.move(this, current_priority, priority); |