libc: pthread: implement mutexes

This commit is contained in:
2026-07-19 13:31:22 +01:00
parent 6317060138
commit 810f741442
4 changed files with 57 additions and 1 deletions
@@ -0,0 +1,18 @@
#include <errno.h>
#include <pthread.h>
int pthread_mutex_trylock(pthread_mutex_t *mut)
{
kern_futex_t expected = 0;
if (__atomic_compare_exchange_n(
&mut->__v,
&expected,
1,
0,
__ATOMIC_ACQUIRE,
__ATOMIC_ACQUIRE)) {
return 0;
}
return __set_errno(EBUSY);
}