blob: 13c9ce6c5a8b9d636ede888028a28031eb34bd14 (
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
|
/*
abstraction for threads
Copyright (C) 2000 Martin Vogt
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Library General Public License as published by
the Free Software Foundation.
For more information look at the file COPYRIGHT in this package
*/
#include "abs_thread.h"
// START SDL
#ifdef SDL_WRAPPER
int abs_thread_cond_init(abs_thread_cond_t* cond) {
*cond=SDL_CreateCond();
return (*cond != NULL);
}
int abs_thread_cond_destroy(abs_thread_cond_t *cond) {
SDL_DestroyCond(*cond);
return true;
}
int abs_thread_cond_signal(abs_thread_cond_t* cond) {
return SDL_CondSignal(*cond);
}
int abs_thread_cond_wait(abs_thread_cond_t* cond,
abs_thread_mutex_t* mutex) {
SDL_CondWait(*cond,*mutex);
return true;
}
// CREATE / JOIN THREAD
int abs_thread_create(abs_thread_t* thread,
void * (*start_routine)(void *), void * arg) {
int (*func)(void *);
func=(int (*)(void *))start_routine;
*thread=SDL_CreateThread(func,arg);
return (*thread != NULL);
}
int abs_thread_join(abs_thread_t th,
void **thread_return) {
SDL_WaitThread(th,(int*)*thread_return);
return true;
}
// MUTEX FUNCTIONS
int abs_thread_mutex_lock(abs_thread_mutex_t *mutex) {
return SDL_LockMutex(*mutex);
}
int abs_thread_mutex_unlock(abs_thread_mutex_t *mutex) {
return SDL_UnlockMutex(*mutex);
}
int abs_thread_mutex_init(abs_thread_mutex_t *mutex) {
*mutex=SDL_CreateMutex();
return true;
}
int abs_thread_mutex_destroy(abs_thread_mutex_t *mutex) {
SDL_DestroyMutex(*mutex);
return true;
}
#endif
|