RetroArch
lwp_mutex.h
Go to the documentation of this file.
1 #ifndef __LWP_MUTEX_H__
2 #define __LWP_MUTEX_H__
3 
4 #include <gctypes.h>
5 #include <lwp_threadq.h>
6 
7 #define LWP_MUTEX_LOCKED 0
8 #define LWP_MUTEX_UNLOCKED 1
9 
10 #define LWP_MUTEX_NEST_ACQUIRE 0
11 #define LWP_MUTEX_NEST_ERROR 1
12 #define LWP_MUTEX_NEST_BLOCK 2
13 
14 #define LWP_MUTEX_FIFO 0
15 #define LWP_MUTEX_PRIORITY 1
16 #define LWP_MUTEX_INHERITPRIO 2
17 #define LWP_MUTEX_PRIORITYCEIL 3
18 
19 #define LWP_MUTEX_SUCCESSFUL 0
20 #define LWP_MUTEX_UNSATISFIED_NOWAIT 1
21 #define LWP_MUTEX_NEST_NOTALLOWED 2
22 #define LWP_MUTEX_NOTOWNER 3
23 #define LWP_MUTEX_DELETED 4
24 #define LWP_MUTEX_TIMEOUT 5
25 #define LWP_MUTEX_CEILINGVIOL 6
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 typedef struct _lwpmutexattr {
36 
37 typedef struct _lwpmutex {
42 } lwp_mutex;
43 
47 void __lwp_mutex_flush(lwp_mutex *mutex,u32 status);
48 
49 static __inline__ u32 __lwp_mutex_seize_irq_trylock(lwp_mutex *mutex,u32 *isr_level);
50 
51 #define __lwp_mutex_seize(_mutex_t,_id,_wait,_timeout,_level) \
52  do { \
53  if(__lwp_mutex_seize_irq_trylock(_mutex_t,&_level)) { \
54  if(!_wait) { \
55  _CPU_ISR_Restore(_level); \
56  _thr_executing->wait.ret_code = LWP_MUTEX_UNSATISFIED_NOWAIT; \
57  } else { \
58  __lwp_threadqueue_csenter(&(_mutex_t)->wait_queue); \
59  _thr_executing->wait.queue = &(_mutex_t)->wait_queue; \
60  _thr_executing->wait.id = _id; \
61  __lwp_thread_dispatchdisable(); \
62  _CPU_ISR_Restore(_level); \
63  __lwp_mutex_seize_irq_blocking(_mutex_t,(u64)_timeout); \
64  } \
65  } \
66  } while(0)
67 
68 #ifdef LIBOGC_INTERNAL
69 #include <libogc/lwp_mutex.inl>
70 #endif
71 
72 #ifdef __cplusplus
73  }
74 #endif
75 
76 #endif
u32 nest_behavior
Definition: lwp_mutex.h:33
GLbitfield GLuint64 timeout
Definition: glext.h:7831
void __lwp_mutex_flush(lwp_mutex *mutex, u32 status)
Definition: lwp_mutex.c:92
Definition: lwp_mutex.h:31
Data type definitions.
Definition: lwp_tqdata.h:23
lwp_cntrl * holder
Definition: lwp_mutex.h:41
u8 prioceil
Definition: lwp_mutex.h:34
u32 blocked_cnt
Definition: lwp_mutex.h:40
static __inline__ u32 __lwp_mutex_seize_irq_trylock(lwp_mutex *mutex, u32 *isr_level)
static sys_sem mutex
Definition: memp.c:120
u32 __lwp_mutex_surrender(lwp_mutex *mutex)
Definition: lwp_mutex.c:23
Definition: lwp_threads.h:36
u8 onlyownerrelease
Definition: lwp_mutex.h:34
lwp_thrqueue wait_queue
Definition: lwp_mutex.h:38
void __lwp_mutex_initialize(lwp_mutex *mutex, lwp_mutex_attr *attrs, u32 init_lock)
Definition: lwp_mutex.c:4
u32 mode
Definition: lwp_mutex.h:32
u32 lock
Definition: lwp_mutex.h:40
u32 nest_cnt
Definition: lwp_mutex.h:40
lwp_mutex_attr atrrs
Definition: lwp_mutex.h:39
uint64_t u64
64bit unsigned integer
Definition: gctypes.h:20
uint8_t u8
8bit unsigned integer
Definition: gctypes.h:17
uint32_t u32
32bit unsigned integer
Definition: gctypes.h:19
struct _lwpmutexattr lwp_mutex_attr
struct _lwpmutex lwp_mutex
void __lwp_mutex_seize_irq_blocking(lwp_mutex *mutex, u64 timeout)
Definition: lwp_mutex.c:70
Definition: lwp_mutex.h:37