Files
zinnia/include/zinnia/futex.h
T
2026-09-15 22:21:27 +02:00

30 lines
683 B
C

// SPDX-License-Identifier: MIT
#ifndef ZINNIA_FUTEX_H
#define ZINNIA_FUTEX_H
#include <zinnia/status.h>
#include <zinnia/syscall.h>
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
// Blocks the calling thread if *addr == expected.
// Returns immediately if the value at addr has changed.
static inline zn_status_t zn_futex_wait(int32_t* addr, int32_t expected) {
return zn_syscall2(addr, expected, ZN_SYSCALL_FUTEX_WAIT);
}
// Wakes up to `count` threads waiting on the given futex address.
static inline zn_status_t zn_futex_wake(int32_t* addr, int32_t count) {
return zn_syscall2(addr, count, ZN_SYSCALL_FUTEX_WAKE);
}
#ifdef __cplusplus
}
#endif
#endif