blob: ada3a5ffdf0b8bd20ea880c4aefdbb804989ebdd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
#ifndef KIT_MUTEX_H
#define KIT_MUTEX_H
#ifndef KIT_DISABLE_SYSTEM_THREADS
# ifndef _GNU_SOURCE
# define _GNU_SOURCE
# endif
# include "thread_defs.h"
# include <time.h>
# if !defined(_WIN32) || defined(__CYGWIN__)
# include <pthread.h>
# endif
# ifdef __cplusplus
extern "C" {
# endif
# if defined(_WIN32) && !defined(__CYGWIN__)
typedef struct {
void *DebugInfo;
long LockCount;
long RecursionCount;
void *OwningThread;
void *LockSemaphore;
uintptr_t SpinCount;
} mtx_t;
# else
typedef pthread_mutex_t mtx_t;
# endif
enum {
mtx_plain = 0,
mtx_recursive = 1,
mtx_timed = 2,
};
void mtx_destroy(mtx_t *mtx_);
int mtx_init(mtx_t *mtx_, int);
int mtx_lock(mtx_t *mtx_);
int mtx_timedlock(mtx_t *__restrict mtx_,
struct timespec const *__restrict);
int mtx_trylock(mtx_t *mtx_);
int mtx_unlock(mtx_t *mtx_);
# ifdef __cplusplus
}
# endif
#endif
#endif
|