aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar bunnei <bunneidev@gmail.com>2015-01-18 02:16:54 -0500
committerGravatar bunnei <bunneidev@gmail.com>2015-01-21 19:12:51 -0500
commit6deb1a0119eb4f17490ed2603d5a608bcf71413a (patch)
tree7e93992b1c176dd4b3b74dece0d395623cad934b /src/core/hle/svc.cpp
parent6643673f28b9273149fc945849a13ed832e9ef33 (diff)
WaitSynchronizationN: Improved comments
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index 05945110..01b53608 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -149,15 +149,20 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
bool wait_thread = !wait_all;
int handle_index = 0;
- // Handles pointer is invalid
+ // Check if 'handles' is invalid
if (handles == nullptr)
return ResultCode(ErrorDescription::InvalidPointer, ErrorModule::Kernel, ErrorSummary::InvalidArgument, ErrorLevel::Permanent).raw;
- // Negative handle_count is invalid
+ // NOTE: on real hardware, there is no nullptr check for 'out' (tested with firmware 4.4). If
+ // this happens, the running application will crash.
+ _assert_msg_(Kernel, out != nullptr, "invalid output pointer specified!");
+
+ // Check if 'handle_count' is invalid
if (handle_count < 0)
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::OS, ErrorSummary::InvalidArgument, ErrorLevel::Usage).raw;
- // If handle_count is non-zero, iterate through them and wait the current thread on the objects
+ // If 'handle_count' is non-zero, iterate through each handle and wait the current thread if
+ // necessary
if (handle_count != 0) {
bool selected = false; // True once an object has been selected
for (int i = 0; i < handle_count; ++i) {
@@ -167,7 +172,7 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
ResultVal<bool> wait = object->Wait(true);
- // Check if the current thread should wait on the object...
+ // Check if the current thread should wait on this object...
if (wait.Succeeded() && *wait) {
// Check we are waiting on all objects...
if (wait_all)
@@ -184,15 +189,15 @@ static Result WaitSynchronizationN(s32* out, Handle* handles, s32 handle_count,
}
}
} else {
- // If no handles were passed in, put the thread to sleep only when wait_all=false
- // NOTE: This is supposed to deadlock the current thread if no timeout was specified
+ // If no handles were passed in, put the thread to sleep only when 'wait_all' is false
+ // NOTE: This should deadlock the current thread if no timeout was specified
if (!wait_all) {
wait_thread = true;
Kernel::WaitCurrentThread(WAITTYPE_SLEEP);
}
}
- // If thread should block, then set its state to waiting and then reschedule...
+ // If thread should wait, then set its state to waiting and then reschedule...
if (wait_thread) {
// Create an event to wake the thread up after the specified nanosecond delay has passed
Kernel::WakeThreadAfterDelay(Kernel::GetCurrentThread(), nano_seconds);