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