MCPcopy Create free account
hub / github.com/devkitPro/libctru / LightLock_TryLock

Function LightLock_TryLock

libctru/source/synchronization.c:85–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83}
84
85int LightLock_TryLock(LightLock* lock)
86{
87 s32 val;
88 do
89 {
90 val = __ldrex(lock);
91 if (val == 0) val = 1; // 0 is an invalid state - treat it as 1 (unlocked)
92 if (val < 0)
93 {
94 __clrex();
95 return 1; // Failure
96 }
97 } while (__strex(lock, -val));
98
99 __dmb();
100 return 0; // Success
101}
102
103void LightLock_Unlock(LightLock* lock)
104{

Callers 2

RecursiveLock_TryLockFunction · 0.85

Calls 4

__ldrexFunction · 0.85
__clrexFunction · 0.85
__strexFunction · 0.85
__dmbFunction · 0.85

Tested by

no test coverage detected