X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=frontend%2F3ds%2Fpthread.h;h=286ea7a1f66232376885b96c1d7b02090d48c4f3;hb=dfcd7153048c2f6d479dfcd328ee2c0e1e0784ed;hp=836f4cb5a74d7b3776c99d1bd5d30cd57572b552;hpb=fc99395c2d7efbbaa0663feed47dc89a54e49506;p=pcsx_rearmed.git diff --git a/frontend/3ds/pthread.h b/frontend/3ds/pthread.h index 836f4cb5..286ea7a1 100644 --- a/frontend/3ds/pthread.h +++ b/frontend/3ds/pthread.h @@ -2,40 +2,21 @@ #ifndef _3DS_PTHREAD_WRAP__ #define _3DS_PTHREAD_WRAP__ -#include "3ds.h" -#include "stdlib.h" -#include "string.h" -#include "stdio.h" +#include +#include +#include +#include "3ds_utils.h" -#define CTR_PTHREAD_STACK_SIZE 0x10000 +#define CTR_PTHREAD_STACK_SIZE (1000000 * 12) -typedef struct -{ - Handle handle; - u32* stack; -}pthread_t; +typedef int32_t pthread_t; typedef int pthread_attr_t; -//#ifndef DEBUG_HOLD -//#include "stdio.h" -//void wait_for_input(void); - -//#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0) -//#endif - static inline int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg) { - -// DEBUG_HOLD(); - - thread->stack = linearMemAlign(CTR_PTHREAD_STACK_SIZE, 8); - - svcCreateThread(&thread->handle, (ThreadFunc)start_routine,arg, - (u32*)((u32)thread->stack + CTR_PTHREAD_STACK_SIZE), - 0x25, 1); - + thread = threadCreate(start_routine, arg, CTR_PTHREAD_STACK_SIZE, 0x25, -2, FALSE); return 1; } @@ -44,11 +25,10 @@ static inline int pthread_join(pthread_t thread, void **retval) { (void)retval; -// DEBUG_HOLD(); - if(svcWaitSynchronization(thread.handle, INT64_MAX)) + if(threadJoin(thread, INT64_MAX)) return -1; - linearFree(thread.stack); + threadFree(thread); return 0; } @@ -58,11 +38,9 @@ static inline void pthread_exit(void *retval) { (void)retval; -// DEBUG_HOLD(); - svcExitThread(); + threadExit(0); } -//#undef DEBUG_HOLD #endif //_3DS_PTHREAD_WRAP__