mirror of
https://github.com/odin-lang/Odin.git
synced 2026-02-14 15:23:15 +00:00
UL_COMPARE_AND_WAIT_SHARED is macOS 10.15+
This commit is contained in:
@@ -839,8 +839,16 @@ gb_internal void futex_signal(Futex *f) {
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
// UL_COMPARE_AND_WAIT_SHARED is only available on macOS 10.15+
|
||||
int WAIT_FLAG;
|
||||
if (__builtin_available(macOS 10.15, *)) {
|
||||
WAIT_FLAG = UL_COMPARE_AND_WAIT_SHARED;
|
||||
} else {
|
||||
WAIT_FLAG = UL_COMPARE_AND_WAIT;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
int ret = __ulock_wake(UL_COMPARE_AND_WAIT_SHARED | ULF_NO_ERRNO, f, 0);
|
||||
int ret = __ulock_wake(WAIT_FLAG | ULF_NO_ERRNO, f, 0);
|
||||
if (ret >= 0) {
|
||||
return;
|
||||
}
|
||||
@@ -875,9 +883,17 @@ gb_internal void futex_broadcast(Futex *f) {
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
// UL_COMPARE_AND_WAIT_SHARED is only available on macOS 10.15+
|
||||
int WAIT_FLAG;
|
||||
if (__builtin_available(macOS 10.15, *)) {
|
||||
WAIT_FLAG = UL_COMPARE_AND_WAIT_SHARED;
|
||||
} else {
|
||||
WAIT_FLAG = UL_COMPARE_AND_WAIT;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
enum { ULF_WAKE_ALL = 0x00000100 };
|
||||
int ret = __ulock_wake(UL_COMPARE_AND_WAIT_SHARED | ULF_NO_ERRNO | ULF_WAKE_ALL, f, 0);
|
||||
int ret = __ulock_wake(WAIT_FLAG | ULF_NO_ERRNO | ULF_WAKE_ALL, f, 0);
|
||||
if (ret == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -915,8 +931,16 @@ gb_internal void futex_wait(Futex *f, Footex val) {
|
||||
}
|
||||
} else {
|
||||
#endif
|
||||
// UL_COMPARE_AND_WAIT_SHARED is only available on macOS 10.15+
|
||||
int WAIT_FLAG;
|
||||
if (__builtin_available(macOS 10.15, *)) {
|
||||
WAIT_FLAG = UL_COMPARE_AND_WAIT_SHARED;
|
||||
} else {
|
||||
WAIT_FLAG = UL_COMPARE_AND_WAIT;
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
int ret = __ulock_wait(UL_COMPARE_AND_WAIT_SHARED | ULF_NO_ERRNO, f, val, 0);
|
||||
int ret = __ulock_wait(WAIT_FLAG | ULF_NO_ERRNO, f, val, 0);
|
||||
if (ret >= 0) {
|
||||
if (*f != val) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user