From 7231a21b00028a52d7938131bfeca4d663d09071 Mon Sep 17 00:00:00 2001 From: Prefetch Date: Sat, 22 Jul 2023 19:22:06 +0200 Subject: Add locks, with some minor improvements to threads --- linen.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'linen.h') diff --git a/linen.h b/linen.h index ef625d0..9062111 100644 --- a/linen.h +++ b/linen.h @@ -5,9 +5,28 @@ #error "Linen (libinen.so) only works on x86_64 Linux!" #endif -typedef int* linen_thread_t; +#include + + +typedef struct { + uint32_t futex; + uint32_t magic; +} *linen_thread_t; extern int linen_thread_create(linen_thread_t* handle, void* (*func)(void*), void* arg); extern int linen_thread_finish(linen_thread_t handle, void** retval); + +typedef struct { + uint32_t futex; + uint32_t count; + uint32_t magic; +} linen_lock_t; + +#define LINEN_LOCK_INITIALIZER { 0, 0, 0xCAFEBABE } + +extern int linen_lock_acquire(linen_lock_t* handle); +extern int linen_lock_release(linen_lock_t* handle); + + #endif /* _LINEN_H_ */ -- cgit v1.2.3