hos: change initialization API
This was needed to make stratosphere buildable with debugging on. os:: assertions rely on GetCurrentThread() working, and this requires the global os resource manager to be constructed. However, __appInit executes before global constructors. We now require that hos::InitializeForStratosphere() be called before anything else is done. This initializes the os resource manager, sets the hos version for libnx, and may do more things in the future. TODO: Consider replacing __appInit/__appExit with ams:: namespace functions in general, and wrap them so that we guarantee hos::InitializeForStratosphere is called first, and generally ensure a consistent stratosphere environment.
This commit is contained in:
@@ -19,6 +19,6 @@
|
||||
namespace ams::os::impl {
|
||||
|
||||
/* TODO: C++20 constinit */
|
||||
OsResourceManager ResourceManagerHolder::s_resource_manager = {};
|
||||
TYPED_STORAGE(OsResourceManager) ResourceManagerHolder::s_resource_manager_storage = {};
|
||||
|
||||
}
|
||||
|
||||
@@ -39,12 +39,17 @@ namespace ams::os::impl {
|
||||
|
||||
class ResourceManagerHolder {
|
||||
private:
|
||||
static /* TODO: C++20 constinit */ OsResourceManager s_resource_manager;
|
||||
static TYPED_STORAGE(OsResourceManager) s_resource_manager_storage;
|
||||
private:
|
||||
constexpr ResourceManagerHolder() { /* ... */ }
|
||||
public:
|
||||
static ALWAYS_INLINE void InitializeResourceManagerInstance() {
|
||||
/* Construct the resource manager instance. */
|
||||
new (GetPointer(s_resource_manager_storage)) OsResourceManager;
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE OsResourceManager &GetResourceManagerInstance() {
|
||||
return s_resource_manager;
|
||||
return GetReference(s_resource_manager_storage);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user