summaryrefslogtreecommitdiff
path: root/src/core/hle/svc.cpp
diff options
context:
space:
mode:
authorGravatar Subv2016-12-14 12:13:02 -0500
committerGravatar Subv2016-12-14 12:35:01 -0500
commit5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2 (patch)
treeb6fbcc194effc5e05a608ebde0ea3c887720d920 /src/core/hle/svc.cpp
parentProperly remove a thread from its wait_objects' waitlist when it is awoken by... (diff)
downloadyuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.tar.gz
yuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.tar.xz
yuzu-5b1edc6ae70972d4a11eee1f1ff8fdff2122b5a2.zip
Fixed the codestyle to match our clang-format rules.
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r--src/core/hle/svc.cpp47
1 files changed, 28 insertions, 19 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp
index c81c14443..a4a00d9b2 100644
--- a/src/core/hle/svc.cpp
+++ b/src/core/hle/svc.cpp
@@ -264,14 +264,16 @@ static ResultCode WaitSynchronization1(Handle handle, s64 nano_seconds) {
264 return ERR_SYNC_TIMEOUT; 264 return ERR_SYNC_TIMEOUT;
265 265
266 object->AddWaitingThread(thread); 266 object->AddWaitingThread(thread);
267 // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion. 267 // TODO(Subv): Perform things like update the mutex lock owner's priority to
268 // Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here. 268 // prevent priority inversion. Currently this is done in Mutex::ShouldWait,
269 // but it should be moved to a function that is called from here.
269 thread->status = THREADSTATUS_WAIT_SYNCH; 270 thread->status = THREADSTATUS_WAIT_SYNCH;
270 271
271 // Create an event to wake the thread up after the specified nanosecond delay has passed 272 // Create an event to wake the thread up after the specified nanosecond delay has passed
272 thread->WakeAfterDelay(nano_seconds); 273 thread->WakeAfterDelay(nano_seconds);
273 274
274 // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a signal in its wait objects. 275 // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread
276 // resumes due to a signal in its wait objects.
275 // Otherwise we retain the default value of timeout. 277 // Otherwise we retain the default value of timeout.
276 return ERR_SYNC_TIMEOUT; 278 return ERR_SYNC_TIMEOUT;
277 } 279 }
@@ -316,20 +318,22 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
316 thread->wait_objects_index.clear(); 318 thread->wait_objects_index.clear();
317 319
318 if (wait_all) { 320 if (wait_all) {
319 bool all_available = std::all_of(objects.begin(), objects.end(), [](const ObjectPtr& object) { 321 bool all_available =
320 return !object->ShouldWait(); 322 std::all_of(objects.begin(), objects.end(),
321 }); 323 [](const ObjectPtr& object) { return !object->ShouldWait(); });
322 if (all_available) { 324 if (all_available) {
323 // We can acquire all objects right now, do so. 325 // We can acquire all objects right now, do so.
324 for (auto& object : objects) 326 for (auto& object : objects)
325 object->Acquire(); 327 object->Acquire();
326 // Note: In this case, the `out` parameter is not set, and retains whatever value it had before. 328 // Note: In this case, the `out` parameter is not set,
329 // and retains whatever value it had before.
327 return RESULT_SUCCESS; 330 return RESULT_SUCCESS;
328 } 331 }
329 332
330 // Not all objects were available right now, prepare to suspend the thread. 333 // Not all objects were available right now, prepare to suspend the thread.
331 334
332 // If a timeout value of 0 was provided, just return the Timeout error code instead of suspending the thread. 335 // If a timeout value of 0 was provided, just return the Timeout error code instead of
336 // suspending the thread.
333 if (nano_seconds == 0) 337 if (nano_seconds == 0)
334 return ERR_SYNC_TIMEOUT; 338 return ERR_SYNC_TIMEOUT;
335 339
@@ -339,8 +343,9 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
339 // Add the thread to each of the objects' waiting threads. 343 // Add the thread to each of the objects' waiting threads.
340 for (auto& object : objects) { 344 for (auto& object : objects) {
341 object->AddWaitingThread(thread); 345 object->AddWaitingThread(thread);
342 // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion. 346 // TODO(Subv): Perform things like update the mutex lock owner's priority to
343 // Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here. 347 // prevent priority inversion. Currently this is done in Mutex::ShouldWait,
348 // but it should be moved to a function that is called from here.
344 } 349 }
345 350
346 // Set the thread's waitlist to the list of objects passed to WaitSynchronizationN 351 // Set the thread's waitlist to the list of objects passed to WaitSynchronizationN
@@ -351,13 +356,13 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
351 356
352 // This value gets set to -1 by default in this case, it is not modified after this. 357 // This value gets set to -1 by default in this case, it is not modified after this.
353 *out = -1; 358 *out = -1;
354 // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a signal in one of its wait objects. 359 // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to
360 // a signal in one of its wait objects.
355 return ERR_SYNC_TIMEOUT; 361 return ERR_SYNC_TIMEOUT;
356 } else { 362 } else {
357 // Find the first object that is acquirable in the provided list of objects 363 // Find the first object that is acquirable in the provided list of objects
358 auto itr = std::find_if(objects.begin(), objects.end(), [](const ObjectPtr& object) { 364 auto itr = std::find_if(objects.begin(), objects.end(),
359 return !object->ShouldWait(); 365 [](const ObjectPtr& object) { return !object->ShouldWait(); });
360 });
361 366
362 if (itr != objects.end()) { 367 if (itr != objects.end()) {
363 // We found a ready object, acquire it and set the result value 368 // We found a ready object, acquire it and set the result value
@@ -369,7 +374,8 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
369 374
370 // No objects were ready to be acquired, prepare to suspend the thread. 375 // No objects were ready to be acquired, prepare to suspend the thread.
371 376
372 // If a timeout value of 0 was provided, just return the Timeout error code instead of suspending the thread. 377 // If a timeout value of 0 was provided, just return the Timeout error code instead of
378 // suspending the thread.
373 if (nano_seconds == 0) 379 if (nano_seconds == 0)
374 return ERR_SYNC_TIMEOUT; 380 return ERR_SYNC_TIMEOUT;
375 381
@@ -385,16 +391,19 @@ static ResultCode WaitSynchronizationN(s32* out, Handle* handles, s32 handle_cou
385 // Set the index of this object in the mapping of Objects -> index for this thread. 391 // Set the index of this object in the mapping of Objects -> index for this thread.
386 thread->wait_objects_index[object->GetObjectId()] = static_cast<int>(i); 392 thread->wait_objects_index[object->GetObjectId()] = static_cast<int>(i);
387 object->AddWaitingThread(thread); 393 object->AddWaitingThread(thread);
388 // TODO(Subv): Perform things like update the mutex lock owner's priority to prevent priority inversion. 394 // TODO(Subv): Perform things like update the mutex lock owner's priority to
389 // Currently this is done in Mutex::ShouldWait, but it should be moved to a function that is called from here. 395 // prevent priority inversion. Currently this is done in Mutex::ShouldWait,
396 // but it should be moved to a function that is called from here.
390 } 397 }
391 398
392 // Note: If no handles and no timeout were given, then the thread will deadlock, this is consistent with hardware behavior. 399 // Note: If no handles and no timeout were given, then the thread will deadlock, this is
400 // consistent with hardware behavior.
393 401
394 // Create an event to wake the thread up after the specified nanosecond delay has passed 402 // Create an event to wake the thread up after the specified nanosecond delay has passed
395 thread->WakeAfterDelay(nano_seconds); 403 thread->WakeAfterDelay(nano_seconds);
396 404
397 // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a signal in one of its wait objects. 405 // Note: The output of this SVC will be set to RESULT_SUCCESS if the thread resumes due to a
406 // signal in one of its wait objects.
398 // Otherwise we retain the default value of timeout, and -1 in the out parameter 407 // Otherwise we retain the default value of timeout, and -1 in the out parameter
399 thread->wait_set_output = true; 408 thread->wait_set_output = true;
400 *out = -1; 409 *out = -1;