BOOL OSAcquireSpinLock(OSSpinLock *spinlock) { OSTestThreadCancel(); spinAcquireLock(spinlock); return TRUE; }
BOOL OSReleaseSpinLock(OSSpinLock *spinlock) { spinReleaseLock(spinlock); OSTestThreadCancel(); return TRUE; }
void OSSleepTicks(Time ticks) { if (1) { OSTestThreadCancel(); gLog->warn("Ignoring unimplemented OSSleepTicks"); return; } auto thread = OSGetCurrentThread(); OSLockScheduler(); // Create the alarm user data auto data = OSAllocFromSystem<SleepAlarmData>(); data->thread = thread; // Create an alarm to trigger wakeup auto alarm = OSAllocFromSystem<OSAlarm>(); OSCreateAlarm(alarm); OSSetAlarmUserData(alarm, data); OSSetAlarm(alarm, ticks, pSleepAlarmHandler); // Sleep thread OSSleepThreadNoLock(nullptr); OSRescheduleNoLock(); OSFreeToSystem(data); OSFreeToSystem(alarm); OSUnlockScheduler(); }
BOOL OSReleaseSpinLock(OSSpinLock *spinlock) { auto result = spinReleaseLock(spinlock); OSTestThreadCancel(); return result; }
BOOL OSTryAcquireSpinLockWithTimeout(OSSpinLock *spinlock, int64_t timeout) { OSTestThreadCancel(); assert(false); return FALSE; }
BOOL OSTryAcquireSpinLockWithTimeout(OSSpinLock *spinlock, OSTime timeout) { OSTestThreadCancel(); return spinTryLockWithTimeout(spinlock, timeout) ? TRUE : FALSE; }
BOOL OSTryAcquireSpinLock(OSSpinLock *spinlock) { OSTestThreadCancel(); return spinTryLock(spinlock) ? TRUE : FALSE; }