diff --git a/gx/gx_video.c b/gx/gx_video.c index 128db0e35a..95d9e6c97b 100644 --- a/gx/gx_video.c +++ b/gx/gx_video.c @@ -34,6 +34,7 @@ #include "ppc_asm.h" #include "gx_video_inl.h" +#include "sdk_defines.h" #define SYSMEM1_SIZE 0x01800000 @@ -41,7 +42,7 @@ void *g_framebuf[2]; unsigned g_current_framebuf; bool g_vsync; -lwpq_t g_video_cond; +OSCond g_video_cond; volatile bool g_draw_done; uint32_t g_orientation; @@ -96,7 +97,7 @@ static void retrace_callback(u32 retrace_count) { (void)retrace_count; g_draw_done = true; - LWP_ThreadSignal(g_video_cond); + OSSignalCond(g_video_cond); } #ifdef HAVE_OVERLAY @@ -341,7 +342,7 @@ static void setup_video_mode(void *data) g_current_framebuf = 0; g_draw_done = true; g_orientation = ORIENTATION_NORMAL; - LWP_InitQueue(&g_video_cond); + OSInitThreadQueue(&g_video_cond); VIDEO_GetPreferredMode(&gx_mode); gx_set_video_mode(data, 0, 0); @@ -904,9 +905,7 @@ static bool gx_frame(void *data, const void *frame, } while (((g_vsync || gx->rgui_texture_enable)) && !g_draw_done) - { - LWP_ThreadSleep(g_video_cond); - } + OSSleepThread(g_video_cond); width = min(g_tex.width, width); height = min(g_tex.height, height); diff --git a/gx/sdk_defines.h b/gx/sdk_defines.h index 1dab8451d0..3e1ce73dff 100644 --- a/gx/sdk_defines.h +++ b/gx/sdk_defines.h @@ -9,12 +9,17 @@ #define OSThreadQueue lwpq_t #define OSInitMutex(mutex) LWP_MutexInit(mutex, 0) +#define OSLockMutex(mutex) LWP_MutexLock(mutex) +#define OSUnlockMutex(mutex) LWP_MutexUnlock(mutex) +#define OSTryLockMutex(mutex) LWP_MutexTryLock(mutex) #define OSInitCond(cond) LWP_CondInit(cond) #define OSSignalCond(cond) LWP_ThreadSignal(cond) +#define OSWaitCond(cond, mutex) LWP_CondWait(cond, mutex) #define OSInitThreadQueue(queue) LWP_InitQueue(queue) #define OSSleepThread(queue) LWP_ThreadSleep(queue) +#define OSJoinThread(thread, val) LWP_JoinThread(thread, val) #define OSCreateThread(thread, func, intarg, ptrarg, stackbase, stacksize, priority, attrs) LWP_CreateThread(thread, func, ptrarg, stackbase, stacksize, priority) #endif diff --git a/thread/gx_pthread.h b/thread/gx_pthread.h index 113cfa0c25..7218cde470 100644 --- a/thread/gx_pthread.h +++ b/thread/gx_pthread.h @@ -20,10 +20,11 @@ #include #include #include +#include "../gx/sdk_defines.h" #define STACKSIZE (8 * 1024) -typedef lwp_t pthread_t; +typedef OSThread pthread_t; typedef mutex_t pthread_mutex_t; typedef void* pthread_mutexattr_t; typedef int pthread_attr_t; @@ -33,12 +34,12 @@ typedef cond_t pthread_condattr_t; static inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) { *thread = 0; - return LWP_CreateThread(thread, start_routine, arg, 0, STACKSIZE, 64); + return OSCreateThread(thread, start_routine, 0 /* unused */, arg, 0, STACKSIZE, 64, 0 /* unused */); } static inline int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr) { - return LWP_MutexInit(mutex, 0); + return OSInitMutex(mutex); } static inline int pthread_mutex_destroy(pthread_mutex_t *mutex) @@ -48,12 +49,12 @@ static inline int pthread_mutex_destroy(pthread_mutex_t *mutex) static inline int pthread_mutex_lock(pthread_mutex_t *mutex) { - return LWP_MutexLock(*mutex); + return OSLockMutex(*mutex); } static inline int pthread_mutex_unlock(pthread_mutex_t *mutex) { - return LWP_MutexUnlock(*mutex); + return OSUnlockMutex(*mutex); } static inline void pthread_exit(void *retval) @@ -71,17 +72,17 @@ static inline int pthread_detach(pthread_t thread) static inline int pthread_join(pthread_t thread, void **retval) { - return LWP_JoinThread(thread, retval); + return OSJoinThread(thread, retval); } static inline int pthread_mutex_trylock(pthread_mutex_t *mutex) { - return LWP_MutexTryLock(*mutex); + return OSTryLockMutex(*mutex); } static inline int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) { - return LWP_CondWait(*cond, *mutex); + return OSWaitCond(*cond, *mutex); } static inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime) @@ -91,7 +92,7 @@ static inline int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t * static inline int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr) { - return LWP_CondInit(cond); + return OSInitCond(cond); } static inline int pthread_cond_signal(pthread_cond_t *cond)