23 #ifndef _CTR_PTHREAD_WRAP_CTR_ 24 #define _CTR_PTHREAD_WRAP_CTR_ 26 #include <3ds/thread.h> 27 #include <3ds/synchronization.h> 33 #define STACKSIZE (4 * 1024) 45 static void *(*start_routine_jump)(
void*);
51 start_routine_jump_safe(
data);
55 const pthread_attr_t *attr,
void *(*start_routine)(
void*),
void *arg)
58 Thread new_ctr_thread;
69 svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
80 *thread = new_ctr_thread;
92 LightLock_Init(
mutex);
104 return LightLock_TryLock(
mutex);
109 LightLock_Unlock(
mutex);
130 return threadJoin(thread, U64_MAX);
135 return LightLock_TryLock(
mutex);
141 LightEvent_Wait(
cond);
150 struct timespec now = {0};
154 gettimeofday(&tm,
NULL);
156 now.tv_nsec = tm.
tv_usec * 1000;
157 if (LightEvent_TryWait(
cond) != 0 || now.tv_sec > abstime->tv_sec || (now.tv_sec == abstime->tv_sec && now.tv_nsec > abstime->tv_nsec))
167 LightEvent_Init(
cond, RESET_ONESHOT);
173 LightEvent_Signal(
cond);
179 LightEvent_Signal(
cond);
191 if (threadGetHandle(t1) == threadGetHandle(t2))
Thread pthread_t
Definition: ctr_pthread.h:35
static INLINE int pthread_detach(pthread_t thread)
Definition: ctr_pthread.h:120
static INLINE int pthread_equal(pthread_t t1, pthread_t t2)
Definition: ctr_pthread.h:189
int32_t s32
32bit signed integer
Definition: gctypes.h:24
#define INLINE
Definition: retro_inline.h:35
static INLINE int pthread_mutex_init(pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
Definition: ctr_pthread.h:89
#define STACKSIZE
Definition: ctr_pthread.h:33
static INLINE int pthread_cond_signal(pthread_cond_t *cond)
Definition: ctr_pthread.h:171
static int cond(LexState *ls)
Definition: lparser.c:1177
static LightLock safe_double_thread_launch
Definition: ctr_pthread.h:44
#define EAGAIN
Definition: need_errno.h:42
typedef void(__stdcall *PFN_DESTRUCTION_CALLBACK)(void *pData)
int pthread_condattr_t
Definition: ctr_pthread.h:40
static sys_sem mutex
Definition: memp.c:120
static INLINE int pthread_mutex_trylock(pthread_mutex_t *mutex)
Definition: ctr_pthread.h:133
static INLINE int pthread_mutex_unlock(pthread_mutex_t *mutex)
Definition: ctr_pthread.h:107
static INLINE int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
Definition: ctr_pthread.h:145
static bool mutex_inited
Definition: ctr_pthread.h:43
#define NULL
Pointer to 0.
Definition: gctypes.h:65
Definition: implement.h:146
static void ctr_thread_launcher(void *data)
Definition: ctr_pthread.h:47
Definition: psp_pthread.h:45
Definition: sockets.h:217
static INLINE int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
Definition: ctr_pthread.h:138
void * pthread_t
Definition: pthread.h:398
static INLINE int pthread_mutex_destroy(pthread_mutex_t *mutex)
Definition: ctr_pthread.h:96
static INLINE void pthread_exit(void *retval)
Definition: ctr_pthread.h:113
static INLINE pthread_t pthread_self(void)
Definition: ctr_pthread.h:84
static INLINE int pthread_mutex_lock(pthread_mutex_t *mutex)
Definition: ctr_pthread.h:102
static INLINE int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr)
Definition: ctr_pthread.h:164
Definition: implement.h:163
static INLINE int pthread_cond_destroy(pthread_cond_t *cond)
Definition: ctr_pthread.h:183
Definition: implement.h:116
static INLINE int pthread_cond_broadcast(pthread_cond_t *cond)
Definition: ctr_pthread.h:177
static INLINE Thread threadGetCurrent(void)
Definition: switch_pthread.h:61
int pthread_attr_t
Definition: ctr_pthread.h:38
void * pthread_mutexattr_t
Definition: ctr_pthread.h:37
long tv_usec
Definition: sockets.h:219
Definition: implement.h:251
LightLock pthread_mutex_t
Definition: ctr_pthread.h:36
LightEvent pthread_cond_t
Definition: ctr_pthread.h:39
long tv_sec
Definition: sockets.h:218
static INLINE int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
Definition: ctr_pthread.h:54
static void *(* start_routine_jump)(void *)
Definition: ctr_pthread.h:45
static INLINE int pthread_join(pthread_t thread, void **retval)
Definition: ctr_pthread.h:127