namespace sts -> namespace ams

namespace sts::ams -> ams::exosphere, ams::.

This is to facilitate future use of ams:: namespace code in
mesosphere, as we'll want to include ams::util, ams::result, ams::svc...
This commit is contained in:
Michael Scire
2019-10-24 02:30:10 -07:00
committed by SciresM
parent 4059dc6187
commit 8cb77ac136
397 changed files with 968 additions and 926 deletions

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
#include "os_inter_process_event.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
namespace {
@@ -40,7 +40,7 @@ namespace sts::os::impl {
}
Result InterProcessEvent::Initialize(bool autoclear) {
STS_ASSERT(!this->is_initialized);
AMS_ASSERT(!this->is_initialized);
Handle rh, wh;
R_TRY(CreateEventHandles(&rh, &wh));
this->Initialize(rh, true, wh, true, autoclear);
@@ -48,8 +48,8 @@ namespace sts::os::impl {
}
void InterProcessEvent::Initialize(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear) {
STS_ASSERT(!this->is_initialized);
STS_ASSERT(read_handle != INVALID_HANDLE || write_handle != INVALID_HANDLE);
AMS_ASSERT(!this->is_initialized);
AMS_ASSERT(read_handle != INVALID_HANDLE || write_handle != INVALID_HANDLE);
this->read_handle = read_handle;
this->manage_read_handle = manage_read_handle;
this->write_handle = write_handle;
@@ -59,30 +59,30 @@ namespace sts::os::impl {
}
Handle InterProcessEvent::DetachReadableHandle() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
const Handle handle = this->read_handle;
STS_ASSERT(handle != INVALID_HANDLE);
AMS_ASSERT(handle != INVALID_HANDLE);
this->read_handle = INVALID_HANDLE;
this->manage_read_handle = false;
return handle;
}
Handle InterProcessEvent::DetachWritableHandle() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
const Handle handle = this->write_handle;
STS_ASSERT(handle != INVALID_HANDLE);
AMS_ASSERT(handle != INVALID_HANDLE);
this->write_handle = INVALID_HANDLE;
this->manage_write_handle = false;
return handle;
}
Handle InterProcessEvent::GetReadableHandle() const {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
return this->read_handle;
}
Handle InterProcessEvent::GetWritableHandle() const {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
return this->write_handle;
}

View File

@@ -17,7 +17,7 @@
#pragma once
#include <stratosphere.hpp>
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfInterProcessEvent;

View File

@@ -16,7 +16,7 @@
#pragma once
#include <stratosphere.hpp>
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableObjectList;
class WaitableManagerImpl;

View File

@@ -21,7 +21,7 @@
#include "os_waitable_holder_of_thread.hpp"
#include "os_waitable_holder_of_message_queue.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
struct WaitableHolderImpl {
union {
@@ -36,7 +36,7 @@ namespace sts::os::impl {
};
#define CHECK_HOLDER(T) \
static_assert(std::is_base_of<::sts::os::impl::WaitableHolderBase, T>::value && std::is_trivially_destructible<T>::value, #T)
static_assert(std::is_base_of<::ams::os::impl::WaitableHolderBase, T>::value && std::is_trivially_destructible<T>::value, #T)
CHECK_HOLDER(WaitableHolderOfHandle);
CHECK_HOLDER(WaitableHolderOfEvent);

View File

@@ -17,7 +17,7 @@
#include "os_waitable_holder_base.hpp"
#include "os_waitable_object_list.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfEvent : public WaitableHolderOfUserObject {
private:

View File

@@ -16,7 +16,7 @@
#pragma once
#include "os_waitable_holder_base.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfHandle : public WaitableHolderOfKernelObject {
private:

View File

@@ -17,7 +17,7 @@
#include "os_waitable_holder_base.hpp"
#include "os_inter_process_event.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfInterProcessEvent : public WaitableHolderOfKernelObject {
private:
@@ -31,7 +31,7 @@ namespace sts::os::impl {
}
virtual Handle GetHandle() const override {
STS_ASSERT(this->event->is_initialized);
AMS_ASSERT(this->event->is_initialized);
return this->event->GetReadableHandle();
}
};

View File

@@ -16,7 +16,7 @@
#pragma once
#include "os_waitable_holder_base.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableHolderOfInterruptEvent : public WaitableHolderOfKernelObject {
private:
@@ -30,7 +30,7 @@ namespace sts::os::impl {
}
virtual Handle GetHandle() const override {
STS_ASSERT(this->event->is_initialized);
AMS_ASSERT(this->event->is_initialized);
return this->event->handle.Get();
}
};

View File

@@ -17,7 +17,7 @@
#include "os_waitable_holder_base.hpp"
#include "os_waitable_object_list.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
template<MessageQueueWaitKind WaitKind>
class WaitableHolderOfMessageQueue : public WaitableHolderOfUserObject {

View File

@@ -16,7 +16,7 @@
#pragma once
#include "os_waitable_holder_base.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
/* Nintendo implements this as a user wait object, operating on Thread state. */
/* Libnx doesn't have an equivalent, so we'll use the thread's handle for kernel semantics. */

View File

@@ -16,7 +16,7 @@
#include "os_waitable_manager_impl.hpp"
#include "os_waitable_object_list.hpp"
namespace sts::os::impl{
namespace ams::os::impl{
WaitableHolderBase *WaitableManagerImpl::WaitAnyImpl(bool infinite, u64 timeout) {
/* Set processing thread handle while in scope. */
@@ -64,7 +64,7 @@ namespace sts::os::impl{
index = WaitTimedOut;
} else {
index = this->WaitSynchronization(object_handles, count, min_timeout);
STS_ASSERT(index != WaitInvalid);
AMS_ASSERT(index != WaitInvalid);
}
switch (index) {
@@ -115,7 +115,7 @@ namespace sts::os::impl{
for (WaitableHolderBase &holder_base : this->waitable_list) {
if (Handle handle = holder_base.GetHandle(); handle != INVALID_HANDLE) {
STS_ASSERT(count < MaximumHandleCount);
AMS_ASSERT(count < MaximumHandleCount);
out_handles[count] = handle;
out_objects[count] = &holder_base;

View File

@@ -16,7 +16,7 @@
#pragma once
#include "os_waitable_holder_base.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableManagerImpl {
public:

View File

@@ -17,7 +17,7 @@
#include "os_waitable_holder_base.hpp"
#include "os_waitable_manager_impl.hpp"
namespace sts::os::impl {
namespace ams::os::impl {
class WaitableObjectList {
public:

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
#include "impl/os_waitable_object_list.hpp"
namespace sts::os {
namespace ams::os {
Event::Event(bool a, bool s) : auto_clear(a), signaled(s) {
new (GetPointer(this->waitable_object_list_storage)) impl::WaitableObjectList();

View File

@@ -16,10 +16,10 @@
#include <stratosphere.hpp>
#include "impl/os_waitable_object_list.hpp"
namespace sts::os {
namespace ams::os {
Result InterruptEvent::Initialize(u32 interrupt_id, bool autoclear) {
STS_ASSERT(!this->is_initialized);
AMS_ASSERT(!this->is_initialized);
this->auto_clear = autoclear;
const auto type = this->auto_clear ? svc::InterruptType_Edge : svc::InterruptType_Level;
@@ -30,7 +30,7 @@ namespace sts::os {
}
void InterruptEvent::Finalize() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
R_ASSERT(svcCloseHandle(this->handle.Move()));
this->auto_clear = true;
this->is_initialized = false;
@@ -46,7 +46,7 @@ namespace sts::os {
}
void InterruptEvent::Wait() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
while (true) {
/* Continuously wait, until success. */
@@ -66,7 +66,7 @@ namespace sts::os {
}
bool InterruptEvent::TryWait() {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
if (this->auto_clear) {
/* Auto-clear. Just try to reset. */
@@ -87,7 +87,7 @@ namespace sts::os {
}
bool InterruptEvent::TimedWait(u64 ns) {
STS_ASSERT(this->is_initialized);
AMS_ASSERT(this->is_initialized);
TimeoutHelper timeout_helper(ns);
while (true) {

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
#include "impl/os_waitable_object_list.hpp"
namespace sts::os {
namespace ams::os {
MessageQueue::MessageQueue(std::unique_ptr<uintptr_t[]> buf, size_t c): buffer(std::move(buf)), capacity(c) {
new (GetPointer(this->waitable_object_list_storage)) impl::WaitableObjectList();
@@ -28,7 +28,7 @@ namespace sts::os {
void MessageQueue::SendInternal(uintptr_t data) {
/* Ensure we don't corrupt the queue, but this should never happen. */
STS_ASSERT(this->count < this->capacity);
AMS_ASSERT(this->count < this->capacity);
/* Write data to tail of queue. */
this->buffer[(this->count++ + this->offset) % this->capacity] = data;
@@ -36,7 +36,7 @@ namespace sts::os {
void MessageQueue::SendNextInternal(uintptr_t data) {
/* Ensure we don't corrupt the queue, but this should never happen. */
STS_ASSERT(this->count < this->capacity);
AMS_ASSERT(this->count < this->capacity);
/* Write data to head of queue. */
this->offset = (this->offset + this->capacity - 1) % this->capacity;
@@ -46,7 +46,7 @@ namespace sts::os {
uintptr_t MessageQueue::ReceiveInternal() {
/* Ensure we don't corrupt the queue, but this should never happen. */
STS_ASSERT(this->count > 0);
AMS_ASSERT(this->count > 0);
uintptr_t data = this->buffer[this->offset];
this->offset = (this->offset + 1) % this->capacity;
@@ -56,7 +56,7 @@ namespace sts::os {
uintptr_t MessageQueue::PeekInternal() {
/* Ensure we don't corrupt the queue, but this should never happen. */
STS_ASSERT(this->count > 0);
AMS_ASSERT(this->count > 0);
return this->buffer[this->offset];
}

View File

@@ -16,7 +16,7 @@
#include <stratosphere.hpp>
#include "impl/os_waitable_holder_impl.hpp"
namespace sts::os {
namespace ams::os {
SystemEvent::SystemEvent(bool inter_process, bool autoclear) : state(SystemEventState::Uninitialized) {
if (inter_process) {
@@ -35,34 +35,34 @@ namespace sts::os {
}
Event &SystemEvent::GetEvent() {
STS_ASSERT(this->state == SystemEventState::Event);
AMS_ASSERT(this->state == SystemEventState::Event);
return GetReference(this->storage_for_event);
}
const Event &SystemEvent::GetEvent() const {
STS_ASSERT(this->state == SystemEventState::Event);
AMS_ASSERT(this->state == SystemEventState::Event);
return GetReference(this->storage_for_event);
}
impl::InterProcessEvent &SystemEvent::GetInterProcessEvent() {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return GetReference(this->storage_for_inter_process_event);
}
const impl::InterProcessEvent &SystemEvent::GetInterProcessEvent() const {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return GetReference(this->storage_for_inter_process_event);
}
Result SystemEvent::InitializeAsEvent(bool autoclear) {
STS_ASSERT(this->state == SystemEventState::Uninitialized);
AMS_ASSERT(this->state == SystemEventState::Uninitialized);
new (GetPointer(this->storage_for_event)) Event(autoclear);
this->state = SystemEventState::Event;
return ResultSuccess();
}
Result SystemEvent::InitializeAsInterProcessEvent(bool autoclear) {
STS_ASSERT(this->state == SystemEventState::Uninitialized);
AMS_ASSERT(this->state == SystemEventState::Uninitialized);
new (GetPointer(this->storage_for_inter_process_event)) impl::InterProcessEvent();
this->state = SystemEventState::InterProcessEvent;
@@ -77,7 +77,7 @@ namespace sts::os {
}
void SystemEvent::AttachHandles(Handle read_handle, bool manage_read_handle, Handle write_handle, bool manage_write_handle, bool autoclear) {
STS_ASSERT(this->state == SystemEventState::Uninitialized);
AMS_ASSERT(this->state == SystemEventState::Uninitialized);
new (GetPointer(this->storage_for_inter_process_event)) impl::InterProcessEvent();
this->state = SystemEventState::InterProcessEvent;
this->GetInterProcessEvent().Initialize(read_handle, manage_read_handle, write_handle, manage_write_handle, autoclear);
@@ -92,22 +92,22 @@ namespace sts::os {
}
Handle SystemEvent::DetachReadableHandle() {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return this->GetInterProcessEvent().DetachReadableHandle();
}
Handle SystemEvent::DetachWritableHandle() {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return this->GetInterProcessEvent().DetachWritableHandle();
}
Handle SystemEvent::GetReadableHandle() const {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return this->GetInterProcessEvent().GetReadableHandle();
}
Handle SystemEvent::GetWritableHandle() const {
STS_ASSERT(this->state == SystemEventState::InterProcessEvent);
AMS_ASSERT(this->state == SystemEventState::InterProcessEvent);
return this->GetInterProcessEvent().GetWritableHandle();
}
@@ -121,7 +121,7 @@ namespace sts::os {
case SystemEventState::InterProcessEvent:
this->GetInterProcessEvent().~InterProcessEvent();
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
this->state = SystemEventState::Uninitialized;
}
@@ -135,7 +135,7 @@ namespace sts::os {
this->GetInterProcessEvent().Signal();
break;
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -148,7 +148,7 @@ namespace sts::os {
this->GetInterProcessEvent().Reset();
break;
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
void SystemEvent::Wait() {
@@ -160,7 +160,7 @@ namespace sts::os {
this->GetInterProcessEvent().Wait();
break;
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -171,7 +171,7 @@ namespace sts::os {
case SystemEventState::InterProcessEvent:
return this->GetInterProcessEvent().TryWait();
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
@@ -182,7 +182,7 @@ namespace sts::os {
case SystemEventState::InterProcessEvent:
return this->GetInterProcessEvent().TimedWait(ns);
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
}
}

View File

@@ -17,11 +17,11 @@
#include "impl/os_waitable_holder_impl.hpp"
#include "impl/os_waitable_manager_impl.hpp"
namespace sts::os {
namespace ams::os {
WaitableHolder::WaitableHolder(Handle handle) {
/* Don't allow invalid handles. */
STS_ASSERT(handle != INVALID_HANDLE);
AMS_ASSERT(handle != INVALID_HANDLE);
/* Initialize appropriate holder. */
new (GetPointer(this->impl_storage)) impl::WaitableHolderOfHandle(handle);
@@ -48,7 +48,7 @@ namespace sts::os {
new (GetPointer(this->impl_storage)) impl::WaitableHolderOfInterProcessEvent(&event->GetInterProcessEvent());
break;
case SystemEventState::Uninitialized:
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
/* Set user-data. */
@@ -80,7 +80,7 @@ namespace sts::os {
case MessageQueueWaitKind::ForNotEmpty:
new (GetPointer(this->impl_storage)) impl::WaitableHolderOfMessageQueueForNotEmpty(message_queue);
break;
STS_UNREACHABLE_DEFAULT_CASE();
AMS_UNREACHABLE_DEFAULT_CASE();
}
/* Set user-data. */
@@ -91,7 +91,7 @@ namespace sts::os {
auto holder_base = reinterpret_cast<impl::WaitableHolderBase *>(GetPointer(this->impl_storage));
/* Don't allow destruction of a linked waitable holder. */
STS_ASSERT(!holder_base->IsLinkedToManager());
AMS_ASSERT(!holder_base->IsLinkedToManager());
holder_base->~WaitableHolderBase();
}
@@ -100,7 +100,7 @@ namespace sts::os {
auto holder_base = reinterpret_cast<impl::WaitableHolderBase *>(GetPointer(this->impl_storage));
/* Don't allow unlinking of an unlinked holder. */
STS_ASSERT(holder_base->IsLinkedToManager());
AMS_ASSERT(holder_base->IsLinkedToManager());
holder_base->GetManager()->UnlinkWaitableHolder(*holder_base);
holder_base->SetManager(nullptr);

View File

@@ -17,7 +17,7 @@
#include "impl/os_waitable_holder_impl.hpp"
#include "impl/os_waitable_manager_impl.hpp"
namespace sts::os {
namespace ams::os {
WaitableManager::WaitableManager() {
/* Initialize storage. */
@@ -28,7 +28,7 @@ namespace sts::os {
auto &impl = GetReference(this->impl_storage);
/* Don't allow destruction of a non-empty waitable holder. */
STS_ASSERT(impl.IsEmpty());
AMS_ASSERT(impl.IsEmpty());
impl.~WaitableManagerImpl();
}
@@ -39,7 +39,7 @@ namespace sts::os {
auto &impl = GetReference(this->impl_storage);
/* Don't allow waiting on empty list. */
STS_ASSERT(!impl.IsEmpty());
AMS_ASSERT(!impl.IsEmpty());
return reinterpret_cast<WaitableHolder *>(impl.WaitAny());
}
@@ -48,7 +48,7 @@ namespace sts::os {
auto &impl = GetReference(this->impl_storage);
/* Don't allow waiting on empty list. */
STS_ASSERT(!impl.IsEmpty());
AMS_ASSERT(!impl.IsEmpty());
return reinterpret_cast<WaitableHolder *>(impl.TryWaitAny());
}
@@ -57,7 +57,7 @@ namespace sts::os {
auto &impl = GetReference(this->impl_storage);
/* Don't allow waiting on empty list. */
STS_ASSERT(!impl.IsEmpty());
AMS_ASSERT(!impl.IsEmpty());
return reinterpret_cast<WaitableHolder *>(impl.TimedWaitAny(timeout));
}
@@ -68,7 +68,7 @@ namespace sts::os {
auto holder_base = reinterpret_cast<impl::WaitableHolderBase *>(GetPointer(holder->impl_storage));
/* Don't allow double-linking a holder. */
STS_ASSERT(!holder_base->IsLinkedToManager());
AMS_ASSERT(!holder_base->IsLinkedToManager());
impl.LinkWaitableHolder(*holder_base);
holder_base->SetManager(&impl);