sm: update to excise unnecessary library code

This commit is contained in:
Michael Scire 2021-05-02 10:33:15 -07:00
parent 7d61cab01c
commit 32f487abfb
7 changed files with 47 additions and 6 deletions

View file

@ -15,6 +15,8 @@
*/
#include <stratosphere.hpp>
extern "C" void NORETURN __real_exit(int rc);
namespace ams {
WEAK_SYMBOL void *Malloc(size_t size) {
@ -37,6 +39,11 @@ namespace ams {
return std::free(ptr);
}
WEAK_SYMBOL void NORETURN Exit(int rc) {
__real_exit(rc);
__builtin_unreachable();
}
}
extern "C" {
@ -46,4 +53,6 @@ extern "C" {
WRAP_ABORT_FUNC(__cxa_pure_virtual)
#undef WRAP_ABORT_FUNC
void NORETURN __wrap_exit(int rc) { ::ams::Exit(rc); __builtin_unreachable(); }
}

View file

@ -15,6 +15,7 @@
*/
#include <stratosphere.hpp>
#include "hos_version_api_private.hpp"
#include "../os/impl/os_rng_manager.hpp"
namespace ams::os {
@ -22,6 +23,15 @@ namespace ams::os {
}
extern "C" {
/* Provide libnx address space allocation shim. */
uintptr_t __libnx_virtmem_rng(void) {
return static_cast<uintptr_t>(::ams::os::impl::GetRngManager().GenerateRandomU64());
}
}
namespace ams::hos {
void InitializeForStratosphere() {

View file

@ -21,12 +21,12 @@ namespace ams::os::impl {
class RngManager {
private:
util::TinyMT mt;
os::Mutex lock;
os::SdkMutex lock;
bool initialized;
private:
void Initialize();
public:
constexpr RngManager() : mt(), lock(false), initialized() { /* ... */ }
constexpr RngManager() : mt(), lock(), initialized() { /* ... */ }
public:
u64 GenerateRandomU64();
};

View file

@ -20,9 +20,9 @@ namespace ams::os {
namespace {
util::TinyMT g_random;
os::Mutex g_random_mutex(false);
bool g_initialized_random;
constinit util::TinyMT g_random;
constinit os::SdkMutex g_random_mutex;
constinit bool g_initialized_random;
template<typename T>
inline T GenerateRandomTImpl(T max) {