PatchworkOS
Loading...
Searching...
No Matches
mtx_init.c
Go to the documentation of this file.
1#include <stdatomic.h>
2#include <stdbool.h>
3#include <stdio.h>
4#include <sys/proc.h>
5#include <threads.h>
6
9
10int mtx_init(mtx_t* mutex, int type)
11{
12 (void)type; // We don't care about the type, we just implement all types the same way as the C specifcation says
13 // that, for example, if a non-recursive mutex is locked recursively, the behavior is undefined so we
14 // just say that it works.
15
17 mutex->owner = ERR;
18 mutex->depth = 0;
19
20 return thrd_success;
21}
#define ERR
Integer error value.
Definition ERR.h:17
static mtx_t mutex
Definition heap.c:35
int mtx_init(mtx_t *mutex, int type)
Definition mtx_init.c:10
#define atomic_init(obj, value)
Definition stdatomic.h:75
tid_t owner
Definition threads.h:54
uint64_t depth
Definition threads.h:55
atomic_uint64_t state
Definition threads.h:53
#define _MTX_UNLOCKED
Definition threads.h:47
@ thrd_success
Definition threads.h:74