void RecursiveLock_Lock(RecursiveLock* lock) { u32 tag = (u32)getThreadLocalStorage(); if (lock->thread_tag != tag) { LightLock_Lock(&lock->lock); lock->thread_tag = tag; } lock->counter ++; }
int RecursiveLock_TryLock(RecursiveLock* lock) { u32 tag = (u32)getThreadLocalStorage(); if (lock->thread_tag != tag) { if (LightLock_TryLock(&lock->lock)) return 1; // Failure lock->thread_tag = tag; } lock->counter ++; return 0; // Success }
static void check_tls_thread_entry(bool* keep) { *keep = !((u32)getThreadLocalStorage() & 0xFFF); svcExitThread(); }