9f43707e2fb7e0a8781d3b5bc345c444f9502fa6
[pcsx_rearmed.git] / frontend / 3ds / pthread.h
1
2 #ifndef _3DS_PTHREAD_WRAP__
3 #define _3DS_PTHREAD_WRAP__
4
5 #include <stdlib.h>
6 #include <string.h>
7 #include <stdio.h>
8
9 #include "3ds_utils.h"
10
11 #define CTR_PTHREAD_STACK_SIZE 0x10000
12
13 typedef int32_t pthread_t;
14 typedef int pthread_attr_t;
15
16 static inline int pthread_create(pthread_t *thread,
17       const pthread_attr_t *attr, void *(*start_routine)(void*), void *arg)
18 {
19    thread = threadCreate(start_routine, arg, CTR_PTHREAD_STACK_SIZE, 0x25, -2, FALSE);
20    return 1;
21 }
22
23
24 static inline int pthread_join(pthread_t thread, void **retval)
25 {
26    (void)retval;
27
28    if(threadJoin(thread, INT64_MAX))
29       return -1;
30
31    threadFree(thread);
32
33    return 0;
34 }
35
36
37 static inline void pthread_exit(void *retval)
38 {   
39    (void)retval;
40
41    threadExit(0);
42 }
43
44
45 #endif //_3DS_PTHREAD_WRAP__
46