blob: c0d6ccad91169e3a57c2ad9015dbf8b1cd9943b9 (
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
#ifndef BH_THREAD_H
#define BH_THREAD_H
#include "Common.h"
#define BH_MAX_TSS 128
typedef struct BH_Lock BH_Lock;
typedef struct BH_Thread BH_Thread;
typedef struct BH_Mutex BH_Mutex;
typedef struct BH_Semaphore BH_Semaphore;
typedef struct BH_Condition BH_Condition;
typedef int (*BH_ThreadCallback)(void *);
BH_Thread *BH_ThreadNew(size_t stack,
BH_ThreadCallback callback,
void *data);
int BH_ThreadJoin(BH_Thread *thread);
int BH_ThreadDetach(BH_Thread *thread);
BH_Mutex *BH_MutexNew(void);
void BH_MutexFree(BH_Mutex *mutex);
int BH_MutexLock(BH_Mutex *mutex);
int BH_MutexUnlock(BH_Mutex *mutex);
int BH_MutexLockTry(BH_Mutex *mutex);
BH_Semaphore *BH_SemaphoreNew(int value);
void BH_SemaphoreFree(BH_Semaphore *semaphore);
int BH_SemaphorePost(BH_Semaphore *semaphore);
int BH_SemaphoreWait(BH_Semaphore *semaphore);
int BH_SemaphoreWaitTry(BH_Semaphore *semaphore);
int BH_SemaphoreWaitFor(BH_Semaphore *semaphore,
uint32_t timeout);
BH_Condition *BH_ConditionNew(void);
void BH_ConditionFree(BH_Condition *condition);
int BH_ConditionWait(BH_Condition *condition,
BH_Mutex *mutex);
int BH_ConditionWaitFor(BH_Condition *condition,
BH_Mutex *mutex,
uint32_t timeout);
int BH_ConditionSignal(BH_Condition *condition);
int BH_ConditionBroadcast(BH_Condition *condition);
void BH_SpinlockLock(int *lock);
int BH_SpinlockLockTry(int *lock);
void BH_SpinlockUnlock(int *lock);
int BH_TssCreate(BH_GenericCallback callback);
void *BH_TssRead(int index);
void BH_TssWrite(int index,
void *value);
#endif /* BH_THREAD_H */
|