2021-01-13 02:18:39 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2018-2020 Atmosphère-NX
|
|
|
|
*
|
|
|
|
* 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-01 02:00:47 +00:00
|
|
|
Result SdkReplyAndReceive(os::MultiWaitHolderType **out, Handle reply_target, MultiWaitType *multi_wait) {
|
|
|
|
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);
|
2021-01-13 02:18:39 +00:00
|
|
|
AMS_ASSERT(!impl.IsEmpty());
|
|
|
|
|
2021-10-01 02:00:47 +00:00
|
|
|
impl::MultiWaitHolderBase *holder_base;
|
|
|
|
ON_SCOPE_EXIT { *out = CastToMultiWaitHolder(holder_base); };
|
2021-01-13 02:18:39 +00:00
|
|
|
|
|
|
|
return impl.ReplyAndReceive(std::addressof(holder_base), reply_target);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|