| 392 | } |
| 393 | |
| 394 | int LightSemaphore_TryAcquire(LightSemaphore* semaphore, s32 count) |
| 395 | { |
| 396 | s32 old_count; |
| 397 | do |
| 398 | { |
| 399 | old_count = __ldrex(&semaphore->current_count); |
| 400 | if (old_count < count) |
| 401 | { |
| 402 | __clrex(); |
| 403 | return 1; // failure |
| 404 | } |
| 405 | } while (__strex(&semaphore->current_count, old_count - count)); |
| 406 | |
| 407 | __dmb(); |
| 408 | return 0; // success |
| 409 | } |
| 410 | |
| 411 | void LightSemaphore_Release(LightSemaphore* semaphore, s32 count) |
| 412 | { |