diff --git a/src/3ds/Platform_3DS.c b/src/3ds/Platform_3DS.c index c60a85335..11b341ded 100644 --- a/src/3ds/Platform_3DS.c +++ b/src/3ds/Platform_3DS.c @@ -253,6 +253,10 @@ void Thread_Join(void* handle) { threadFree(thread); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { LightLock* lock = (LightLock*)Mem_Alloc(1, sizeof(LightLock), "mutex"); LightLock_Init(lock); diff --git a/src/Platform_BeOS.cpp b/src/Platform_BeOS.cpp index 77a3bcaf3..256fe0840 100644 --- a/src/Platform_BeOS.cpp +++ b/src/Platform_BeOS.cpp @@ -60,7 +60,14 @@ void Thread_Join(void* handle) { thread_id thread = (thread_id)handle; wait_for_thread(thread, NULL); } +#endif + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ +// NOTE: BeOS only, as haiku uses the more efficient pthreads implementation in Platform_Posix.c +#if defined CC_BUILD_BEOS void* Mutex_Create(const char* name) { sem_id id = create_sem(1, name); return (void*)id; diff --git a/src/Platform_WinCE.c b/src/Platform_WinCE.c index bc7d4bda6..e80fb247c 100644 --- a/src/Platform_WinCE.c +++ b/src/Platform_WinCE.c @@ -389,6 +389,10 @@ void Thread_Join(void* handle) { Thread_Detach(handle); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { CRITICAL_SECTION* ptr = (CRITICAL_SECTION*)Mem_Alloc(1, sizeof(CRITICAL_SECTION), "mutex"); InitializeCriticalSection(ptr); diff --git a/src/Platform_Windows.c b/src/Platform_Windows.c index 604521857..63ce5ac6b 100644 --- a/src/Platform_Windows.c +++ b/src/Platform_Windows.c @@ -452,6 +452,10 @@ void Thread_Join(void* handle) { #endif } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { CRITICAL_SECTION* ptr = (CRITICAL_SECTION*)Mem_Alloc(1, sizeof(CRITICAL_SECTION), "mutex"); InitializeCriticalSection(ptr); diff --git a/src/UWP/Platform_UWP.cpp b/src/UWP/Platform_UWP.cpp index e2f0d390f..c8f15ccbf 100644 --- a/src/UWP/Platform_UWP.cpp +++ b/src/UWP/Platform_UWP.cpp @@ -368,6 +368,10 @@ void Thread_Join(void* handle) { Thread_Detach(handle); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { CRITICAL_SECTION* ptr = (CRITICAL_SECTION*)Mem_Alloc(1, sizeof(CRITICAL_SECTION), "mutex"); InitializeCriticalSection(ptr); diff --git a/src/dreamcast/Platform_Dreamcast.c b/src/dreamcast/Platform_Dreamcast.c index 697df5e71..83689dc84 100644 --- a/src/dreamcast/Platform_Dreamcast.c +++ b/src/dreamcast/Platform_Dreamcast.c @@ -513,6 +513,10 @@ void Thread_Join(void* handle) { thd_join((kthread_t*)handle, NULL); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { mutex_t* ptr = (mutex_t*)Mem_Alloc(1, sizeof(mutex_t), "mutex"); int res = mutex_init(ptr, MUTEX_TYPE_NORMAL); diff --git a/src/gcwii/Platform_GCWii.h b/src/gcwii/Platform_GCWii.h index 63b9137f9..affe969e6 100644 --- a/src/gcwii/Platform_GCWii.h +++ b/src/gcwii/Platform_GCWii.h @@ -1,73 +1,3 @@ -/*########################################################################################################################* -*------------------------------------------------------Logging/Time-------------------------------------------------------* -*#########################################################################################################################*/ -#ifdef HW_RVL -static void LogOverEXI(char* msg, int len) { - u32 cmd = 0x80000000 | (0x800400 << 6); // write flag, UART base address - - // https://hitmen.c02.at/files/yagcd/yagcd/chap10.html - // Try to acquire "MASK ROM"/"IPL" link - // Writing to the IPL is used for debug message logging - if (EXI_Lock(EXI_CHANNEL_0, EXI_DEVICE_1, NULL) == 0) return; - if (EXI_Select(EXI_CHANNEL_0, EXI_DEVICE_1, EXI_SPEED8MHZ) == 0) { - EXI_Unlock(EXI_CHANNEL_0); return; - } - - EXI_Imm( EXI_CHANNEL_0, &cmd, 4, EXI_WRITE, NULL); - EXI_Sync( EXI_CHANNEL_0); - EXI_ImmEx( EXI_CHANNEL_0, msg, len, EXI_WRITE); - EXI_Deselect(EXI_CHANNEL_0); - EXI_Unlock( EXI_CHANNEL_0); -} - -void Platform_Log(const char* msg, int len) { - char tmp[256 + 1]; - len = min(len, 256); - // See EXI_DeviceIPL.cpp in Dolphin, \r is what triggers buffered message to be logged - Mem_Copy(tmp, msg, len); tmp[len] = '\r'; - - LogOverEXI(tmp, len + 1); -} -#else -void Platform_Log(const char* msg, int len) { - SYS_Report("%.*s\n", len, msg); -} -#endif - -TimeMS DateTime_CurrentUTC(void) { - struct timeval cur; - gettimeofday(&cur, NULL); - return (cc_uint64)cur.tv_sec + UNIX_EPOCH_SECONDS; -} - -void DateTime_CurrentLocal(struct cc_datetime* t) { - struct timeval cur; - struct tm loc_time; - gettimeofday(&cur, NULL); - localtime_r(&cur.tv_sec, &loc_time); - - t->year = loc_time.tm_year + 1900; - t->month = loc_time.tm_mon + 1; - t->day = loc_time.tm_mday; - t->hour = loc_time.tm_hour; - t->minute = loc_time.tm_min; - t->second = loc_time.tm_sec; -} - -cc_uint64 Stopwatch_Measure(void) { -#ifdef HW_RVL - return SYS_Time(); -#else - return __SYS_GetSystemTime(); -#endif -} - -cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) { - if (end < beg) return 0; - return ticks_to_microsecs(end - beg); -} - - /*########################################################################################################################* *-------------------------------------------------------Crash handling----------------------------------------------------* *#########################################################################################################################*/ @@ -246,145 +176,6 @@ void Thread_Join(void* handle) { Mem_Free(ptr); } -void* Mutex_Create(const char* name) { - mutex_t* ptr = (mutex_t*)Mem_Alloc(1, sizeof(mutex_t), "mutex"); - int res = LWP_MutexInit(ptr, false); - if (res) Process_Abort2(res, "Creating mutex"); - return ptr; -} - -void Mutex_Free(void* handle) { - mutex_t* mutex = (mutex_t*)handle; - int res = LWP_MutexDestroy(*mutex); - if (res) Process_Abort2(res, "Destroying mutex"); - Mem_Free(handle); -} - -void Mutex_Lock(void* handle) { - mutex_t* mutex = (mutex_t*)handle; - int res = LWP_MutexLock(*mutex); - if (res) Process_Abort2(res, "Locking mutex"); -} - -void Mutex_Unlock(void* handle) { - mutex_t* mutex = (mutex_t*)handle; - int res = LWP_MutexUnlock(*mutex); - if (res) Process_Abort2(res, "Unlocking mutex"); -} - -#ifdef HW_RVL -// should really use a semaphore with max 1.. too bad no 'TimedWait' though -struct WaitData { - cond_t cond; - mutex_t mutex; - int signalled; // For when Waitable_Signal is called before Waitable_Wait -}; - -void* Waitable_Create(const char* name) { - struct WaitData* ptr = (struct WaitData*)Mem_Alloc(1, sizeof(struct WaitData), "waitable"); - int res; - - res = LWP_CondInit(&ptr->cond); - if (res) Process_Abort2(res, "Creating waitable"); - res = LWP_MutexInit(&ptr->mutex, false); - if (res) Process_Abort2(res, "Creating waitable mutex"); - - ptr->signalled = false; - return ptr; -} - -void Waitable_Free(void* handle) { - struct WaitData* ptr = (struct WaitData*)handle; - int res; - - res = LWP_CondDestroy(ptr->cond); - if (res) Process_Abort2(res, "Destroying waitable"); - res = LWP_MutexDestroy(ptr->mutex); - if (res) Process_Abort2(res, "Destroying waitable mutex"); - Mem_Free(handle); -} - -void Waitable_Signal(void* handle) { - struct WaitData* ptr = (struct WaitData*)handle; - int res; - - Mutex_Lock(&ptr->mutex); - ptr->signalled = true; - Mutex_Unlock(&ptr->mutex); - - res = LWP_CondSignal(ptr->cond); - if (res) Process_Abort2(res, "Signalling event"); -} - -void Waitable_Wait(void* handle) { - struct WaitData* ptr = (struct WaitData*)handle; - int res; - - Mutex_Lock(&ptr->mutex); - if (!ptr->signalled) { - res = LWP_CondWait(ptr->cond, ptr->mutex); - if (res) Process_Abort2(res, "Waitable wait"); - } - ptr->signalled = false; - Mutex_Unlock(&ptr->mutex); -} - -void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) { - struct WaitData* ptr = (struct WaitData*)handle; - struct timespec ts; - int res; - - ts.tv_sec = milliseconds / TB_MSPERSEC; - ts.tv_nsec = (milliseconds % TB_MSPERSEC) * TB_NSPERMS; - - Mutex_Lock(&ptr->mutex); - if (!ptr->signalled) { - res = LWP_CondTimedWait(ptr->cond, ptr->mutex, &ts); - if (res && res != ETIMEDOUT) Process_Abort2(res, "Waitable wait for"); - } - ptr->signalled = false; - Mutex_Unlock(&ptr->mutex); -} -#else -void* Waitable_Create(const char* name) { - sem_t* ptr = (sem_t*)Mem_Alloc(1, sizeof(sem_t), "waitable"); - int res = LWP_SemInit(ptr, 0, 1); - if (res) Process_Abort2(res, "Creating waitable"); - return ptr; -} - -void Waitable_Free(void* handle) { - sem_t* ptr = (sem_t*)handle; - int res = LWP_SemDestroy(*ptr); - if (res) Process_Abort2(res, "Destroying waitable"); - Mem_Free(handle); -} - -void Waitable_Signal(void* handle) { - sem_t* ptr = (sem_t*)handle; - int res = LWP_SemPost(*ptr); - if (res && res != EOVERFLOW) Process_Abort2(res, "Signalling event"); -} - -void Waitable_Wait(void* handle) { - sem_t* ptr = (sem_t*)handle; - int res = LWP_SemWait(*ptr); - if (res) Process_Abort2(res, "Event wait"); -} - -void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) { - sem_t* ptr = (sem_t*)handle; - struct timespec ts; - int res; - - ts.tv_sec = milliseconds / TB_MSPERSEC; - ts.tv_nsec = (milliseconds % TB_MSPERSEC) * TB_NSPERMS; - - res = LWP_SemTimedWait(*ptr, &ts); - if (res && res != ETIMEDOUT) Process_Abort2(res, "Event timed wait"); -} -#endif - /*########################################################################################################################* *---------------------------------------------------------Socket----------------------------------------------------------* diff --git a/src/gcwii/Platform_Gamecube.c b/src/gcwii/Platform_Gamecube.c index fc39391d5..b502007b5 100644 --- a/src/gcwii/Platform_Gamecube.c +++ b/src/gcwii/Platform_Gamecube.c @@ -59,6 +59,43 @@ int main(int argc, char** argv) { } +/*########################################################################################################################* +*------------------------------------------------------Logging/Time-------------------------------------------------------* +*#########################################################################################################################*/ +void Platform_Log(const char* msg, int len) { + SYS_Report("%.*s\n", len, msg); +} + +TimeMS DateTime_CurrentUTC(void) { + struct timeval cur; + gettimeofday(&cur, NULL); + return (cc_uint64)cur.tv_sec + UNIX_EPOCH_SECONDS; +} + +void DateTime_CurrentLocal(struct cc_datetime* t) { + struct timeval cur; + struct tm loc_time; + gettimeofday(&cur, NULL); + localtime_r(&cur.tv_sec, &loc_time); + + t->year = loc_time.tm_year + 1900; + t->month = loc_time.tm_mon + 1; + t->day = loc_time.tm_mday; + t->hour = loc_time.tm_hour; + t->minute = loc_time.tm_min; + t->second = loc_time.tm_sec; +} + +cc_uint64 Stopwatch_Measure(void) { + return __SYS_GetSystemTime(); +} + +cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) { + if (end < beg) return 0; + return ticks_to_microsecs(end - beg); +} + + /*########################################################################################################################* *---------------------------------------------------------Socket----------------------------------------------------------* *#########################################################################################################################*/ @@ -133,6 +170,74 @@ static void InitSockets(void) { } +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ +void* Mutex_Create(const char* name) { + mutex_t* ptr = (mutex_t*)Mem_Alloc(1, sizeof(mutex_t), "mutex"); + int res = LWP_MutexInit(ptr, false); + if (res) Process_Abort2(res, "Creating mutex"); + return ptr; +} + +void Mutex_Free(void* handle) { + mutex_t* mutex = (mutex_t*)handle; + int res = LWP_MutexDestroy(*mutex); + if (res) Process_Abort2(res, "Destroying mutex"); + Mem_Free(handle); +} + +void Mutex_Lock(void* handle) { + mutex_t* mutex = (mutex_t*)handle; + int res = LWP_MutexLock(*mutex); + if (res) Process_Abort2(res, "Locking mutex"); +} + +void Mutex_Unlock(void* handle) { + mutex_t* mutex = (mutex_t*)handle; + int res = LWP_MutexUnlock(*mutex); + if (res) Process_Abort2(res, "Unlocking mutex"); +} + +void* Waitable_Create(const char* name) { + sem_t* ptr = (sem_t*)Mem_Alloc(1, sizeof(sem_t), "waitable"); + int res = LWP_SemInit(ptr, 0, 1); + if (res) Process_Abort2(res, "Creating waitable"); + return ptr; +} + +void Waitable_Free(void* handle) { + sem_t* ptr = (sem_t*)handle; + int res = LWP_SemDestroy(*ptr); + if (res) Process_Abort2(res, "Destroying waitable"); + Mem_Free(handle); +} + +void Waitable_Signal(void* handle) { + sem_t* ptr = (sem_t*)handle; + int res = LWP_SemPost(*ptr); + if (res && res != EOVERFLOW) Process_Abort2(res, "Signalling event"); +} + +void Waitable_Wait(void* handle) { + sem_t* ptr = (sem_t*)handle; + int res = LWP_SemWait(*ptr); + if (res) Process_Abort2(res, "Event wait"); +} + +void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) { + sem_t* ptr = (sem_t*)handle; + struct timespec ts; + int res; + + ts.tv_sec = milliseconds / TB_MSPERSEC; + ts.tv_nsec = (milliseconds % TB_MSPERSEC) * TB_NSPERMS; + + res = LWP_SemTimedWait(*ptr, &ts); + if (res && res != ETIMEDOUT) Process_Abort2(res, "Event timed wait"); +} + + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/gcwii/Platform_Wii.c b/src/gcwii/Platform_Wii.c index 91a9d2bf8..a56ce9407 100644 --- a/src/gcwii/Platform_Wii.c +++ b/src/gcwii/Platform_Wii.c @@ -61,6 +61,66 @@ int main(int argc, char** argv) { } +/*########################################################################################################################* +*------------------------------------------------------Logging/Time-------------------------------------------------------* +*#########################################################################################################################*/ +static void LogOverEXI(char* msg, int len) { + u32 cmd = 0x80000000 | (0x800400 << 6); // write flag, UART base address + + // https://hitmen.c02.at/files/yagcd/yagcd/chap10.html + // Try to acquire "MASK ROM"/"IPL" link + // Writing to the IPL is used for debug message logging + if (EXI_Lock(EXI_CHANNEL_0, EXI_DEVICE_1, NULL) == 0) return; + if (EXI_Select(EXI_CHANNEL_0, EXI_DEVICE_1, EXI_SPEED8MHZ) == 0) { + EXI_Unlock(EXI_CHANNEL_0); return; + } + + EXI_Imm( EXI_CHANNEL_0, &cmd, 4, EXI_WRITE, NULL); + EXI_Sync( EXI_CHANNEL_0); + EXI_ImmEx( EXI_CHANNEL_0, msg, len, EXI_WRITE); + EXI_Deselect(EXI_CHANNEL_0); + EXI_Unlock( EXI_CHANNEL_0); +} + +void Platform_Log(const char* msg, int len) { + char tmp[256 + 1]; + len = min(len, 256); + // See EXI_DeviceIPL.cpp in Dolphin, \r is what triggers buffered message to be logged + Mem_Copy(tmp, msg, len); tmp[len] = '\r'; + + LogOverEXI(tmp, len + 1); +} + +TimeMS DateTime_CurrentUTC(void) { + struct timeval cur; + gettimeofday(&cur, NULL); + return (cc_uint64)cur.tv_sec + UNIX_EPOCH_SECONDS; +} + +void DateTime_CurrentLocal(struct cc_datetime* t) { + struct timeval cur; + struct tm loc_time; + gettimeofday(&cur, NULL); + localtime_r(&cur.tv_sec, &loc_time); + + t->year = loc_time.tm_year + 1900; + t->month = loc_time.tm_mon + 1; + t->day = loc_time.tm_mday; + t->hour = loc_time.tm_hour; + t->minute = loc_time.tm_min; + t->second = loc_time.tm_sec; +} + +cc_uint64 Stopwatch_Measure(void) { + return SYS_Time(); +} + +cc_uint64 Stopwatch_ElapsedMicroseconds(cc_uint64 beg, cc_uint64 end) { + if (end < beg) return 0; + return ticks_to_microsecs(end - beg); +} + + /*########################################################################################################################* *---------------------------------------------------------Socket----------------------------------------------------------* *#########################################################################################################################*/ @@ -119,6 +179,109 @@ static void InitSockets(void) { } +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ +void* Mutex_Create(const char* name) { + mutex_t* ptr = (mutex_t*)Mem_Alloc(1, sizeof(mutex_t), "mutex"); + int res = LWP_MutexInit(ptr, false); + if (res) Process_Abort2(res, "Creating mutex"); + return ptr; +} + +void Mutex_Free(void* handle) { + mutex_t* mutex = (mutex_t*)handle; + int res = LWP_MutexDestroy(*mutex); + if (res) Process_Abort2(res, "Destroying mutex"); + Mem_Free(handle); +} + +void Mutex_Lock(void* handle) { + mutex_t* mutex = (mutex_t*)handle; + int res = LWP_MutexLock(*mutex); + if (res) Process_Abort2(res, "Locking mutex"); +} + +void Mutex_Unlock(void* handle) { + mutex_t* mutex = (mutex_t*)handle; + int res = LWP_MutexUnlock(*mutex); + if (res) Process_Abort2(res, "Unlocking mutex"); +} + +// should really use a semaphore with max 1.. too bad no 'TimedWait' though +struct WaitData { + cond_t cond; + mutex_t mutex; + int signalled; // For when Waitable_Signal is called before Waitable_Wait +}; + +void* Waitable_Create(const char* name) { + struct WaitData* ptr = (struct WaitData*)Mem_Alloc(1, sizeof(struct WaitData), "waitable"); + int res; + + res = LWP_CondInit(&ptr->cond); + if (res) Process_Abort2(res, "Creating waitable"); + res = LWP_MutexInit(&ptr->mutex, false); + if (res) Process_Abort2(res, "Creating waitable mutex"); + + ptr->signalled = false; + return ptr; +} + +void Waitable_Free(void* handle) { + struct WaitData* ptr = (struct WaitData*)handle; + int res; + + res = LWP_CondDestroy(ptr->cond); + if (res) Process_Abort2(res, "Destroying waitable"); + res = LWP_MutexDestroy(ptr->mutex); + if (res) Process_Abort2(res, "Destroying waitable mutex"); + Mem_Free(handle); +} + +void Waitable_Signal(void* handle) { + struct WaitData* ptr = (struct WaitData*)handle; + int res; + + Mutex_Lock(&ptr->mutex); + ptr->signalled = true; + Mutex_Unlock(&ptr->mutex); + + res = LWP_CondSignal(ptr->cond); + if (res) Process_Abort2(res, "Signalling event"); +} + +void Waitable_Wait(void* handle) { + struct WaitData* ptr = (struct WaitData*)handle; + int res; + + Mutex_Lock(&ptr->mutex); + if (!ptr->signalled) { + res = LWP_CondWait(ptr->cond, ptr->mutex); + if (res) Process_Abort2(res, "Waitable wait"); + } + ptr->signalled = false; + Mutex_Unlock(&ptr->mutex); +} + +void Waitable_WaitFor(void* handle, cc_uint32 milliseconds) { + struct WaitData* ptr = (struct WaitData*)handle; + struct timespec ts; + int res; + + ts.tv_sec = milliseconds / TB_MSPERSEC; + ts.tv_nsec = (milliseconds % TB_MSPERSEC) * TB_NSPERMS; + + Mutex_Lock(&ptr->mutex); + if (!ptr->signalled) { + res = LWP_CondTimedWait(ptr->cond, ptr->mutex, &ts); + if (res && res != ETIMEDOUT) Process_Abort2(res, "Waitable wait for"); + } + ptr->signalled = false; + Mutex_Unlock(&ptr->mutex); +} + + /*########################################################################################################################* *-------------------------------------------------------Encryption--------------------------------------------------------* *#########################################################################################################################*/ diff --git a/src/nds/Platform_NDS.c b/src/nds/Platform_NDS.c index 8e0d6042e..8486f3663 100644 --- a/src/nds/Platform_NDS.c +++ b/src/nds/Platform_NDS.c @@ -413,6 +413,10 @@ void Thread_Detach(void* handle) { void Thread_Join(void* handle) { } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { return NULL; } diff --git a/src/ps2/Platform_PS2.c b/src/ps2/Platform_PS2.c index 79e72353d..19b2f78ed 100644 --- a/src/ps2/Platform_PS2.c +++ b/src/ps2/Platform_PS2.c @@ -346,6 +346,10 @@ void Thread_Join(void* handle) { } } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { ee_sema_t sema = { 0 }; sema.init_count = 1; diff --git a/src/ps3/Platform_PS3.c b/src/ps3/Platform_PS3.c index ac561f808..a581f7391 100644 --- a/src/ps3/Platform_PS3.c +++ b/src/ps3/Platform_PS3.c @@ -294,6 +294,10 @@ void Thread_Join(void* handle) { Mem_Free(thread); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { sys_mutex_attr_t attr; sysMutexAttrInitialize(attr); diff --git a/src/ps4/Platform_PS4.c b/src/ps4/Platform_PS4.c index c2dbe8558..04b4e22a1 100644 --- a/src/ps4/Platform_PS4.c +++ b/src/ps4/Platform_PS4.c @@ -284,6 +284,10 @@ void Thread_Join(void* handle) { Mem_Free(ptr); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { pthread_mutex_t* ptr = (pthread_mutex_t*)Mem_Alloc(1, sizeof(pthread_mutex_t), "mutex"); int res = pthread_mutex_init(ptr, NULL); diff --git a/src/psp/Platform_PSP.c b/src/psp/Platform_PSP.c index 357ca077a..155a602c5 100644 --- a/src/psp/Platform_PSP.c +++ b/src/psp/Platform_PSP.c @@ -270,6 +270,10 @@ void Thread_Join(void* handle) { sceKernelDeleteThread((int)handle); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { SceLwMutexWorkarea* ptr = (SceLwMutexWorkarea*)Mem_Alloc(1, sizeof(SceLwMutexWorkarea), "mutex"); int res = sceKernelCreateLwMutex(ptr, name, 0, 0, NULL); diff --git a/src/psvita/Platform_PSVita.c b/src/psvita/Platform_PSVita.c index e3856bb99..68b89cc48 100644 --- a/src/psvita/Platform_PSVita.c +++ b/src/psvita/Platform_PSVita.c @@ -250,6 +250,10 @@ void Thread_Join(void* handle) { sceKernelDeleteThread((int)handle); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { SceKernelLwMutexWork* ptr = (SceKernelLwMutexWork*)Mem_Alloc(1, sizeof(SceKernelLwMutexWork), "mutex"); int res = sceKernelCreateLwMutex(ptr, name, 0, 0, NULL); diff --git a/src/symbian/Platform_Symbian.cpp b/src/symbian/Platform_Symbian.cpp index 6525cca96..f23f2fef1 100644 --- a/src/symbian/Platform_Symbian.cpp +++ b/src/symbian/Platform_Symbian.cpp @@ -340,6 +340,10 @@ void Thread_Join(void* handle) { Mem_Free(ptr); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { RMutex* mutex = new RMutex; if (!mutex) Process_Abort("Creating mutex"); diff --git a/src/wiiu/Platform_WiiU.c b/src/wiiu/Platform_WiiU.c index 25af9135f..bdfb75afe 100644 --- a/src/wiiu/Platform_WiiU.c +++ b/src/wiiu/Platform_WiiU.c @@ -284,6 +284,10 @@ void Thread_Join(void* handle) { OSJoinThread((OSThread*)handle, &result); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { OSFastMutex* mutex = (OSFastMutex*)Mem_Alloc(1, sizeof(OSFastMutex), "mutex"); diff --git a/src/xbox/Platform_Xbox.c b/src/xbox/Platform_Xbox.c index fd641e6d2..a38a116a2 100644 --- a/src/xbox/Platform_Xbox.c +++ b/src/xbox/Platform_Xbox.c @@ -284,6 +284,10 @@ void Thread_Join(void* handle) { Thread_Detach(handle); } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { CRITICAL_SECTION* ptr = (CRITICAL_SECTION*)Mem_Alloc(1, sizeof(CRITICAL_SECTION), "mutex"); RtlInitializeCriticalSection(ptr); diff --git a/src/xbox360/Platform_Xbox360.c b/src/xbox360/Platform_Xbox360.c index 7f4ac500e..94f1c4178 100644 --- a/src/xbox360/Platform_Xbox360.c +++ b/src/xbox360/Platform_Xbox360.c @@ -248,6 +248,10 @@ void Thread_Detach(void* handle) {// TODO void Thread_Join(void* handle) {// TODO } + +/*########################################################################################################################* +*-----------------------------------------------------Synchronisation-----------------------------------------------------* +*#########################################################################################################################*/ void* Mutex_Create(const char* name) { return Mem_AllocCleared(1, sizeof(int), "mutex"); }