tinysmb devoptab fix - allow fread sizes > 7236
[libogc.git] / libogc / lock_supp.c
blob6a30c37bf0eef7591199d9822218d3f5ce262827
1 #include <_ansi.h>
2 #include <_syslist.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 #include <string.h>
6 #ifndef REENTRANT_SYSCALLS_PROVIDED
7 #include <reent.h>
8 #endif
9 #include <errno.h>
11 #include "asm.h"
12 #include "processor.h"
13 #include "mutex.h"
16 int __libogc_lock_init(int *lock,int recursive)
18 s32 ret;
19 mutex_t retlck = LWP_MUTEX_NULL;
21 if(!lock) return -1;
23 *lock = 0;
24 ret = LWP_MutexInit(&retlck,(recursive?TRUE:FALSE));
25 if(ret==0) *lock = (int)retlck;
27 return ret;
30 int __libogc_lock_close(int *lock)
32 s32 ret;
33 mutex_t plock;
35 if(!lock || *lock==0) return -1;
37 plock = (mutex_t)*lock;
38 ret = LWP_MutexDestroy(plock);
39 if(ret==0) *lock = 0;
41 return ret;
44 int __libogc_lock_acquire(int *lock)
46 mutex_t plock;
48 if(!lock || *lock==0) return -1;
50 plock = (mutex_t)*lock;
51 return LWP_MutexLock(plock);
55 int __libogc_lock_release(int *lock)
57 mutex_t plock;
59 if(!lock || *lock==0) return -1;
61 plock = (mutex_t)*lock;
62 return LWP_MutexUnlock(plock);