1 
2 #ifndef __PTHREAD_H__
3 #define __PTHREAD_H__
4 
5 #include <time.h>
6 
7 #define PTHREAD_MUTEX_INITIALIZER	NULL
8 #define PTHREAD_COND_INITIALIZER	NULL
9 
10 typedef struct pthread *pthread_t;
11 typedef struct pthread_attr *pthread_attr_t;
12 typedef struct pthread_barrier *pthread_barrier_t;
13 typedef struct pthread_barrierattr *pthread_barrierattr_t;
14 typedef struct pthread_mutex *pthread_mutex_t;
15 typedef struct pthread_mutexattr *pthread_mutexattr_t;
16 typedef struct pthread_cond *pthread_cond_t;
17 typedef struct pthread_condattr *pthread_condattr_t;
18 
19 pthread_t pthread_self(void);
20 int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
21 		   void *(*start_routine)(void *), void *arg);
22 void pthread_exit(void *value_ptr);
23 int pthread_join(pthread_t thread, void **value_ptr);
24 void pthread_yield(void);
25 
26 /*
27  * Barriers
28  */
29 
30 int pthread_barrier_init(pthread_barrier_t *barrier,
31 			 const pthread_barrierattr_t *attr,
32 			 unsigned count);
33 int pthread_barrier_destroy(pthread_barrier_t *barrier);
34 int pthread_barrier_wait(pthread_barrier_t *barrier);
35 
36 /*
37  * Mutex
38  */
39 
40 int pthread_mutex_init(pthread_mutex_t *mutex,
41 		       const pthread_mutexattr_t *attr);
42 int pthread_mutex_destroy(pthread_mutex_t *mutex);
43 int pthread_mutex_lock(pthread_mutex_t *mutex);
44 int pthread_mutex_trylock(pthread_mutex_t *mutex);
45 int pthread_mutex_unlock(pthread_mutex_t *mutex);
46 
47 /*
48  * Reader/Writer Lock
49  */
50 
51 /*
52  * Condition Variables
53  */
54 
55 int pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *attr);
56 int pthread_cond_destroy(pthread_cond_t *cond);
57 int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
58 int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
59 			   const struct timespec *abstime);
60 int pthread_cond_signal(pthread_cond_t *cond);
61 int pthread_cond_broadcast(pthread_cond_t *cond);
62 
63 #endif /* __PTHREAD_H__ */
64 
65