WUT  0.1
Wii U Toolchain
mutex.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 #include "threadqueue.h"
4 
11 #ifdef __cplusplus
12 extern "C" {
13 #endif
14 
15 typedef struct OSThread;
16 
17 typedef struct OSCondition OSCondition;
18 typedef struct OSMutex OSMutex;
19 typedef struct OSMutexLink OSMutexLink;
20 
22 {
25 };
26 CHECK_OFFSET(OSMutexLink, 0x00, next);
27 CHECK_OFFSET(OSMutexLink, 0x04, prev);
28 CHECK_SIZE(OSMutexLink, 0x8);
29 
30 #define OS_MUTEX_TAG 0x6D557458u
31 
32 struct OSMutex
33 {
34  // OSMutex::Tag
35  uint32_t tag;
36 
37  // Name set by OSInitMutexEx(mutex, name)
38  const char *name;
39  UNKNOWN(4);
40 
41  // Queue of threads waiting for this mutex to unlock
43 
44  // Current owner of mutex
46 
47  // Current recursion lock count of mutex
48  int32_t count;
49 
50  // Link used inside OSThread's mutex queue
52 };
53 CHECK_OFFSET(OSMutex, 0x00, tag);
54 CHECK_OFFSET(OSMutex, 0x04, name);
55 CHECK_OFFSET(OSMutex, 0x0c, queue);
56 CHECK_OFFSET(OSMutex, 0x1c, owner);
57 CHECK_OFFSET(OSMutex, 0x20, count);
58 CHECK_OFFSET(OSMutex, 0x24, link);
59 CHECK_SIZE(OSMutex, 0x2c);
60 
61 void
62 OSInitMutex(OSMutex *mutex);
63 
64 void
65 OSInitMutexEx(OSMutex *mutex,
66  const char *name);
67 
68 void
69 OSLockMutex(OSMutex *mutex);
70 
71 void
72 OSUnlockMutex(OSMutex *mutex);
73 
74 BOOL
75 OSTryLockMutex(OSMutex *mutex);
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
int32_t count
Definition: mutex.h:48
OSThreadQueue queue
Definition: mutex.h:42
void OSInitMutexEx(OSMutex *mutex, const char *name)
uint32_t tag
Definition: mutex.h:35
void OSUnlockMutex(OSMutex *mutex)
int BOOL
Definition: wut_types.h:4
OSThread * owner
Definition: mutex.h:45
Definition: mutex.h:32
void OSLockMutex(OSMutex *mutex)
void OSInitMutex(OSMutex *mutex)
BOOL OSTryLockMutex(OSMutex *mutex)
const char * name
Definition: mutex.h:38
OSMutexLink link
Definition: mutex.h:51