pthread.h revision 1.1.2.1 1
2 /* Copyright */
3
4 #ifndef _LIB_PTHREAD_H
5 #define _LIB_PTHREAD_H
6
7 #include "sched.h"
8 #include <sys/time.h> /* For timespec */
9
10 struct pthread_st;
11 struct pthread_attr_st;
12 struct pthread_mutex_st;
13 struct pthread_mutexattr_st;
14 struct pthread_cond_st;
15 struct pthread_condattr_st;
16
17 typedef struct pthread_st *pthread_t;
18 typedef struct pthread_attr_st *pthread_attr_t;
19 typedef struct pthread_mutex_st *pthread_mutex_t;
20 typedef struct pthread_mutexattr_st *pthread_mutexattr_t;
21 typedef struct pthread_cond_st *pthread_cond_t;
22 typedef struct pthread_condattr_st *pthread_condattr_t;
23
24 int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
25 void *(*startfunc)(void *), void *arg);
26 void pthread_exit(void *retval);
27 int pthread_join(pthread_t thread, void **valptr);
28 int pthread_equal(pthread_t t1, pthread_t t2);
29 pthread_t pthread_self(void);
30 int pthread_detach(pthread_t thread);
31
32 int pthread_kill(pthread_t thread, int sig);
33 int pthread_sigmask(int how, const sigset_t *set, sigset_t *oset);
34
35 int pthread_attr_destroy(pthread_attr_t *attr);
36 int pthread_attr_getdetachstate(pthread_attr_t *attr, int *detachstate);
37 int pthread_attr_init(pthread_attr_t *attr);
38 int pthread_attr_setdetachstate(pthread_attr_t *attr, int detachstate);
39 int pthread_attr_setschedparam(pthread_attr_t *attr,
40 const struct sched_param *param);
41 int pthread_attr_getschedparam(pthread_attr_t *attr,
42 struct sched_param *param);
43
44 int pthread_mutex_init(pthread_mutex_t *mutex,
45 const pthread_mutexattr_t *attr);
46 int pthread_mutex_destroy(pthread_mutex_t *mutex);
47 int pthread_mutex_lock(pthread_mutex_t *mutex);
48 int pthread_mutex_trylock(pthread_mutex_t *mutex);
49 int pthread_mutex_unlock(pthread_mutex_t *mutex);
50
51 int pthread_cond_init(pthread_cond_t *cond,
52 const pthread_condattr_t *attr);
53 int pthread_cond_destroy(pthread_cond_t *cond);
54 int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
55 int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
56 const struct timespec *abstime);
57 int pthread_cond_signal(pthread_cond_t *cond);
58 int pthread_cond_broadacst(pthread_cond_t *cond);
59 int pthread_condattr_init(pthread_condattr_t *attr);
60 int pthread_condattr_destroy(pthread_condattr_t *attr);
61 int pthread_condattr_getpshared(const pthread_condattr_t *attr,
62 int *pshared);
63 int pthread_condattr_setpshared(pthread_condattr_t *attr, int pshared);
64
65 #define PTHREAD_MUTEX_INITIALIZER xxxxx
66 #define PTHREAD_COND_INITIALIZER xxxxx
67
68 #define PTHREAD_CREATE_JOINABLE 0
69 #define PTHREAD_CREATE_DETACHED 1
70
71 #define PTHREAD_PROCESS_PRIVATE 0
72 #define PTHREAD_PROCESS_SHARED 1
73
74 #define _POSIX_THREADS
75
76 /* XXX not actually implemented but required to exist */
77 #define PTHREAD_DESTRUCTOR_ITERATIONS 4 /* Min. required */
78 #define PTHREAD_KEYS_MAX 128 /* Min. required */
79 #define PTHREAD_STACK_MIN 4096 /* XXX Pulled out of my butt */
80 #define PTHREAD_THREADS_MAX 64 /* Min. required */
81
82
83 #endif /* _LIB_PTHREAD_H */
84