diff options
author | Test_User <hax@andrewyu.org> | 2024-06-20 18:29:24 -0400 |
---|---|---|
committer | Test_User <hax@andrewyu.org> | 2024-06-20 18:29:24 -0400 |
commit | ef6f87193ab6628a2366b004a21c5cb21304c663 (patch) | |
tree | 8406b6c90f6f4a65ac19360e4fbc640779b52aa5 /mutex.h | |
parent | 6a858830eb5ab1c8cd78e502471f88333b9bcca5 (diff) | |
download | haxircd-ef6f87193ab6628a2366b004a21c5cb21304c663.tar.gz haxircd-ef6f87193ab6628a2366b004a21c5cb21304c663.zip |
Seperate futex fom atomics
Diffstat (limited to 'mutex.h')
-rw-r--r-- | mutex.h | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -42,11 +42,15 @@ inline int mutex_init(uint32_t *futex) { } inline void mutex_lock(uint32_t *futex) { - if (__sync_fetch_and_or(futex, 0x1) == 0) - return; + do { + if (__sync_fetch_and_or(futex, 0x1) == 0) + return; + + if (__sync_fetch_and_or(futex, 0x3) == 0) + return; - while (__sync_fetch_and_or(futex, 0x3) != 0) syscall(SYS_futex, futex, FUTEX_PRIVATE_FLAG | FUTEX_WAIT, 3, 0, 0, 0); + } while (1); } inline void mutex_unlock(uint32_t *futex) { |