Atmosphere/libraries/libstratosphere/source/os/os_sdk_reply_and_receive.cpp

48 lines
1.7 KiB
C++
Raw Permalink Normal View History

2021-01-13 02:18:39 +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>
#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 {
ALWAYS_INLINE impl::MultiWaitImpl &GetMultiWaitImpl(MultiWaitType *multi_wait) {
return GetReference(multi_wait->impl_storage);
2021-01-13 02:18:39 +00:00
}
ALWAYS_INLINE MultiWaitHolderType *CastToMultiWaitHolder(impl::MultiWaitHolderBase *base) {
return reinterpret_cast<MultiWaitHolderType *>(base);
2021-01-13 02:18:39 +00:00
}
}
Result SdkReplyAndReceive(os::MultiWaitHolderType **out, NativeHandle reply_target, MultiWaitType *multi_wait) {
auto &impl = GetMultiWaitImpl(multi_wait);
2021-01-13 02:18:39 +00:00
AMS_ASSERT(multi_wait->state == MultiWaitType::State_Initialized);
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;
ON_SCOPE_EXIT { *out = CastToMultiWaitHolder(holder_base); };
2021-01-13 02:18:39 +00:00
R_RETURN(impl.ReplyAndReceive(std::addressof(holder_base), reply_target));
2021-01-13 02:18:39 +00:00
}
}