1 /* 2 * Copyright 2003-2009, Axel Dörfler, axeld@pinc-software.de. 3 * Copyright 2007, Ryan Leavengood, leavengood@gmail.com. 4 * All rights reserved. Distributed under the terms of the MIT License. 5 */ 6 #ifndef _PTHREAD_PRIVATE_H_ 7 #define _PTHREAD_PRIVATE_H_ 8 9 10 #include <pthread.h> 11 12 #include <OS.h> 13 14 // The public *_t types are only pointers to these structures 15 // This way, we are completely free to change them, which might be 16 // necessary in the future (not only due to the incomplete implementation 17 // at this point). 18 19 typedef struct _pthread_condattr { 20 bool process_shared; 21 } pthread_condattr; 22 23 typedef struct _pthread_mutexattr { 24 int32 type; 25 bool process_shared; 26 } pthread_mutexattr; 27 28 typedef struct _pthread_attr { 29 int32 detach_state; 30 int32 sched_priority; 31 size_t stack_size; 32 } pthread_attr; 33 34 typedef struct _pthread_rwlockattr { 35 uint32_t flags; 36 } pthread_rwlockattr; 37 38 typedef void (*pthread_key_destructor)(void *data); 39 40 struct pthread_key { 41 vint32 sequence; 42 pthread_key_destructor destructor; 43 }; 44 45 struct pthread_key_data { 46 vint32 sequence; 47 void *value; 48 }; 49 50 #define PTHREAD_UNUSED_SEQUENCE 0 51 52 typedef struct _pthread_thread { 53 thread_id id; 54 int32 flags; 55 void *(*entry)(void*); 56 void *entry_argument; 57 void *exit_value; 58 int cancel_state; 59 int cancel_type; 60 bool cancelled; 61 struct pthread_key_data specific[PTHREAD_KEYS_MAX]; 62 struct __pthread_cleanup_handler *cleanup_handlers; 63 } pthread_thread; 64 65 66 #ifdef __cplusplus 67 extern "C" { 68 #endif 69 70 void __pthread_key_call_destructors(pthread_thread *thread); 71 void __pthread_destroy_thread(void); 72 pthread_thread *__allocate_pthread(void *data); 73 74 #ifdef __cplusplus 75 } 76 #endif 77 78 #endif /* _PTHREAD_PRIVATE_H_ */ 79