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 15 // _pthread_thread::flags values 16 #define THREAD_DETACHED 0x01 17 #define THREAD_DEAD 0x02 18 #define THREAD_CANCELED 0x04 19 #define THREAD_CANCEL_ENABLED 0x08 20 #define THREAD_CANCEL_ASYNCHRONOUS 0x10 21 22 23 struct thread_creation_attributes; 24 25 // The public *_t types are only pointers to these structures 26 // This way, we are completely free to change them, which might be 27 // necessary in the future (not only due to the incomplete implementation 28 // at this point). 29 30 typedef struct _pthread_condattr { 31 bool process_shared; 32 } pthread_condattr; 33 34 typedef struct _pthread_mutexattr { 35 int32 type; 36 bool process_shared; 37 } pthread_mutexattr; 38 39 typedef struct _pthread_attr { 40 int32 detach_state; 41 int32 sched_priority; 42 size_t stack_size; 43 } pthread_attr; 44 45 typedef struct _pthread_rwlockattr { 46 uint32_t flags; 47 } pthread_rwlockattr; 48 49 typedef void (*pthread_key_destructor)(void *data); 50 51 struct pthread_key { 52 vint32 sequence; 53 pthread_key_destructor destructor; 54 }; 55 56 struct pthread_key_data { 57 vint32 sequence; 58 void *value; 59 }; 60 61 #define PTHREAD_UNUSED_SEQUENCE 0 62 63 typedef struct _pthread_thread { 64 thread_id id; 65 int32 flags; 66 void *(*entry)(void*); 67 void *entry_argument; 68 void *exit_value; 69 struct pthread_key_data specific[PTHREAD_KEYS_MAX]; 70 struct __pthread_cleanup_handler *cleanup_handlers; 71 } pthread_thread; 72 73 74 #ifdef __cplusplus 75 extern "C" { 76 #endif 77 78 void __pthread_key_call_destructors(pthread_thread *thread); 79 void __pthread_destroy_thread(void); 80 pthread_thread *__allocate_pthread(void* (*entry)(void*), void *data); 81 void __init_pthread(pthread_thread* thread, void* (*entry)(void*), void* data); 82 status_t __pthread_init_creation_attributes( 83 const pthread_attr_t* pthreadAttributes, pthread_t thread, 84 status_t (*entryFunction)(void*, void*), void* argument1, 85 void* argument2, const char* name, 86 struct thread_creation_attributes* attributes); 87 88 #ifdef __cplusplus 89 } 90 #endif 91 92 #endif /* _PTHREAD_PRIVATE_H_ */ 93