| 1585 | } |
| 1586 | |
| 1587 | static __attribute__((__noinline__)) int mutex_unlock(mutex_t *m) |
| 1588 | { |
| 1589 | if (mutex_disabled) |
| 1590 | return 0; |
| 1591 | pid_t *x = mutex_get_ptr(m); |
| 1592 | pid_t self = mutex_gettid(); |
| 1593 | while (!mutex_fast_unlock(self, x)) |
| 1594 | { |
| 1595 | if (syscall(SYS_futex, x, FUTEX_UNLOCK_PI, 0, NULL, NULL, 0) != 0) |
| 1596 | return -1; |
| 1597 | if ((pid_t)(*x & ~FUTEX_WAITERS) != self) |
| 1598 | break; |
| 1599 | } |
| 1600 | return 0; // released |
| 1601 | } |
| 1602 | |
| 1603 | static pid_t gettid(void) |
| 1604 | { |
no test coverage detected