8 #define __NEED_struct_timespec
9 #define __NEED_sigset_t
10 #define __NEED_pthread_t
13 #include <bits/alltypes.h>
17 typedef int pthread_once_t, pthread_key_t, pthread_spinlock_t;
18 typedef int pthread_mutexattr_t, pthread_condattr_t, pthread_barrierattr_t;
23 unsigned __detach : 1;
30 } pthread_rwlockattr_t;
62 #define PTHREAD_CREATE_JOINABLE 0
63 #define PTHREAD_CREATE_DETACHED 1
65 #define PTHREAD_MUTEX_NORMAL 0
66 #define PTHREAD_MUTEX_DEFAULT 0
67 #define PTHREAD_MUTEX_RECURSIVE 1
68 #define PTHREAD_MUTEX_ERRORCHECK 2
70 #define PTHREAD_MUTEX_STALLED 0
71 #define PTHREAD_MUTEX_ROBUST 1
73 #define PTHREAD_PRIO_NONE 0
74 #define PTHREAD_PRIO_INHERIT 1
75 #define PTHREAD_PRIO_PROTECT 2
77 #define PTHREAD_INHERIT_SCHED 0
78 #define PTHREAD_EXPLICIT_SCHED 1
80 #define PTHREAD_SCOPE_SYSTEM 0
81 #define PTHREAD_SCOPE_PROCESS 1
83 #define PTHREAD_PROCESS_PRIVATE 0
84 #define PTHREAD_PROCESS_SHARED 1
87 #define PTHREAD_MUTEX_INITIALIZER {0}
88 #define PTHREAD_RWLOCK_INITIALIZER {0}
89 #define PTHREAD_COND_INITIALIZER {0}
90 #define PTHREAD_ONCE_INIT 0
93 #define PTHREAD_CANCEL_ENABLE 0
94 #define PTHREAD_CANCEL_DISABLE 1
96 #define PTHREAD_CANCEL_DEFERRED 0
97 #define PTHREAD_CANCEL_ASYNCHRONOUS 1
99 #define PTHREAD_CANCELLED ((void *)-1)
102 #define PTHREAD_BARRIER_SERIAL_THREAD (-1)
105 int pthread_create(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *);
106 int pthread_detach(pthread_t);
107 void pthread_exit(void *);
108 int pthread_join(pthread_t, void **);
110 pthread_t pthread_self(void);
111 int pthread_equal(pthread_t, pthread_t);
113 int pthread_setcancelstate(int, int *);
114 int pthread_setcanceltype(int, int *);
115 void pthread_testcancel(void);
116 int pthread_cancel(pthread_t);
118 int pthread_once(pthread_once_t *, void (*)(void));
120 int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *);
121 int pthread_mutex_lock(pthread_mutex_t *);
122 int pthread_mutex_unlock(pthread_mutex_t *);
123 int pthread_mutex_trylock(pthread_mutex_t *);
124 int pthread_mutex_destroy(pthread_mutex_t *);
126 int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *);
127 int pthread_cond_destroy(pthread_cond_t *);
128 int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
129 int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *, const struct timespec *);
130 int pthread_cond_broadcast(pthread_cond_t *);
131 int pthread_cond_signal(pthread_cond_t *);
133 int pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *);
134 int pthread_rwlock_destroy(pthread_rwlock_t *);
135 int pthread_rwlock_rdlock(pthread_rwlock_t *);
136 int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
137 int pthread_rwlock_timedrdlock(pthread_rwlock_t *, const struct timespec *);
138 int pthread_rwlock_wrlock(pthread_rwlock_t *);
139 int pthread_rwlock_trywrlock(pthread_rwlock_t *);
140 int pthread_rwlock_timedwrlock(pthread_rwlock_t *, const struct timespec *);
141 int pthread_rwlock_unlock(pthread_rwlock_t *);
143 int pthread_spin_init(pthread_spinlock_t *, int);
144 int pthread_spin_destroy(pthread_spinlock_t *);
145 int pthread_spin_lock(pthread_spinlock_t *);
146 int pthread_spin_trylock(pthread_spinlock_t *);
147 int pthread_spin_unlock(pthread_spinlock_t *);
149 int pthread_barrier_init(pthread_barrier_t *, const pthread_barrierattr_t *, unsigned);
150 int pthread_barrier_destroy(pthread_barrier_t *);
151 int pthread_barrier_wait(pthread_barrier_t *);
153 int pthread_key_create(pthread_key_t *, void (*)(void *));
154 int pthread_key_delete(pthread_key_t);
155 void *pthread_getspecific(pthread_key_t);
156 int pthread_setspecific(pthread_key_t, const void *);
158 int pthread_attr_init(pthread_attr_t *);
159 int pthread_attr_destroy(pthread_attr_t *);
161 int pthread_attr_getguardsize(pthread_attr_t *, size_t *);
162 int pthread_attr_setguardsize(pthread_attr_t *, size_t);
163 int pthread_attr_getstacksize(pthread_attr_t *, size_t *);
164 int pthread_attr_setstacksize(pthread_attr_t *, size_t);
165 int pthread_attr_getdetachstate(pthread_attr_t *, int *);
166 int pthread_attr_setdetachstate(pthread_attr_t *, int);
167 int pthread_attr_getstack(pthread_attr_t *, void **, size_t *);
168 int pthread_attr_setstack(pthread_attr_t *, void *, size_t);
169 int pthread_attr_getscope(pthread_attr_t *, int *);
170 int pthread_attr_setscope(pthread_attr_t *, int);
171 int pthread_attr_getschedpolicy(pthread_attr_t *, int *);
172 int pthread_attr_setschedpolicy(pthread_attr_t *, int);
173 int pthread_attr_getschedparam(pthread_attr_t *, struct sched_param *);
174 int pthread_attr_setschedparam(pthread_attr_t *, const struct sched_param *);
175 int pthread_attr_getinheritsched(pthread_attr_t *, int *);
176 int pthread_attr_setinheritsched(pthread_attr_t *, int);
178 int pthread_mutexattr_destroy(pthread_mutexattr_t *);
179 int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *, int *);
180 int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *, int *);
181 int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *);
182 int pthread_mutexattr_getrobust(const pthread_mutexattr_t *, int *);
183 int pthread_mutexattr_gettype(const pthread_mutexattr_t *, int *);
184 int pthread_mutexattr_init(pthread_mutexattr_t *);
185 int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
186 int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
187 int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
188 int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int);
189 int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
191 int pthread_barrierattr_destroy(pthread_barrierattr_t *);
192 int pthread_barrierattr_getpshared(const pthread_barrierattr_t *, int *);
193 int pthread_barrierattr_init(pthread_barrierattr_t *);
194 int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int);
196 #include <bits/pthread.h>
198 int __setjmp(void *);
199 void __pthread_register_cancel(struct __ptcb *);
200 void __pthread_unregister_cancel(struct __ptcb *);
201 void __pthread_unwind_next(struct __ptcb *);
203 #define pthread_cleanup_push(f, x) \
204 do { struct __ptcb __cb; void (*__f)(void *) = (f); void *__x = (x); \
205 if (__setjmp(__cb.__jb)) __f(__x), __pthread_unwind_next(&__cb); \
206 __pthread_register_cancel(&__cb); {
208 #define pthread_cleanup_pop(r) ; } \
209 __pthread_unregister_cancel(&__cb); \
210 if (r) __f(__x); } while (0)