-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmutex.h
More file actions
46 lines (35 loc) · 1.1 KB
/
mutex.h
File metadata and controls
46 lines (35 loc) · 1.1 KB
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
#pragma once
/**
* \file mutex.h
* \brief Mutex procedures binding file
*
* \author Nikita Maslov
* \date 2018
* \copyright GPU LGPLv3
*/
#include "config.h"
#include "mutex_t.h"
#if defined(CONFIG_SBMALLOC_MUTEX_NONE)
static inline int sbmalloc_mutex_init(sbmalloc_mutex_t *mtx) { return 0; }
static inline int sbmalloc_mutex_destroy(sbmalloc_mutex_t *mtx) { return 0; }
static inline int sbmalloc_mutex_lock(sbmalloc_mutex_t *mtx) { return 0; }
static inline int sbmalloc_mutex_unlock(sbmalloc_mutex_t *mtx) { return 0; }
#elif defined(CONFIG_SBMALLOC_MUTEX_POSIX)
#include <pthread.h>
static inline int sbmalloc_mutex_init(sbmalloc_mutex_t *mtx)
{
return pthread_mutex_init((pthread_mutex_t *) mtx, NULL);
}
static inline int sbmalloc_mutex_destroy(sbmalloc_mutex_t *mtx)
{
return pthread_mutex_destroy((pthread_mutex_t *) mtx);
}
static inline int sbmalloc_mutex_lock(sbmalloc_mutex_t *mtx)
{
return pthread_mutex_lock((pthread_mutex_t *) mtx);
}
static inline int sbmalloc_mutex_unlock(sbmalloc_mutex_t *mtx)
{
return pthread_mutex_unlock((sbmalloc_mutex_t *) mtx);
}
#endif