mirror of
https://github.com/CraftyBoss/SuperMarioOdysseyOnline.git
synced 2024-11-26 13:13:04 +00:00
31 lines
747 B
C++
31 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
|