SuperMarioOdysseyOnline/include/sead/thread/nin/seadThreadLocalStorageNin.hpp
2022-06-16 14:33:18 -07:00

30 lines
747 B
C++

#ifndef SEAD_THREAD_THREAD_LOCAL_STORAGE_H_
#include "thread/seadThreadLocalStorage.h"
#endif
#include "basis/seadRawPrint.h"
namespace sead
{
inline ThreadLocalStorage::ThreadLocalStorage()
{
[[maybe_unused]] auto result = nn::os::AllocateTlsSlot(&mTlsSlot, nullptr);
//SEAD_ASSERT(result.IsSuccess()); // this errors
}
inline ThreadLocalStorage::~ThreadLocalStorage()
{
nn::os::FreeTlsSlot(mTlsSlot);
}
inline void ThreadLocalStorage::setValue(uintptr_t value)
{
static_assert(sizeof(uintptr_t) == sizeof(u64), "uintptr_t and u64 should have the same size");
nn::os::SetTlsValue(mTlsSlot, value);
}
inline uintptr_t ThreadLocalStorage::getValue() const
{
return nn::os::GetTlsValue(mTlsSlot);
}
} // namespace sead