aboutsummaryrefslogtreecommitdiff
path: root/src/thread_null.c
blob: 6aaefc29dce113022a589e662d5718fa7349c438 (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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
#include <bh/internal/thread.h>

/**
 * \ingroup thread
 * \{
 */

/**
 * Creates the thread object with the given \a task.
 *
 * \warning This function can be implemented either as a macro or as a function.
 *
 * \param task      Pointer to the task object
 *
 * \return On success, returns the pointer to the new queue object.
 * \return On failure, returns a null pointer.
 */
bh_thread_t *bh_thread_new(bh_task_t *task)
{
    (void)task;
    return NULL;
}

/**
 * Initializes the \a thread object with the given \a task.
 *
 * \warning This is an internal function.
 * \warning This function can be implemented either as a macro or as a function.
 *
 * \param thread    Pointer to the thread object
 * \param task      Pointer to the task object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_thread_init(bh_thread_t *thread,
                   bh_task_t *task)
{
    (void)thread;
    (void)task;
    return BH_NO_IMPL;
}

int bh_thread_sleep(unsigned long timeout)
{
    return BH_NO_IMPL;
}

/**
 * Joins the \a thread.
 *
 * If thread was created with bh_thread_new, this function also frees the \a
 * thread object.
 *
 * \param thread    Pointer to the thread object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_thread_join(bh_thread_t *thread)
{
    (void)thread;
    return BH_NO_IMPL;
}

/**
 * Detaches the \a thread.
 *
 * If thread was created with bh_thread_new, this function also frees the \a
 * thread object.
 *
 * \param thread    Pointer to the thread object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_thread_detach(bh_thread_t *thread)
{
    (void)thread;
    return BH_NO_IMPL;
}

/**
 * Initializes the \a mutex object.
 *
 * \warning This is an internal function.
 *
 * \param mutex Pointer to the mutex object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_mutex_init(bh_mutex_t *mutex)
{
    (void)mutex;
    return BH_NO_IMPL;
}

/**
 * Destroyes the \a mutex object.
 *
 * \param mutex Pointer to the mutex object
 *
 * \warning This is an internal function.
 */
void bh_mutex_destroy(bh_mutex_t *mutex)
{
    (void)mutex;
}

/**
 * Locks the \a mutex object.
 *
 * \param mutex Pointer to the mutex object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_mutex_lock(bh_mutex_t *mutex)
{
    (void)mutex;
    return BH_NO_IMPL;
}

/**
 * Tries to lock the \a mutex object.
 *
 * \param mutex Pointer to the mutex object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_mutex_try_lock(bh_mutex_t *mutex)
{
    (void)mutex;
    return BH_NO_IMPL;
}

/**
 * Unlocks the \a mutex object.
 *
 * \param mutex Pointer to the mutex object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_mutex_unlock(bh_mutex_t *mutex)
{
    (void)mutex;
    return BH_NO_IMPL;
}

/**
 * Initilizes the \a semaphore object with specified \a count value.
 *
 * \warning This is an internal function.
 *
 * \param semaphore Pointer to the semaphore object
 * \param count     Initial semaphore value
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 *
 * \note Guranteed maximum \a count value is 32767.
 */
int bh_semaphore_init(bh_semaphore_t *semaphore, int count)
{
    (void)semaphore;
    (void)count;
    return BH_NO_IMPL;
}

/**
 * Destroyes the \a semaphore object.
 *
 * \warning This is an internal function.
 *
 * \param semaphore Pointer to the semaphore object
 */
void bh_semaphore_destroy(bh_semaphore_t *semaphore)
{
    (void)semaphore;
}

/**
 * Posts (increases value of) the \a semaphore.
 *
 * \param semaphore Pointer to the semaphore object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_semaphore_post(bh_semaphore_t *semaphore)
{
    (void)semaphore;
    return BH_NO_IMPL;
}

/**
 * Waits (decreases value of) the \a semaphore.
 *
 * \param semaphore Pointer to the semaphore object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_semaphore_wait(bh_semaphore_t *semaphore)
{
    (void)semaphore;
    return BH_NO_IMPL;
}

/**
 * Waits (decreases value of) the \a semaphore for the specified \a timeout
 * amount of milliseconds.
 *
 * \param semaphore Pointer to the semaphore object
 * \param timeout   Number of milliseconds to wait for
 *
 * \return On success, returns zero.
 * \return On failure or timeout, returns error code.
 */
int bh_semaphore_wait_for(bh_semaphore_t *semaphore,
                          unsigned long timeout)
{
    (void)semaphore;
    return BH_NO_IMPL;
}

/**
 * Tries to waits (decrease value of) the \a semaphore.
 *
 * \param semaphore Pointer to the semaphore object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_semaphore_try_wait(bh_semaphore_t *semaphore)
{
    (void)semaphore;
    return BH_NO_IMPL;
}

/**
 * Initializes the condition variable object \a cond.
 *
 * \warning This is an internal function.
 *
 * \param cond  Pointer to the condition variable
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_cond_init(bh_cond_t *cond)
{
    (void)cond;
    return BH_NO_IMPL;
}

/**
 * Destroyes the condition variable object \a cond.
 *
 * \param cond  Pointer to the condition variable object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 *
 * \warning This is an internal function.
 */
void bh_cond_destroy(bh_cond_t *cond)
{
    (void)cond;
}

/**
 * Waits on the condition variable \a cond with specified \a mutex.
 *
 * \param cond  Pointer to the condition variable object
 * \param mutex Pointer to the mutex object
 *
 * \return On success, returns zero.
 * \return ON failure, returns error code.
 */
int bh_cond_wait(bh_cond_t *cond,
                 bh_mutex_t *mutex)
{
    (void)cond;
    (void)mutex;
    return BH_NO_IMPL;
}

/**
 * Waits on the condition variable \a cond with specified \a mutex for the
 * specified \a timeout amount of milliseconds.
 *
 * \param cond      Pointer to the condition variable object
 * \param mutex     Pointer to the mutex object
 * \param timeout   Number of milliseconds to wait for
 *
 * \return On success, returns zero.
 * \return On failure or timeout, returns error code.
 */
int bh_cond_wait_for(bh_cond_t *cond,
                     bh_mutex_t *mutex,
                     unsigned long timeout)
{
    (void)cond;
    (void)mutex;
    (void)timeout;
    return BH_NO_IMPL;
}

/**
 * Signals (notifies) one waiting thread on the condition variable \a cond.
 *
 * \param cond  Pointer to the condition variable object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_cond_signal(bh_cond_t *cond)
{
    (void)cond;
    return BH_NO_IMPL;
}

/**
 * Signals (notifies) all waiting threads on the condition variable \a cond.
 *
 * \param cond  Pointer to the condition variable object
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_cond_broadcast(bh_cond_t *cond)
{
    (void)cond;
    return BH_NO_IMPL;
}

/**
 * Creates the thread pool object with specified \a size amount of threads.
 *
 * \param size  Number of threads in the thread pool
 *
 * \return On success, returns pointer to the new thread pool object.
 * \return On failure, returns null pointer.
 */
bh_thread_pool_t *bh_thread_pool_new(size_t size)
{
    (void)size;
    return NULL;
}

/**
 * Initilizes the thread \a pool object with specified \a size amount of
 * threads.
 *
 * \warning This is an internal function.
 *
 * \param pool  Pointer to the thread pool object
 * \param size  Number of threads in the thread pool
 *
 * \return On success, returns zero.
 * \return On failure, returns error code.
 */
int bh_thread_pool_init(bh_thread_pool_t *pool,
                        size_t size)
{
    (void)pool;
    (void)size;
    return BH_NO_IMPL;
}

void bh_spinlock_init(bh_spinlock_t *lock)
{
    lock->handle = 0;
}

void bh_spinlock_destroy(bh_spinlock_t *lock)
{
    (void)lock;
}

int bh_spinlock_lock(bh_spinlock_t *lock)
{
    return BH_NO_IMPL;
}

int bh_spinlock_unlock(bh_spinlock_t *lock)
{
    return BH_NO_IMPL;
}

int bh_spinlock_try_lock(bh_spinlock_t *lock)
{
    return BH_NO_IMPL;
}

bh_tls_info_t *bh_tls_info(void)
{
    static bh_tls_info_t info;

    return &info;
}

bh_tls_t *bh_tls_fetch(void)
{
    static bh_tls_t tls;

    return &tls;
}

/**
 * \}
 */