Usermode - More hackery to get glib compiling
[tpg/acess2.git] / Usermode / Libraries / libpthread.so_src / include_exp / pthread.h
1 /*
2  * Acess2 libpthread
3  * - By John Hodge (thePowersGang)
4  *
5  * pthread.h
6  * - Core POSIX threads header
7  */
8 #ifndef _LIBPTHREAT_PTHREAD_H_
9 #define _LIBPTHREAT_PTHREAD_H_
10
11 // XXX: Hack - libgcc doesn't seem to be auto-detecting the presence of this header
12 #include "sched.h"
13
14 //! \name pthread core
15 //! \{
16 typedef struct pthread_attr_s   pthread_attr_t;
17
18 struct pthread_s
19 {
20         void*   retval;
21         unsigned int    kernel_handle;
22 };
23 typedef struct pthread_s        pthread_t;
24
25 extern int      pthread_create(pthread_t *threadptr, const pthread_attr_t * attrs, void* (*fcn)(void*), void* arg);
26 extern int      pthread_detach(pthread_t thread);
27 extern int      pthread_join(pthread_t thread, void **retvalptr);
28 extern int      pthread_cancel(pthread_t thread);
29 extern int      pthread_equal(pthread_t t1, pthread_t t2);
30 extern pthread_t        pthread_self(void);
31 extern void     pthread_exit(void* retval);
32 //! }
33
34
35 //! \name pthread_once
36 //! \{
37 struct pthread_once_s
38 {
39         int     flag;
40 };
41 #define PTHREAD_ONCE_INIT       ((struct pthread_once_s){.flag=0})
42 typedef struct pthread_once_s   pthread_once_t;
43 extern int pthread_once(pthread_once_t *once_contol, void (*init_routine)(void));
44 //! \}
45
46 //! \name pthread mutexes
47 //! \{
48 #define PTHREAD_MUTEX_NORMAL    0
49 #define PTHREAD_MUTEX_RECURSIVE 1
50 struct pthread_mutexattr_s
51 {
52         int     type;
53 };
54 typedef struct pthread_mutexattr_s      pthread_mutexattr_t;
55 extern int pthread_mutexattr_init(pthread_mutexattr_t *attrs);
56 extern int pthread_mutexattr_settype(pthread_mutexattr_t *attrs, int type);
57 extern int pthread_mutexattr_destroy(pthread_mutexattr_t *attrs);
58
59 struct pthread_mutex_s
60 {
61         void*   futex;
62 };
63 #define PTHREAD_MUTEX_INITIALIZER       ((struct pthread_mutex_s){0})
64 typedef struct pthread_mutex_s  pthread_mutex_t;
65 extern int pthread_mutex_init(pthread_mutex_t * mutex, const pthread_mutexattr_t *attrs);
66 extern int pthread_mutex_lock(pthread_mutex_t *lock);
67 extern int pthread_mutex_trylock(pthread_mutex_t *lock);
68 extern int pthread_mutex_unlock(pthread_mutex_t *lock);
69 extern int pthread_mutex_destroy(pthread_mutex_t *lock);
70 //! \}
71
72 //! \name pthread TLS keys
73 //! \{
74 //typedef struct pthread_key_s  pthread_key_t;
75 typedef unsigned int    pthread_key_t;
76 extern int pthread_key_create(pthread_key_t *keyptr, void (*fcn)(void*));
77 extern int pthread_key_delete(pthread_key_t key);
78 extern int pthread_setspecific(pthread_key_t key, const void* data);
79 extern void* pthread_getspecific(pthread_key_t key);
80 //! \}
81
82 //! \name pthread condvars
83 //! \{
84 typedef struct pthread_cond_s   pthread_cond_t;
85 typedef struct pthread_condattr_s       pthread_condattr_t;
86 extern int pthread_cond_init(pthread_cond_t *condptr, const pthread_condattr_t* attrs);
87 extern int pthread_cond_wait(pthread_cond_t *condptr, pthread_mutex_t *mutex);
88 extern int pthread_cond_timedwait(pthread_cond_t *condptr, pthread_mutex_t *mutex, const struct timespec *timeout);
89 extern int pthread_cond_signal(pthread_cond_t *condptr);
90 extern int pthread_cond_broadcast(pthread_cond_t *condptr);
91 extern int pthread_cond_destroy(pthread_cond_t *condptr);
92 //! \}
93
94 #endif
95

UCC git Repository :: git.ucc.asn.au