Some "cast to pointer from integer of different size" warnings removed.
[AROS-Contrib.git] / MultiMedia / cdxlplay / SDL_cond_aros.c
blobed6c6d15de37c62f00c742f8021bed535f35f030
1 #include <SDL/SDL.h>
2 #include <exec/exec.h>
3 #include <proto/exec.h>
4 #ifdef __AMIGAOS4__
5 #include <inline4/exec.h>
6 #endif
7 #include "lists.h"
9 typedef struct SDL_cond_node {
10 struct node node;
11 struct Task *task;
12 int32_t signal;
13 } SDL_cond_node;
15 struct SDL_cond {
16 struct list list;
19 SDL_cond *SDL_CreateCond(void) {
20 SDL_cond *cond;
21 cond = malloc(sizeof(*cond));
22 if (cond) {
23 init_list(&cond->list);
25 return cond;
28 void SDL_DestroyCond(SDL_cond *cond) {
29 if (cond) {
30 free(cond);
34 int SDL_CondWait(SDL_cond *cond, SDL_mutex *mut) {
35 SDL_cond_node node;
36 node.task = FindTask(NULL);
37 node.signal = AllocSignal(-1);
38 add_tail(&cond->list, &node.node);
39 SDL_UnlockMutex(mut);
40 Wait(1 << node.signal);
41 FreeSignal(node.signal);
42 SDL_LockMutex(mut);
43 return 0;
46 int SDL_CondSignal(SDL_cond *cond) {
47 SDL_cond_node *node;
48 node = (SDL_cond_node *)rem_head(&cond->list);
49 if (node) {
50 Signal(node->task, 1 << node->signal);
51 return 0;
53 return -1;