2 #ifndef _3DS_PTHREAD_WRAP__
3 #define _3DS_PTHREAD_WRAP__
11 #define CTR_PTHREAD_STACK_SIZE 0x10000
18 typedef int pthread_attr_t;
22 //void wait_for_input(void);
24 //#define DEBUG_HOLD() do{printf("%s@%s:%d.\n",__FUNCTION__, __FILE__, __LINE__);fflush(stdout);wait_for_input();}while(0)
27 static inline int pthread_create(pthread_t *thread,
28 const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
33 thread->stack = linearMemAlign(CTR_PTHREAD_STACK_SIZE, 8);
35 svcCreateThread(&thread->handle, (ThreadFunc)start_routine,arg,
36 (u32*)((u32)thread->stack + CTR_PTHREAD_STACK_SIZE),
43 static inline int pthread_join(pthread_t thread, void **retval)
48 if(svcWaitSynchronization(thread.handle, INT64_MAX))
51 linearFree(thread.stack);
57 static inline void pthread_exit(void *retval)
67 #endif //_3DS_PTHREAD_WRAP__