ams: globally prefer R_RETURN to return for ams::Result
This commit is contained in:
@@ -26,6 +26,18 @@ namespace ams::os::impl {
|
||||
m_target_impl.SetCurrentThreadHandleForCancelWait();
|
||||
MultiWaitHolderBase *holder = this->LinkHoldersToObjectList();
|
||||
|
||||
/* When we're done, cleanup and set output. */
|
||||
ON_SCOPE_EXIT {
|
||||
/* Unlink holders from the current object list. */
|
||||
this->UnlinkHoldersFromObjectList();
|
||||
|
||||
/* Clear cancel wait. */
|
||||
m_target_impl.ClearCurrentThreadHandleForCancelWait();
|
||||
|
||||
/* Set output holder. */
|
||||
*out = holder;
|
||||
};
|
||||
|
||||
/* Check if we've been signaled. */
|
||||
{
|
||||
std::scoped_lock lk(m_cs_wait);
|
||||
@@ -35,28 +47,16 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
/* Process object array. */
|
||||
Result wait_result = ResultSuccess();
|
||||
if (holder != nullptr) {
|
||||
if (reply && reply_target != os::InvalidNativeHandle) {
|
||||
s32 index;
|
||||
wait_result = m_target_impl.TimedReplyAndReceive(std::addressof(index), nullptr, 0, 0, reply_target, TimeSpan::FromNanoSeconds(0));
|
||||
if (R_FAILED(wait_result)) {
|
||||
holder = nullptr;
|
||||
}
|
||||
}
|
||||
R_SUCCEED_IF(!(reply && reply_target != os::InvalidNativeHandle));
|
||||
|
||||
ON_RESULT_FAILURE { holder = nullptr; };
|
||||
|
||||
s32 index;
|
||||
R_RETURN(m_target_impl.TimedReplyAndReceive(std::addressof(index), nullptr, 0, 0, reply_target, TimeSpan::FromNanoSeconds(0)))
|
||||
} else {
|
||||
wait_result = this->WaitAnyHandleImpl(std::addressof(holder), infinite, timeout, reply, reply_target);
|
||||
R_RETURN(this->WaitAnyHandleImpl(std::addressof(holder), infinite, timeout, reply, reply_target));
|
||||
}
|
||||
|
||||
/* Unlink holders from the current object list. */
|
||||
this->UnlinkHoldersFromObjectList();
|
||||
|
||||
m_target_impl.ClearCurrentThreadHandleForCancelWait();
|
||||
|
||||
/* Set output holder. */
|
||||
*out = holder;
|
||||
|
||||
return wait_result;
|
||||
}
|
||||
|
||||
Result MultiWaitImpl::WaitAnyHandleImpl(MultiWaitHolderBase **out, bool infinite, TimeSpan timeout, bool reply, NativeHandle reply_target) {
|
||||
@@ -93,7 +93,7 @@ namespace ams::os::impl {
|
||||
|
||||
if (index == WaitInvalid) {
|
||||
*out = nullptr;
|
||||
return wait_result;
|
||||
R_RETURN(wait_result);
|
||||
}
|
||||
|
||||
switch (index) {
|
||||
@@ -104,11 +104,11 @@ namespace ams::os::impl {
|
||||
std::scoped_lock lk(m_cs_wait);
|
||||
m_signaled_holder = min_timeout_object;
|
||||
*out = min_timeout_object;
|
||||
return wait_result;
|
||||
R_RETURN(wait_result);
|
||||
}
|
||||
} else {
|
||||
*out = nullptr;
|
||||
return wait_result;
|
||||
R_RETURN(wait_result);
|
||||
}
|
||||
break;
|
||||
case WaitCancelled:
|
||||
@@ -116,7 +116,7 @@ namespace ams::os::impl {
|
||||
std::scoped_lock lk(m_cs_wait);
|
||||
if (m_signaled_holder) {
|
||||
*out = m_signaled_holder;
|
||||
return wait_result;
|
||||
R_RETURN(wait_result);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -128,7 +128,7 @@ namespace ams::os::impl {
|
||||
std::scoped_lock lk(m_cs_wait);
|
||||
m_signaled_holder = objects[index];
|
||||
*out = objects[index];
|
||||
return wait_result;
|
||||
R_RETURN(wait_result);
|
||||
} else {
|
||||
AMS_ABORT_UNLESS(MaximumHandleCount > 0);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
Result ReplyAndReceive(MultiWaitHolderBase **out, NativeHandle reply_target) {
|
||||
return this->WaitAnyImpl(out, true, TimeSpan::FromNanoSeconds(std::numeric_limits<s64>::max()), true, reply_target);
|
||||
R_RETURN(this->WaitAnyImpl(out, true, TimeSpan::FromNanoSeconds(std::numeric_limits<s64>::max()), true, reply_target));
|
||||
}
|
||||
|
||||
/* List management. */
|
||||
|
||||
@@ -47,8 +47,8 @@ namespace ams::os::impl {
|
||||
static_assert(MultiWaitImpl::WaitInvalid != -1);
|
||||
|
||||
R_TRY_CATCH(svc::ReplyAndReceive(std::addressof(index), arr, num, reply_target, ns)) {
|
||||
R_CATCH(svc::ResultTimedOut) { *out_index = MultiWaitImpl::WaitTimedOut; return R_CURRENT_RESULT; }
|
||||
R_CATCH(svc::ResultCancelled) { *out_index = MultiWaitImpl::WaitCancelled; return R_CURRENT_RESULT; }
|
||||
R_CATCH(svc::ResultTimedOut) { *out_index = MultiWaitImpl::WaitTimedOut; R_THROW(R_CURRENT_RESULT); }
|
||||
R_CATCH(svc::ResultCancelled) { *out_index = MultiWaitImpl::WaitCancelled; R_THROW(R_CURRENT_RESULT); }
|
||||
R_CATCH(svc::ResultSessionClosed) {
|
||||
if (index == -1) {
|
||||
*out_index = MultiWaitImpl::WaitInvalid;
|
||||
|
||||
@@ -33,11 +33,11 @@ namespace ams::os::impl {
|
||||
void CancelWait();
|
||||
|
||||
Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) {
|
||||
return this->WaitSynchronizationN(out_index, num, arr, array_size, svc::WaitInfinite);
|
||||
R_RETURN(this->WaitSynchronizationN(out_index, num, arr, array_size, svc::WaitInfinite));
|
||||
}
|
||||
|
||||
Result TryWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) {
|
||||
return this->WaitSynchronizationN(out_index, num, arr, array_size, 0);
|
||||
R_RETURN(this->WaitSynchronizationN(out_index, num, arr, array_size, 0));
|
||||
}
|
||||
|
||||
Result TimedWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, TimeSpan ts) {
|
||||
@@ -45,15 +45,15 @@ namespace ams::os::impl {
|
||||
if (timeout < 0) {
|
||||
timeout = 0;
|
||||
}
|
||||
return this->WaitSynchronizationN(out_index, num, arr, array_size, timeout);
|
||||
R_RETURN(this->WaitSynchronizationN(out_index, num, arr, array_size, timeout));
|
||||
}
|
||||
|
||||
Result ReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target) {
|
||||
return this->ReplyAndReceiveN(out_index, num, arr, array_size, std::numeric_limits<s64>::max(), reply_target);
|
||||
R_RETURN(this->ReplyAndReceiveN(out_index, num, arr, array_size, std::numeric_limits<s64>::max(), reply_target));
|
||||
}
|
||||
|
||||
Result TimedReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target, TimeSpan ts) {
|
||||
return this->ReplyAndReceiveN(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target);
|
||||
R_RETURN(this->ReplyAndReceiveN(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target));
|
||||
}
|
||||
|
||||
void SetCurrentThreadHandleForCancelWait() {
|
||||
|
||||
@@ -35,23 +35,23 @@ namespace ams::os::impl {
|
||||
void CancelWait();
|
||||
|
||||
Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) {
|
||||
return this->PollNativeHandlesImpl(out_index, num, arr, array_size, static_cast<s64>(-1));
|
||||
R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, static_cast<s64>(-1)));
|
||||
}
|
||||
|
||||
Result TryWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) {
|
||||
return this->PollNativeHandlesImpl(out_index, num, arr, array_size, 0);
|
||||
R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, 0));
|
||||
}
|
||||
|
||||
Result TimedWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, TimeSpan ts) {
|
||||
return this->PollNativeHandlesImpl(out_index, num, arr, array_size, ts.GetNanoSeconds());
|
||||
R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, ts.GetNanoSeconds()));
|
||||
}
|
||||
|
||||
Result ReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target) {
|
||||
return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits<s64>::max(), reply_target);
|
||||
R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits<s64>::max(), reply_target));
|
||||
}
|
||||
|
||||
Result TimedReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target, TimeSpan ts) {
|
||||
return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target);
|
||||
R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target));
|
||||
}
|
||||
|
||||
void SetCurrentThreadHandleForCancelWait() {
|
||||
|
||||
@@ -36,23 +36,23 @@ namespace ams::os::impl {
|
||||
void CancelWait();
|
||||
|
||||
Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) {
|
||||
return this->PollNativeHandlesImpl(out_index, num, arr, array_size, static_cast<s64>(-1));
|
||||
R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, static_cast<s64>(-1)));
|
||||
}
|
||||
|
||||
Result TryWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) {
|
||||
return this->PollNativeHandlesImpl(out_index, num, arr, array_size, 0);
|
||||
R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, 0));
|
||||
}
|
||||
|
||||
Result TimedWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, TimeSpan ts) {
|
||||
return this->PollNativeHandlesImpl(out_index, num, arr, array_size, ts.GetNanoSeconds());
|
||||
R_RETURN(this->PollNativeHandlesImpl(out_index, num, arr, array_size, ts.GetNanoSeconds()));
|
||||
}
|
||||
|
||||
Result ReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target) {
|
||||
return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits<s64>::max(), reply_target);
|
||||
R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits<s64>::max(), reply_target));
|
||||
}
|
||||
|
||||
Result TimedReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target, TimeSpan ts) {
|
||||
return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target);
|
||||
R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target));
|
||||
}
|
||||
|
||||
void SetCurrentThreadHandleForCancelWait() {
|
||||
|
||||
@@ -44,21 +44,21 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
Result WaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) {
|
||||
return this->WaitForMultipleObjectsImpl(out_index, num, arr, array_size, INFINITE);
|
||||
R_RETURN(this->WaitForMultipleObjectsImpl(out_index, num, arr, array_size, INFINITE));
|
||||
}
|
||||
|
||||
Result TryWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num) {
|
||||
return this->WaitForMultipleObjectsImpl(out_index, num, arr, array_size, 0);
|
||||
R_RETURN(this->WaitForMultipleObjectsImpl(out_index, num, arr, array_size, 0));
|
||||
}
|
||||
|
||||
Result TimedWaitAny(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, TimeSpan ts);
|
||||
|
||||
Result ReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target) {
|
||||
return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits<s64>::max(), reply_target);
|
||||
R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, std::numeric_limits<s64>::max(), reply_target));
|
||||
}
|
||||
|
||||
Result TimedReplyAndReceive(s32 *out_index, NativeHandle arr[], s32 array_size, s32 num, NativeHandle reply_target, TimeSpan ts) {
|
||||
return this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target);
|
||||
R_RETURN(this->ReplyAndReceiveImpl(out_index, num, arr, array_size, ts.GetNanoSeconds(), reply_target));
|
||||
}
|
||||
|
||||
void SetCurrentThreadHandleForCancelWait() {
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE Result GetProcessId(ProcessId *out, NativeHandle handle) {
|
||||
return svc::GetProcessId(std::addressof(out->value), handle);
|
||||
R_RETURN(svc::GetProcessId(std::addressof(out->value), handle));
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE Result GetProgramId(ncm::ProgramId *out, NativeHandle handle) {
|
||||
return svc::GetInfo(std::addressof(out->value), svc::InfoType_ProgramId, handle, 0);
|
||||
R_RETURN(svc::GetInfo(std::addressof(out->value), svc::InfoType_ProgramId, handle, 0));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ namespace ams::os::impl {
|
||||
}
|
||||
|
||||
Result ThreadManager::CreateThread(ThreadType *thread, ThreadFunction function, void *argument, void *stack, size_t stack_size, s32 priority) {
|
||||
return this->CreateThread(thread, function, argument, stack, stack_size, priority, m_impl.GetDefaultCoreNumber());
|
||||
R_RETURN(this->CreateThread(thread, function, argument, stack, stack_size, priority, m_impl.GetDefaultCoreNumber()));
|
||||
}
|
||||
|
||||
void ThreadManager::DestroyThread(ThreadType *thread) {
|
||||
|
||||
Reference in New Issue
Block a user