2021-01-13 02:18:39 +00:00
|
|
|
/*
|
2021-10-04 19:59:10 +00:00
|
|
|
* Copyright (c) Atmosphère-NX
|
2021-01-13 02:18:39 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
#include <stratosphere.hpp>
|
2021-10-01 02:00:47 +00:00
|
|
|
#include "impl/os_multiple_wait_impl.hpp"
|
|
|
|
#include "impl/os_multiple_wait_holder_base.hpp"
|
|
|
|
#include "impl/os_multiple_wait_holder_impl.hpp"
|
2021-01-13 02:18:39 +00:00
|
|
|
|
|
|
|
namespace ams::os {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
2021-10-01 02:00:47 +00:00
|
|
|
ALWAYS_INLINE impl::MultiWaitImpl &GetMultiWaitImpl(MultiWaitType *multi_wait) {
|
|
|
|
return GetReference(multi_wait->impl_storage);
|
2021-01-13 02:18:39 +00:00
|
|
|
}
|
|
|
|
|
2021-10-01 02:00:47 +00:00
|
|
|
ALWAYS_INLINE MultiWaitHolderType *CastToMultiWaitHolder(impl::MultiWaitHolderBase *base) {
|
|
|
|
return reinterpret_cast<MultiWaitHolderType *>(base);
|
2021-01-13 02:18:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-10-04 19:33:09 +00:00
|
|
|
Result SdkReplyAndReceive(os::MultiWaitHolderType **out, NativeHandle reply_target, MultiWaitType *multi_wait) {
|
2021-10-01 02:00:47 +00:00
|
|
|
auto &impl = GetMultiWaitImpl(multi_wait);
|
2021-01-13 02:18:39 +00:00
|
|
|
|
2021-10-01 02:00:47 +00:00
|
|
|
AMS_ASSERT(multi_wait->state == MultiWaitType::State_Initialized);
|
2022-04-12 23:47:36 +00:00
|
|
|
AMS_ASSERT(impl.IsListNotEmpty());
|
2021-01-13 02:18:39 +00:00
|
|
|
|
2022-04-16 19:28:21 +00:00
|
|
|
impl::MultiWaitHolderBase *holder_base = nullptr;
|
2021-10-01 02:00:47 +00:00
|
|
|
ON_SCOPE_EXIT { *out = CastToMultiWaitHolder(holder_base); };
|
2021-01-13 02:18:39 +00:00
|
|
|
|
2022-03-26 21:48:33 +00:00
|
|
|
R_RETURN(impl.ReplyAndReceive(std::addressof(holder_base), reply_target));
|
2021-01-13 02:18:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|