| 445 | |
| 446 | |
| 447 | static int pthread_rwlock_tryrdlock(pthread_rwlock_t *l) |
| 448 | { |
| 449 | /* Get the current state of the lock */ |
| 450 | void *state = *(void **) l; |
| 451 | |
| 452 | if (!state) |
| 453 | { |
| 454 | /* Unlocked to locked */ |
| 455 | if (!InterlockedCompareExchangePointer((volatile PVOID *) l, (void *)0x11, NULL)) return 0; |
| 456 | return EBUSY; |
| 457 | } |
| 458 | |
| 459 | /* A single writer exists */ |
| 460 | if (state == (void *) 1) return EBUSY; |
| 461 | |
| 462 | /* Multiple writers exist? */ |
| 463 | if ((uintptr_t) state & 14) return EBUSY; |
| 464 | |
| 465 | if (InterlockedCompareExchangePointer((volatile PVOID *) l, (void *) ((uintptr_t)state + 16), state) == state) return 0; |
| 466 | |
| 467 | return EBUSY; |
| 468 | } |
| 469 | |
| 470 | static int pthread_rwlock_trywrlock(pthread_rwlock_t *l) |
| 471 | { |
no outgoing calls
no test coverage detected