1 | // |
---|
2 | // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo |
---|
3 | // |
---|
4 | // The contents of this file are covered under the licence agreement in the |
---|
5 | // file "LICENCE" distributed with Cforall. |
---|
6 | // |
---|
7 | // pthread.cfa -- |
---|
8 | // |
---|
9 | // Author : Zhenyan Zhu |
---|
10 | // Created On : Sat Aug 6 16:29:18 2022 |
---|
11 | // Last Modified By : Peter A. Buhr |
---|
12 | // Last Modified On : Mon Sep 4 15:37:51 2023 |
---|
13 | // Update Count : 1 |
---|
14 | // |
---|
15 | |
---|
16 | #define __cforall_thread__ |
---|
17 | |
---|
18 | #include <signal.h> |
---|
19 | #include <pthread.h> |
---|
20 | #include <errno.h> |
---|
21 | #include "locks.hfa" |
---|
22 | |
---|
23 | #define check_nonnull(x) asm("": "+rm"(x)); if( x == 0p ) return EINVAL; |
---|
24 | |
---|
25 | /* pthread key, pthread once inner routine mutual exclusion */ |
---|
26 | static simple_owner_lock once_lock,key_lock,magic_mutex_check, concurrency_lock; |
---|
27 | |
---|
28 | //######################### Local Storage Helpers ######################### |
---|
29 | |
---|
30 | enum { PTHREAD_KEYS_MAX = 1024 }; |
---|
31 | |
---|
32 | struct pthread_values{ |
---|
33 | inline dlink(pthread_values); |
---|
34 | void * value; |
---|
35 | bool in_use; |
---|
36 | }; |
---|
37 | P9_EMBEDDED( pthread_values, dlink(pthread_values) ) |
---|
38 | |
---|
39 | struct pthread_keys { |
---|
40 | bool in_use; |
---|
41 | void (* destructor)( void * ); |
---|
42 | dlist( pthread_values ) threads; |
---|
43 | }; |
---|
44 | |
---|
45 | static void ?{}(pthread_keys& k) { |
---|
46 | k.threads{}; |
---|
47 | } |
---|
48 | |
---|
49 | // Create storage separately to ensure no constructors are called. |
---|
50 | static pthread_keys cfa_pthread_keys_storage[PTHREAD_KEYS_MAX] __attribute__((aligned (16))); |
---|
51 | |
---|
52 | static void init_pthread_storage() { |
---|
53 | for ( int i = 0; i < PTHREAD_KEYS_MAX; i++ ) { |
---|
54 | cfa_pthread_keys_storage[i]{}; |
---|
55 | } |
---|
56 | } |
---|
57 | |
---|
58 | #define cfa_pthread_keys ((pthread_keys *)cfa_pthread_keys_storage) |
---|
59 | |
---|
60 | /* Controlling the iterations of destructors for thread-specific data. */ |
---|
61 | #define _POSIX_THREAD_DESTRUCTOR_ITERATIONS 4 |
---|
62 | /* Number of iterations this implementation does. */ |
---|
63 | #define PTHREAD_DESTRUCTOR_ITERATIONS _POSIX_THREAD_DESTRUCTOR_ITERATIONS |
---|
64 | |
---|
65 | //######################### Parallelism Helpers ######################### |
---|
66 | |
---|
67 | struct Pthread_kernel_threads{ |
---|
68 | inline dlink(Pthread_kernel_threads); |
---|
69 | processor p; |
---|
70 | }; |
---|
71 | P9_EMBEDDED( Pthread_kernel_threads, dlink(Pthread_kernel_threads) ) |
---|
72 | |
---|
73 | static dlist(Pthread_kernel_threads) cfa_pthreads_kernel_threads; |
---|
74 | static bool cfa_pthreads_kernel_threads_zero = false; // set to zero ? |
---|
75 | static int cfa_pthreads_no_kernel_threads = 1; // number of kernel threads |
---|
76 | |
---|
77 | |
---|
78 | //######################### Cond Helpers ######################### |
---|
79 | |
---|
80 | typedef pthread_cond_var(simple_owner_lock) cfa2pthr_cond_var_t; |
---|
81 | |
---|
82 | /* condvar helper routines */ |
---|
83 | static void init(pthread_cond_t * pcond) { |
---|
84 | static_assert(sizeof(pthread_cond_t) >= sizeof(cfa2pthr_cond_var_t),"sizeof(pthread_t) < sizeof(cfa2pthr_cond_var_t)"); |
---|
85 | cfa2pthr_cond_var_t * _cond = (cfa2pthr_cond_var_t *)pcond; |
---|
86 | ?{}(*_cond); |
---|
87 | } |
---|
88 | |
---|
89 | static cfa2pthr_cond_var_t * get(pthread_cond_t * pcond) { |
---|
90 | static_assert(sizeof(pthread_cond_t) >= sizeof(cfa2pthr_cond_var_t),"sizeof(pthread_t) < sizeof(cfa2pthr_cond_var_t)"); |
---|
91 | return (cfa2pthr_cond_var_t *)pcond; |
---|
92 | } |
---|
93 | |
---|
94 | static void destroy(pthread_cond_t * cond) { |
---|
95 | static_assert(sizeof(pthread_cond_t) >= sizeof(cfa2pthr_cond_var_t),"sizeof(pthread_t) < sizeof(cfa2pthr_cond_var_t)"); |
---|
96 | ^?{}(*get(cond)); |
---|
97 | } |
---|
98 | |
---|
99 | |
---|
100 | //######################### Mutex Helper ######################### |
---|
101 | |
---|
102 | /* mutex helper routines */ |
---|
103 | static void mutex_check(pthread_mutex_t * t) { |
---|
104 | // Use double check to improve performance. |
---|
105 | // Check is safe on x86; volatile prevents compiler reordering |
---|
106 | volatile pthread_mutex_t * const mutex_ = t; |
---|
107 | |
---|
108 | // SKULLDUGGERY: not a portable way to access the kind field, /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h |
---|
109 | int _lock_val = ((pthread_mutex_t *)mutex_)->__data.__lock; |
---|
110 | |
---|
111 | // if pthread_mutex_t is initialized by PTHREAD_MUTEX_INITIALIZER, _lock_val should be 0 |
---|
112 | if ( _lock_val == 0 ) { |
---|
113 | lock(magic_mutex_check); |
---|
114 | _lock_val = ((pthread_mutex_t *)mutex_)->__data.__lock; |
---|
115 | if ( _lock_val == 0 ) { |
---|
116 | pthread_mutex_init( t, NULL ); |
---|
117 | } |
---|
118 | unlock(magic_mutex_check); |
---|
119 | } |
---|
120 | } // mutex_check |
---|
121 | |
---|
122 | |
---|
123 | static void init(pthread_mutex_t * plock) { |
---|
124 | static_assert(sizeof(pthread_mutex_t) >= sizeof(simple_owner_lock),"sizeof(pthread_mutex_t) < sizeof(simple_owner_lock)"); |
---|
125 | simple_owner_lock * _lock = (simple_owner_lock *)plock; |
---|
126 | ?{}(*_lock); |
---|
127 | } |
---|
128 | |
---|
129 | static simple_owner_lock * get(pthread_mutex_t * plock) { |
---|
130 | static_assert(sizeof(pthread_mutex_t) >= sizeof(simple_owner_lock),"sizeof(pthread_mutex_t) < sizeof(simple_owner_lock)"); |
---|
131 | return (simple_owner_lock *)plock; |
---|
132 | } |
---|
133 | |
---|
134 | static void destroy(pthread_mutex_t * plock) { |
---|
135 | static_assert(sizeof(pthread_mutex_t) >= sizeof(simple_owner_lock),"sizeof(pthread_mutex_t) < sizeof(simple_owner_lock)"); |
---|
136 | ^?{}(*get(plock)); |
---|
137 | } |
---|
138 | |
---|
139 | //######################### Attr helpers ######################### |
---|
140 | typedef struct cfaPthread_attr_t { // thread attributes |
---|
141 | int contentionscope; |
---|
142 | int detachstate; |
---|
143 | size_t stacksize; |
---|
144 | void * stackaddr; |
---|
145 | int policy; |
---|
146 | int inheritsched; |
---|
147 | struct sched_param param; |
---|
148 | } cfaPthread_attr_t; |
---|
149 | |
---|
150 | static const cfaPthread_attr_t default_attrs { |
---|
151 | 0, |
---|
152 | 0, |
---|
153 | 65_000, |
---|
154 | NULL, |
---|
155 | 0, |
---|
156 | 0, |
---|
157 | {0} |
---|
158 | }; |
---|
159 | |
---|
160 | static cfaPthread_attr_t * get(const pthread_attr_t * attr) { |
---|
161 | static_assert(sizeof(pthread_attr_t) >= sizeof(cfaPthread_attr_t), "sizeof(pthread_attr_t) < sizeof(cfaPthread_attr_t)"); |
---|
162 | return (cfaPthread_attr_t *)attr; |
---|
163 | } |
---|
164 | |
---|
165 | |
---|
166 | //######################### Threads Helper ######################### |
---|
167 | |
---|
168 | // exception for cancel_stack in pthread_exit |
---|
169 | exception pthread_exit_exp {}; |
---|
170 | static vtable(pthread_exit_exp) exp_vt; |
---|
171 | |
---|
172 | thread cfaPthread{ |
---|
173 | cfaPthread_attr_t attr; |
---|
174 | pthread_t pthreadId; |
---|
175 | |
---|
176 | // pthreads return value |
---|
177 | void * joinval; |
---|
178 | |
---|
179 | // pthread attributes |
---|
180 | pthread_attr_t pthread_attr; |
---|
181 | |
---|
182 | void *(* start_routine)(void *); |
---|
183 | void * start_arg; |
---|
184 | |
---|
185 | // thread local data |
---|
186 | pthread_values * pthreadData; |
---|
187 | |
---|
188 | // flag used for tryjoin |
---|
189 | bool isTerminated; |
---|
190 | }; |
---|
191 | |
---|
192 | /* thread part routines */ |
---|
193 | // cfaPthread entry point |
---|
194 | void main(cfaPthread & _thread) with(_thread) { |
---|
195 | joinval = start_routine(start_arg); |
---|
196 | isTerminated = true; |
---|
197 | } |
---|
198 | |
---|
199 | static cfaPthread * lookup( pthread_t p ) { |
---|
200 | static_assert(sizeof(pthread_t) >= sizeof(cfaPthread *),"sizeof(pthread_t) < sizeof(cfaPthread *)"); |
---|
201 | return (cfaPthread *)p; |
---|
202 | } |
---|
203 | |
---|
204 | static void pthread_deletespecific_( pthread_values * values ) { // see uMachContext::invokeTask |
---|
205 | pthread_values * value; |
---|
206 | pthread_keys * key; |
---|
207 | bool destcalled = true; |
---|
208 | if (values != NULL) { |
---|
209 | for ( int attempts = 0; attempts < PTHREAD_DESTRUCTOR_ITERATIONS && destcalled ; attempts += 1 ) { |
---|
210 | destcalled = false; |
---|
211 | lock(key_lock); |
---|
212 | for ( int i = 0; i < PTHREAD_KEYS_MAX; i++ ) { |
---|
213 | // for each valid key |
---|
214 | if ( values[i].in_use) { |
---|
215 | value = &values[i]; |
---|
216 | key = &cfa_pthread_keys[i]; |
---|
217 | value->in_use = false; |
---|
218 | remove(*value); |
---|
219 | |
---|
220 | // if a key value has a non-NULL destructor pointer, and the thread has a non-NULL value associated with that key, |
---|
221 | // the value of the key is set to NULL, and then the function pointed to is called with the previously associated value as its sole argument. |
---|
222 | if (value->value != NULL && key->destructor != NULL) { |
---|
223 | unlock(key_lock); |
---|
224 | key->destructor(value->value); // run destructor |
---|
225 | lock(key_lock); |
---|
226 | destcalled = true; |
---|
227 | } // if |
---|
228 | value->value = NULL; |
---|
229 | } // if |
---|
230 | } // for |
---|
231 | unlock(key_lock); |
---|
232 | } // for |
---|
233 | free(values); |
---|
234 | } // if |
---|
235 | } |
---|
236 | |
---|
237 | static void ^?{}(cfaPthread & mutex t) { |
---|
238 | // delete pthread local storage |
---|
239 | pthread_values * values = t.pthreadData; |
---|
240 | pthread_deletespecific_(values); |
---|
241 | } |
---|
242 | |
---|
243 | static void ?{}(cfaPthread & t, pthread_t * _thread, const pthread_attr_t * _attr,void *(* start_routine)(void *), void * arg) { |
---|
244 | static_assert(sizeof(pthread_t) >= sizeof(cfaPthread *), "pthread_t too small to hold a pointer: sizeof(pthread_t) < sizeof(cfaPthread *)"); |
---|
245 | |
---|
246 | // set up user thread stackSize |
---|
247 | cfaPthread_attr_t * attr = get(_attr); |
---|
248 | ((thread&)t){ attr ? attr->stacksize: DEFAULT_STACK_SIZE }; |
---|
249 | |
---|
250 | // initialize _thread & cfaPthread id |
---|
251 | *_thread = t.pthreadId = (pthread_t)(&t); |
---|
252 | |
---|
253 | // if attr null, self attr will be set as default_attrs; else set to attr |
---|
254 | t.attr = (attr != NULL ? *attr : default_attrs); |
---|
255 | |
---|
256 | // init start routine and arguments |
---|
257 | t.start_routine = start_routine; |
---|
258 | t.start_arg = arg; |
---|
259 | t.pthreadData = NULL; |
---|
260 | } |
---|
261 | |
---|
262 | |
---|
263 | extern "C"{ |
---|
264 | //######################### Pthread Attrs ######################### |
---|
265 | |
---|
266 | int pthread_attr_init(pthread_attr_t * attr) libcfa_public __THROW { |
---|
267 | cfaPthread_attr_t * _attr = get(attr); |
---|
268 | ?{}(*_attr, default_attrs); |
---|
269 | return 0; |
---|
270 | } |
---|
271 | int pthread_attr_destroy(pthread_attr_t * attr) libcfa_public __THROW { |
---|
272 | ^?{}(*get(attr)); |
---|
273 | return 0; |
---|
274 | } |
---|
275 | |
---|
276 | int pthread_attr_setscope( pthread_attr_t * attr, int contentionscope ) libcfa_public __THROW { |
---|
277 | get( attr )->contentionscope = contentionscope; |
---|
278 | return 0; |
---|
279 | } // pthread_attr_setscope |
---|
280 | |
---|
281 | int pthread_attr_getscope( const pthread_attr_t * attr, int * contentionscope ) libcfa_public __THROW { |
---|
282 | *contentionscope = get( attr )->contentionscope; |
---|
283 | return 0; |
---|
284 | } // pthread_attr_getscope |
---|
285 | |
---|
286 | int pthread_attr_setdetachstate( pthread_attr_t * attr, int detachstate ) libcfa_public __THROW { |
---|
287 | get( attr )->detachstate = detachstate; |
---|
288 | return 0; |
---|
289 | } // pthread_attr_setdetachstate |
---|
290 | |
---|
291 | int pthread_attr_getdetachstate( const pthread_attr_t * attr, int * detachstate ) libcfa_public __THROW { |
---|
292 | *detachstate = get( attr )->detachstate; |
---|
293 | return 0; |
---|
294 | } // pthread_attr_getdetachstate |
---|
295 | |
---|
296 | int pthread_attr_setstacksize( pthread_attr_t * attr, size_t stacksize ) libcfa_public __THROW { |
---|
297 | get( attr )->stacksize = stacksize; |
---|
298 | return 0; |
---|
299 | } // pthread_attr_setstacksize |
---|
300 | |
---|
301 | int pthread_attr_getstacksize( const pthread_attr_t * attr, size_t * stacksize ) libcfa_public __THROW { |
---|
302 | *stacksize = get( attr )->stacksize; |
---|
303 | return 0; |
---|
304 | } // pthread_attr_getstacksize |
---|
305 | |
---|
306 | int pthread_attr_getguardsize( const pthread_attr_t * /* attr */, size_t * /* guardsize */ ) libcfa_public __THROW { |
---|
307 | return 0; |
---|
308 | } // pthread_attr_getguardsize |
---|
309 | |
---|
310 | int pthread_attr_setguardsize( pthread_attr_t * /* attr */, size_t /* guardsize */ ) libcfa_public __THROW { |
---|
311 | return 0; |
---|
312 | } // pthread_attr_setguardsize |
---|
313 | |
---|
314 | int pthread_attr_setstackaddr( pthread_attr_t * attr, void * stackaddr ) libcfa_public __THROW { |
---|
315 | get( attr )->stackaddr = stackaddr; |
---|
316 | return 0; |
---|
317 | } // pthread_attr_setstackaddr |
---|
318 | |
---|
319 | int pthread_attr_getstackaddr( const pthread_attr_t * attr, void ** stackaddr ) libcfa_public __THROW { |
---|
320 | *stackaddr = get( attr )->stackaddr; |
---|
321 | return 0; |
---|
322 | } // pthread_attr_getstackaddr |
---|
323 | |
---|
324 | int pthread_attr_setstack( pthread_attr_t * attr, void * stackaddr, size_t stacksize ) libcfa_public __THROW { |
---|
325 | get( attr )->stackaddr = stackaddr; |
---|
326 | get( attr )->stacksize = stacksize; |
---|
327 | return 0; |
---|
328 | } // pthread_attr_setstack |
---|
329 | |
---|
330 | int pthread_attr_getstack( const pthread_attr_t * attr, void ** stackaddr, size_t * stacksize ) libcfa_public __THROW { |
---|
331 | *stackaddr = get( attr )->stackaddr; |
---|
332 | *stacksize = get( attr )->stacksize; |
---|
333 | return 0; |
---|
334 | } // pthread_attr_getstack |
---|
335 | |
---|
336 | // Initialize thread attribute *attr with attributes corresponding to the |
---|
337 | // already running thread threadID. It shall be called on unitialized attr |
---|
338 | // and destroyed with pthread_attr_destroy when no longer needed. |
---|
339 | int pthread_getattr_np( pthread_t threadID, pthread_attr_t * attr ) libcfa_public __THROW { // GNU extension |
---|
340 | check_nonnull(attr); |
---|
341 | |
---|
342 | // copy all fields |
---|
343 | *get(attr) = lookup( threadID )->attr; |
---|
344 | |
---|
345 | return 0; |
---|
346 | } // pthread_getattr_np |
---|
347 | |
---|
348 | |
---|
349 | //######################### Threads ######################### |
---|
350 | |
---|
351 | int pthread_create(pthread_t * _thread, const pthread_attr_t * attr, void *(* start_routine)(void *), void * arg) libcfa_public __THROW { |
---|
352 | cfaPthread * t = alloc(); |
---|
353 | (*t){_thread, attr, start_routine, arg}; |
---|
354 | return 0; |
---|
355 | } |
---|
356 | |
---|
357 | int pthread_join(pthread_t _thread, void ** value_ptr) libcfa_public __THROW { |
---|
358 | // if thread is invalid |
---|
359 | if (_thread == NULL) return EINVAL; |
---|
360 | if (_thread == pthread_self()) return EDEADLK; |
---|
361 | |
---|
362 | // get user thr pointer |
---|
363 | cfaPthread * p = lookup(_thread); |
---|
364 | try { |
---|
365 | join(*p); |
---|
366 | } |
---|
367 | // if thread called pthread_exit |
---|
368 | catchResume (ThreadCancelled(cfaPthread) * cancel) {} |
---|
369 | |
---|
370 | // fetch result |
---|
371 | if (value_ptr != NULL ) *value_ptr = p->joinval; |
---|
372 | delete(p); |
---|
373 | return 0; |
---|
374 | } |
---|
375 | |
---|
376 | int pthread_tryjoin_np(pthread_t _thread, void ** value_ptr) libcfa_public __THROW { |
---|
377 | // if thread is invalid |
---|
378 | if (_thread == NULL) return EINVAL; |
---|
379 | if (_thread == pthread_self()) return EDEADLK; |
---|
380 | |
---|
381 | cfaPthread * p = lookup(_thread); |
---|
382 | |
---|
383 | // thread not finished ? |
---|
384 | if (!p->isTerminated) return EBUSY; |
---|
385 | |
---|
386 | join( *p ); |
---|
387 | |
---|
388 | if (value_ptr != NULL ) *value_ptr = p->joinval; |
---|
389 | delete(p); |
---|
390 | return 0; |
---|
391 | } |
---|
392 | |
---|
393 | pthread_t pthread_self(void) libcfa_public __THROW { |
---|
394 | return (pthread_t)((uintptr_t)active_thread() - (sizeof(cfaPthread) - sizeof(thread$))); |
---|
395 | } |
---|
396 | |
---|
397 | void pthread_exit(void * status) libcfa_public __THROW { |
---|
398 | pthread_t pid = pthread_self(); |
---|
399 | cfaPthread * _thread = (cfaPthread *)pid; |
---|
400 | _thread->joinval = status; // set return value |
---|
401 | _thread->isTerminated = 1; // set terminated flag |
---|
402 | cancel_stack((pthread_exit_exp){&exp_vt}); |
---|
403 | } //pthread_exit_ |
---|
404 | |
---|
405 | int pthread_yield( void ) __THROW { // GNU extension |
---|
406 | yield(); |
---|
407 | return 0; |
---|
408 | } |
---|
409 | |
---|
410 | |
---|
411 | //######################### Mutex ######################### |
---|
412 | |
---|
413 | int pthread_mutex_init(pthread_mutex_t *_mutex, const pthread_mutexattr_t * attr) libcfa_public __THROW { |
---|
414 | check_nonnull(_mutex); |
---|
415 | init(_mutex); |
---|
416 | return 0; |
---|
417 | } //pthread_mutex_init_ |
---|
418 | |
---|
419 | |
---|
420 | int pthread_mutex_destroy(pthread_mutex_t *_mutex) libcfa_public __THROW { |
---|
421 | check_nonnull(_mutex); |
---|
422 | simple_owner_lock * _lock = get(_mutex); |
---|
423 | if (_lock->owner != NULL) { |
---|
424 | return EBUSY; |
---|
425 | } |
---|
426 | destroy(_mutex); |
---|
427 | return 0; |
---|
428 | } //pthread_mutex_destroy_ |
---|
429 | |
---|
430 | int pthread_mutex_lock(pthread_mutex_t *_mutex) libcfa_public __THROW { |
---|
431 | check_nonnull(_mutex); |
---|
432 | mutex_check(_mutex); |
---|
433 | simple_owner_lock * _lock = get(_mutex); |
---|
434 | lock(*_lock); |
---|
435 | return 0; |
---|
436 | } //pthread_mutex_lock_ |
---|
437 | |
---|
438 | int pthread_mutex_unlock(pthread_mutex_t *_mutex) libcfa_public __THROW { |
---|
439 | check_nonnull(_mutex); |
---|
440 | simple_owner_lock * _lock = get(_mutex); |
---|
441 | if (_lock->owner != active_thread()) { |
---|
442 | return EPERM; |
---|
443 | } // current thread does not hold the mutex |
---|
444 | unlock(*_lock); |
---|
445 | return 0; |
---|
446 | } //pthread_mutex_unlock_ |
---|
447 | |
---|
448 | int pthread_mutex_trylock(pthread_mutex_t *_mutex) libcfa_public __THROW { |
---|
449 | check_nonnull(_mutex); |
---|
450 | simple_owner_lock * _lock = get(_mutex); |
---|
451 | if (_lock->owner != active_thread() && _lock->owner != NULL) { |
---|
452 | return EBUSY; |
---|
453 | } // if mutex is owned |
---|
454 | lock(*_lock); |
---|
455 | return 0; |
---|
456 | } //pthread_mutex_trylock_ |
---|
457 | |
---|
458 | //######################### Conditional Variable ######################### |
---|
459 | |
---|
460 | /* conditional variable routines */ |
---|
461 | int pthread_cond_init(pthread_cond_t * cond, const pthread_condattr_t * attr) libcfa_public __THROW { |
---|
462 | check_nonnull(cond); |
---|
463 | init(cond); |
---|
464 | return 0; |
---|
465 | } //pthread_cond_init |
---|
466 | |
---|
467 | int pthread_cond_wait(pthread_cond_t * cond, pthread_mutex_t *_mutex) libcfa_public __THROW { |
---|
468 | check_nonnull(_mutex); |
---|
469 | check_nonnull(cond); |
---|
470 | wait(*get(cond), *get(_mutex)); |
---|
471 | return 0; |
---|
472 | } // pthread_cond_wait |
---|
473 | |
---|
474 | int pthread_cond_timedwait(pthread_cond_t * cond, pthread_mutex_t * _mutex, const struct timespec * abstime) libcfa_public __THROW { |
---|
475 | check_nonnull(_mutex); |
---|
476 | check_nonnull(cond); |
---|
477 | wait(*get(cond), *get(_mutex), *abstime); |
---|
478 | return 0; |
---|
479 | } // pthread_cond_timedwait |
---|
480 | |
---|
481 | int pthread_cond_signal(pthread_cond_t * cond) libcfa_public __THROW { |
---|
482 | check_nonnull(cond); |
---|
483 | return notify_one(*get(cond)); |
---|
484 | } // pthread_cond_signal |
---|
485 | |
---|
486 | int pthread_cond_broadcast(pthread_cond_t * cond) libcfa_public __THROW { |
---|
487 | check_nonnull(cond); |
---|
488 | return notify_all(*get(cond)); |
---|
489 | } // pthread_cond_broadcast |
---|
490 | |
---|
491 | int pthread_cond_destroy(pthread_cond_t * cond) libcfa_public __THROW { |
---|
492 | check_nonnull(cond); |
---|
493 | destroy(cond); |
---|
494 | return 0; |
---|
495 | } // pthread_cond_destroy |
---|
496 | |
---|
497 | |
---|
498 | |
---|
499 | //######################### Local storage ######################### |
---|
500 | |
---|
501 | int pthread_once(pthread_once_t * once_control, void (* init_routine)(void)) libcfa_public __THROW { |
---|
502 | static_assert(sizeof(pthread_once_t) >= sizeof(int),"sizeof(pthread_once_t) < sizeof(int)"); |
---|
503 | check_nonnull(once_control); |
---|
504 | check_nonnull(init_routine); |
---|
505 | lock(once_lock); |
---|
506 | if ( *((int *)once_control) == 0 ) { |
---|
507 | init_routine(); |
---|
508 | *((int *)once_control) = 1; |
---|
509 | } // if |
---|
510 | unlock(once_lock); |
---|
511 | return 0; |
---|
512 | } // pthread_once |
---|
513 | |
---|
514 | int pthread_key_create( pthread_key_t * key, void (* destructor)( void * ) ) libcfa_public __THROW { |
---|
515 | lock(key_lock); |
---|
516 | for ( int i = 0; i < PTHREAD_KEYS_MAX; i += 1 ) { |
---|
517 | if ( ! cfa_pthread_keys[i].in_use ) { |
---|
518 | cfa_pthread_keys[i].in_use = true; |
---|
519 | cfa_pthread_keys[i].destructor = destructor; |
---|
520 | unlock( key_lock ); |
---|
521 | *key = i; |
---|
522 | return 0; |
---|
523 | } // if |
---|
524 | } // for |
---|
525 | unlock(key_lock); |
---|
526 | return EAGAIN; |
---|
527 | } // pthread_key_create |
---|
528 | |
---|
529 | int pthread_key_delete( pthread_key_t key ) libcfa_public __THROW { |
---|
530 | lock(key_lock); |
---|
531 | if ( key >= PTHREAD_KEYS_MAX || ! cfa_pthread_keys[key].in_use ) { |
---|
532 | unlock( key_lock ); |
---|
533 | return EINVAL; |
---|
534 | } // if |
---|
535 | cfa_pthread_keys[key].in_use = false; |
---|
536 | cfa_pthread_keys[key].destructor = NULL; |
---|
537 | |
---|
538 | // Remove key from all threads with a value. |
---|
539 | |
---|
540 | // Sequence(pthread_values)& head = cfa_pthread_keys[key].threads; |
---|
541 | // for ( SeqIter(pthread_values) iter = { head }; iter | p; ) { |
---|
542 | // remove(head, p); |
---|
543 | // p.in_use = false; |
---|
544 | // } |
---|
545 | pthread_values * p = &try_pop_front( cfa_pthread_keys[key].threads ); |
---|
546 | for ( ; p; ) { |
---|
547 | p->in_use = false; |
---|
548 | p = &try_pop_front( cfa_pthread_keys[key].threads ); |
---|
549 | } |
---|
550 | unlock(key_lock); |
---|
551 | return 0; |
---|
552 | } // pthread_key_delete |
---|
553 | |
---|
554 | int pthread_setspecific( pthread_key_t key, const void * value ) libcfa_public __THROW { |
---|
555 | // get current thread |
---|
556 | cfaPthread * t = lookup(pthread_self()); |
---|
557 | // if current thread's pthreadData is NULL; initialize it |
---|
558 | pthread_values * values; |
---|
559 | if (t->pthreadData == NULL) { |
---|
560 | values = anew( PTHREAD_KEYS_MAX); |
---|
561 | t->pthreadData = values; |
---|
562 | for ( int i = 0;i < PTHREAD_KEYS_MAX; i++ ) { |
---|
563 | t->pthreadData[i].in_use = false; |
---|
564 | } // for |
---|
565 | } else { |
---|
566 | values = t->pthreadData; |
---|
567 | } // if |
---|
568 | // find corresponding key and set value |
---|
569 | lock(key_lock); |
---|
570 | // if invalid key |
---|
571 | if ( key >= PTHREAD_KEYS_MAX || ! cfa_pthread_keys[key].in_use ) { |
---|
572 | unlock( key_lock ); |
---|
573 | return EINVAL; |
---|
574 | } // if |
---|
575 | pthread_values &entry = values[key]; |
---|
576 | if ( ! entry.in_use ) { |
---|
577 | entry.in_use = true; |
---|
578 | insert_last(cfa_pthread_keys[key].threads, entry); |
---|
579 | } // if |
---|
580 | entry.value = (void *)value; |
---|
581 | unlock(key_lock); |
---|
582 | return 0; |
---|
583 | } //pthread_setspecific |
---|
584 | |
---|
585 | void * pthread_getspecific(pthread_key_t key) libcfa_public __THROW { |
---|
586 | if (key >= PTHREAD_KEYS_MAX || ! cfa_pthread_keys[key].in_use) return NULL; |
---|
587 | |
---|
588 | // get current thread |
---|
589 | cfaPthread * t = lookup(pthread_self()); |
---|
590 | if (t->pthreadData == NULL) return NULL; |
---|
591 | lock(key_lock); |
---|
592 | pthread_values & entry = ((pthread_values *)t->pthreadData)[key]; |
---|
593 | if ( ! entry.in_use ) { |
---|
594 | unlock( key_lock ); |
---|
595 | return NULL; |
---|
596 | } // if |
---|
597 | void * value = entry.value; |
---|
598 | unlock(key_lock); |
---|
599 | |
---|
600 | return value; |
---|
601 | } //pthread_get_specific |
---|
602 | |
---|
603 | //######################### Parallelism ######################### |
---|
604 | void pthread_delete_kernel_threads_() __THROW { // see uMain::~uMain |
---|
605 | Pthread_kernel_threads * p = &try_pop_front(cfa_pthreads_kernel_threads); |
---|
606 | for ( ; p; ) { |
---|
607 | delete(p); |
---|
608 | p = &try_pop_front(cfa_pthreads_kernel_threads); |
---|
609 | } // for |
---|
610 | } // pthread_delete_kernel_threads_ |
---|
611 | |
---|
612 | int pthread_getconcurrency( void ) __THROW { // XOPEN extension |
---|
613 | return cfa_pthreads_kernel_threads_zero ? 0 : cfa_pthreads_no_kernel_threads; |
---|
614 | } // pthread_getconcurrency |
---|
615 | |
---|
616 | int pthread_setconcurrency( int new_level ) libcfa_public __THROW { // XOPEN extension |
---|
617 | if ( new_level < 0 ) return EINVAL; |
---|
618 | if ( new_level == 0 ) { |
---|
619 | cfa_pthreads_kernel_threads_zero = true; // remember set to zero, but ignore |
---|
620 | return 0; // do not do kernel thread management |
---|
621 | } // exit |
---|
622 | cfa_pthreads_kernel_threads_zero = false; |
---|
623 | lock( concurrency_lock ); |
---|
624 | for ( ; new_level > cfa_pthreads_no_kernel_threads; cfa_pthreads_no_kernel_threads += 1 ) { // add processors ? |
---|
625 | insert_last(cfa_pthreads_kernel_threads, *new() ); |
---|
626 | } // for |
---|
627 | for ( ; new_level < cfa_pthreads_no_kernel_threads; cfa_pthreads_no_kernel_threads -= 1 ) { // remove processors ? |
---|
628 | delete(&try_pop_front(cfa_pthreads_kernel_threads)); |
---|
629 | } // for |
---|
630 | unlock( concurrency_lock ); |
---|
631 | return 0; |
---|
632 | } // pthread_setconcurrency |
---|
633 | |
---|
634 | //######################### Signal ######################### |
---|
635 | |
---|
636 | |
---|
637 | int pthread_sigmask( int /* how */, const sigset_t * /* set */, sigset_t * /* oset */ ) libcfa_public __THROW { |
---|
638 | abort( "pthread_sigmask : not implemented" ); |
---|
639 | return 0; |
---|
640 | } // pthread_sigmask |
---|
641 | |
---|
642 | int pthread_kill( pthread_t _thread __attribute__(( unused )), int sig ) libcfa_public __THROW { |
---|
643 | if ( sig == 0 ) { |
---|
644 | return 0; |
---|
645 | } else { |
---|
646 | abort( "pthread_kill : not implemented" ); |
---|
647 | } // if |
---|
648 | return 0; |
---|
649 | } // pthread_kill |
---|
650 | |
---|
651 | int pthread_sigqueue(pthread_t , int sig, const union sigval) libcfa_public __THROW { |
---|
652 | abort( "pthread_sigqueue : not implemented" ); |
---|
653 | return 0; |
---|
654 | } // pthread_sigqueue |
---|
655 | |
---|
656 | //######################### Scheduling ######################### |
---|
657 | int pthread_detach( pthread_t threadID ) __THROW { |
---|
658 | abort( "pthread_detach : not implemented" ); |
---|
659 | return 0; |
---|
660 | } // pthread_detach |
---|
661 | |
---|
662 | int pthread_setschedparam( pthread_t /* thread */, int /* policy */, const struct sched_param * /* param */ ) libcfa_public __THROW { |
---|
663 | abort( "pthread_setschedparam : not implemented" ); |
---|
664 | return 0; |
---|
665 | } // pthread_setschedparam |
---|
666 | |
---|
667 | int pthread_getschedparam( pthread_t /* thread */, int */* policy */, struct sched_param * /* param */ ) libcfa_public __THROW { |
---|
668 | abort( "pthread_getschedparam : not implemented" ); |
---|
669 | return 0; |
---|
670 | } // pthread_getschedparam |
---|
671 | |
---|
672 | //######################### Mutex Attr ######################### |
---|
673 | |
---|
674 | int pthread_mutexattr_init( pthread_mutexattr_t * /* attr */ ) libcfa_public __THROW { |
---|
675 | return 0; |
---|
676 | } // pthread_mutexattr_init |
---|
677 | |
---|
678 | int pthread_mutexattr_destroy( pthread_mutexattr_t * /* attr */ ) libcfa_public __THROW { |
---|
679 | return 0; |
---|
680 | } // pthread_mutexattr_destroy |
---|
681 | |
---|
682 | int pthread_mutexattr_setpshared( pthread_mutexattr_t * /* attr */, int /* pshared */ ) libcfa_public __THROW { |
---|
683 | return 0; |
---|
684 | } // pthread_mutexattr_setpshared |
---|
685 | |
---|
686 | int pthread_mutexattr_getpshared( const pthread_mutexattr_t * /* attr */, int * /* pshared */ ) libcfa_public __THROW { |
---|
687 | return 0; |
---|
688 | } // pthread_mutexattr_getpshared |
---|
689 | |
---|
690 | int pthread_mutexattr_setprotocol( pthread_mutexattr_t * /* attr */, int /* protocol */ ) libcfa_public __THROW { |
---|
691 | return 0; |
---|
692 | } // pthread_mutexattr_setprotocol |
---|
693 | |
---|
694 | int pthread_mutexattr_getprotocol( const pthread_mutexattr_t * /* attr */, int * /* protocol */ ) libcfa_public __THROW { |
---|
695 | return 0; |
---|
696 | } // pthread_mutexattr_getprotocol |
---|
697 | |
---|
698 | int pthread_mutexattr_setprioceiling( pthread_mutexattr_t * /* attr */, int /* prioceiling */ ) libcfa_public __THROW { |
---|
699 | return 0; |
---|
700 | } // pthread_mutexattr_setprioceiling |
---|
701 | |
---|
702 | int pthread_mutexattr_getprioceiling( const pthread_mutexattr_t * /* attr */, int * /* ceiling */ ) libcfa_public __THROW { |
---|
703 | return 0; |
---|
704 | } // pthread_mutexattr_getprioceiling |
---|
705 | |
---|
706 | int pthread_mutex_setprioceiling( pthread_mutex_t * /* mutex */, int /* prioceiling */, int * /* old_ceiling */ ) libcfa_public __THROW { |
---|
707 | return 0; |
---|
708 | } // pthread_mutex_setprioceiling |
---|
709 | |
---|
710 | int pthread_mutex_getprioceiling( const pthread_mutex_t * /* mutex */, int * /* ceiling */ ) libcfa_public __THROW { |
---|
711 | return 0; |
---|
712 | } // pthread_mutex_getprioceiling |
---|
713 | |
---|
714 | int pthread_mutexattr_gettype( __const pthread_mutexattr_t * __restrict /* __attr */, int * __restrict /* __kind */ ) libcfa_public __THROW { |
---|
715 | return 0; |
---|
716 | } // pthread_mutexattr_gettype |
---|
717 | |
---|
718 | int pthread_mutexattr_settype( pthread_mutexattr_t * /* __attr */, int /* __kind */ ) libcfa_public __THROW { |
---|
719 | return 0; |
---|
720 | } // pthread_mutexattr_settype |
---|
721 | |
---|
722 | //######################### Mutex ######################### |
---|
723 | |
---|
724 | int pthread_mutex_timedlock( pthread_mutex_t *__restrict /* __mutex */, __const struct timespec *__restrict /* __abstime */ ) libcfa_public __THROW { |
---|
725 | abort( "pthread_mutex_timedlock" ); |
---|
726 | } // pthread_mutex_timedlock |
---|
727 | |
---|
728 | //######################### Condition ######################### |
---|
729 | |
---|
730 | int pthread_condattr_getclock( __const pthread_condattr_t * __restrict /* __attr */, __clockid_t *__restrict /* __clock_id */ ) libcfa_public __THROW { |
---|
731 | abort( "pthread_condattr_getclock" ); |
---|
732 | } // pthread_condattr_getclock |
---|
733 | |
---|
734 | int pthread_condattr_setclock( pthread_condattr_t * /* __attr */, __clockid_t /* __clock_id */ ) libcfa_public __THROW { |
---|
735 | abort( "pthread_condattr_setclock" ); |
---|
736 | } // pthread_condattr_setclock |
---|
737 | |
---|
738 | //######################### Spinlock ######################### |
---|
739 | |
---|
740 | int pthread_spin_init( pthread_spinlock_t * /* __lock */, int /*__pshared */ ) libcfa_public __THROW { |
---|
741 | abort( "pthread_spin_init" ); |
---|
742 | } // pthread_spin_init |
---|
743 | |
---|
744 | int pthread_spin_destroy( pthread_spinlock_t * /* __lock */ ) libcfa_public __THROW { |
---|
745 | abort( "pthread_spin_destroy" ); |
---|
746 | } // pthread_spin_destroy |
---|
747 | |
---|
748 | int pthread_spin_lock( pthread_spinlock_t * /* __lock */ ) libcfa_public __THROW { |
---|
749 | abort( "pthread_spin_lock" ); |
---|
750 | } // pthread_spin_lock |
---|
751 | |
---|
752 | int pthread_spin_trylock( pthread_spinlock_t * /* __lock */ ) libcfa_public __THROW { |
---|
753 | abort( "pthread_spin_trylock" ); |
---|
754 | } // pthread_spin_trylock |
---|
755 | |
---|
756 | int pthread_spin_unlock( pthread_spinlock_t * /* __lock */ ) libcfa_public __THROW { |
---|
757 | abort( "pthread_spin_unlock" ); |
---|
758 | } // pthread_spin_unlock |
---|
759 | |
---|
760 | //######################### Barrier ######################### |
---|
761 | |
---|
762 | int pthread_barrier_init( pthread_barrier_t *__restrict /* __barrier */, __const pthread_barrierattr_t *__restrict /* __attr */, unsigned int /* __count */ ) libcfa_public __THROW { |
---|
763 | abort( "pthread_barrier_init" ); |
---|
764 | } // pthread_barrier_init |
---|
765 | |
---|
766 | int pthread_barrier_destroy( pthread_barrier_t * /* __barrier */ ) libcfa_public __THROW { |
---|
767 | abort( "pthread_barrier_destroy" ); |
---|
768 | } // pthread_barrier_destroy |
---|
769 | |
---|
770 | int pthread_barrier_wait( pthread_barrier_t * /* __barrier */ ) libcfa_public __THROW { |
---|
771 | abort( "pthread_barrier_wait" ); |
---|
772 | } // pthread_barrier_wait |
---|
773 | |
---|
774 | int pthread_barrierattr_init( pthread_barrierattr_t * /* __attr */ ) libcfa_public __THROW { |
---|
775 | abort( "pthread_barrierattr_init" ); |
---|
776 | } // pthread_barrierattr_init |
---|
777 | |
---|
778 | int pthread_barrierattr_destroy( pthread_barrierattr_t * /* __attr */ ) libcfa_public __THROW { |
---|
779 | abort( "pthread_barrierattr_destroy" ); |
---|
780 | } // pthread_barrierattr_destroy |
---|
781 | |
---|
782 | int pthread_barrierattr_getpshared( __const pthread_barrierattr_t * __restrict /* __attr */, int *__restrict /* __pshared */ ) libcfa_public __THROW { |
---|
783 | abort( "pthread_barrierattr_getpshared" ); |
---|
784 | } // pthread_barrierattr_getpshared |
---|
785 | |
---|
786 | int pthread_barrierattr_setpshared( pthread_barrierattr_t * /* __attr */, int /* __pshared */ ) libcfa_public __THROW { |
---|
787 | abort( "pthread_barrierattr_setpshared" ); |
---|
788 | } // pthread_barrierattr_setpshared |
---|
789 | |
---|
790 | //######################### Clock ######################### |
---|
791 | |
---|
792 | int pthread_getcpuclockid( pthread_t /* __thread_id */, __clockid_t * /* __clock_id */ ) libcfa_public __THROW { |
---|
793 | abort( "pthread_getcpuclockid" ); |
---|
794 | } // pthread_getcpuclockid |
---|
795 | |
---|
796 | // pthread_atfork() |
---|
797 | |
---|
798 | // UNIX98 |
---|
799 | |
---|
800 | //######################### Read/Write ######################### |
---|
801 | |
---|
802 | int pthread_rwlock_init( pthread_rwlock_t *__restrict /* __rwlock */, __const pthread_rwlockattr_t *__restrict /* __attr */ ) libcfa_public __THROW { |
---|
803 | abort( "pthread_rwlock_init" ); |
---|
804 | } // pthread_rwlock_init |
---|
805 | |
---|
806 | int pthread_rwlock_destroy( pthread_rwlock_t * /* __rwlock */ ) libcfa_public __THROW { |
---|
807 | abort( "pthread_rwlock_destroy" ); |
---|
808 | } // pthread_rwlock_destroy |
---|
809 | |
---|
810 | int pthread_rwlock_rdlock( pthread_rwlock_t * /* __rwlock */ ) libcfa_public __THROW { |
---|
811 | abort( "pthread_rwlock_rdlock" ); |
---|
812 | } // pthread_rwlock_rdlock |
---|
813 | |
---|
814 | int pthread_rwlock_tryrdlock( pthread_rwlock_t * /* __rwlock */ ) libcfa_public __THROW { |
---|
815 | abort( "pthread_rwlock_tryrdlock" ); |
---|
816 | } // pthread_rwlock_tryrdlock |
---|
817 | |
---|
818 | int pthread_rwlock_wrlock( pthread_rwlock_t * /* __rwlock */ ) libcfa_public __THROW { |
---|
819 | abort( "pthread_rwlock_wrlock" ); |
---|
820 | } // pthread_rwlock_wrlock |
---|
821 | |
---|
822 | int pthread_rwlock_trywrlock( pthread_rwlock_t * /* __rwlock */ ) libcfa_public __THROW { |
---|
823 | abort( "pthread_rwlock_trywrlock" ); |
---|
824 | } // pthread_rwlock_trywrlock |
---|
825 | |
---|
826 | int pthread_rwlock_unlock( pthread_rwlock_t * /* __rwlock */ ) libcfa_public __THROW { |
---|
827 | abort( "pthread_rwlock_unlock" ); |
---|
828 | } // pthread_rwlock_unlock |
---|
829 | |
---|
830 | int pthread_rwlockattr_init( pthread_rwlockattr_t * /* __attr */ ) libcfa_public __THROW { |
---|
831 | abort( "pthread_rwlockattr_init" ); |
---|
832 | } // pthread_rwlockattr_init |
---|
833 | |
---|
834 | int pthread_rwlockattr_destroy( pthread_rwlockattr_t * /*__attr */ ) libcfa_public __THROW { |
---|
835 | abort( "pthread_rwlockattr_destroy" ); |
---|
836 | } // pthread_rwlockattr_destroy |
---|
837 | |
---|
838 | int pthread_rwlockattr_getpshared( __const pthread_rwlockattr_t * __restrict /* __attr */, int *__restrict /* __pshared */ ) libcfa_public __THROW { |
---|
839 | abort( "pthread_rwlockattr_getpshared" ); |
---|
840 | } // pthread_rwlockattr_getpshared |
---|
841 | |
---|
842 | int pthread_rwlockattr_setpshared( pthread_rwlockattr_t * /* __attr */, int /* __pshared */ ) libcfa_public __THROW { |
---|
843 | abort( "pthread_rwlockattr_setpshared" ); |
---|
844 | } // pthread_rwlockattr_setpshared |
---|
845 | |
---|
846 | int pthread_rwlockattr_getkind_np( __const pthread_rwlockattr_t * /* __attr */, int * /* __pref */ ) libcfa_public __THROW { |
---|
847 | abort( "pthread_rwlockattr_getkind_np" ); |
---|
848 | } // pthread_rwlockattr_getkind_np |
---|
849 | |
---|
850 | int pthread_rwlockattr_setkind_np( pthread_rwlockattr_t * /* __attr */, int /* __pref */ ) libcfa_public __THROW { |
---|
851 | abort( "pthread_rwlockattr_setkind_np" ); |
---|
852 | } // pthread_rwlockattr_setkind_np |
---|
853 | |
---|
854 | // UNIX98 + XOPEN |
---|
855 | |
---|
856 | int pthread_rwlock_timedrdlock( pthread_rwlock_t *__restrict /* __rwlock */, __const struct timespec *__restrict /* __abstime */ ) libcfa_public __THROW { |
---|
857 | abort( "pthread_rwlock_timedrdlock" ); |
---|
858 | } // pthread_rwlock_timedrdlock |
---|
859 | |
---|
860 | int pthread_rwlock_timedwrlock( pthread_rwlock_t *__restrict /* __rwlock */, __const struct timespec *__restrict /* __abstime */ ) libcfa_public __THROW { |
---|
861 | abort( "pthread_rwlock_timedwrlock" ); |
---|
862 | } // pthread_rwlock_timedwrlock |
---|
863 | |
---|
864 | // GNU |
---|
865 | |
---|
866 | //######################### Parallelism ######################### |
---|
867 | |
---|
868 | // int pthread_setaffinity_np( pthread_t /* __th */, size_t /* __cpusetsize */, __const cpu_set_t * /* __cpuset */ ) libcfa_public __THROW { |
---|
869 | // abort( "pthread_setaffinity_np" ); |
---|
870 | // } // pthread_setaffinity_np |
---|
871 | |
---|
872 | // int pthread_getaffinity_np( pthread_t /* __th */, size_t /* __cpusetsize */, cpu_set_t * /* __cpuset */ ) libcfa_public __THROW { |
---|
873 | // abort( "pthread_getaffinity_np" ); |
---|
874 | // } // pthread_getaffinity_np |
---|
875 | |
---|
876 | // int pthread_attr_setaffinity_np( pthread_attr_t * /* __attr */, size_t /* __cpusetsize */, __const cpu_set_t * /* __cpuset */ ) libcfa_public __THROW { |
---|
877 | // abort( "pthread_attr_setaffinity_np" ); |
---|
878 | // } // pthread_attr_setaffinity_np |
---|
879 | |
---|
880 | // int pthread_attr_getaffinity_np( __const pthread_attr_t * /* __attr */, size_t /* __cpusetsize */, cpu_set_t * /* __cpuset */ ) libcfa_public __THROW { |
---|
881 | // abort( "pthread_attr_getaffinity_np" ); |
---|
882 | // } // pthread_attr_getaffinity_np |
---|
883 | |
---|
884 | //######################### Cancellation ######################### |
---|
885 | |
---|
886 | void _pthread_cleanup_push_defer( struct _pthread_cleanup_buffer * /* __buffer */, void( * /* __routine */ )( void * ), void * /* __arg */ ) libcfa_public __THROW { |
---|
887 | abort( "_pthread_cleanup_push_defer" ); |
---|
888 | } // _pthread_cleanup_push_defer |
---|
889 | |
---|
890 | void _pthread_cleanup_pop_restore( struct _pthread_cleanup_buffer * /* __buffer */, int /* __execute */ ) libcfa_public __THROW { |
---|
891 | abort( "_pthread_cleanup_pop_restore" ); |
---|
892 | } // _pthread_cleanup_pop_res |
---|
893 | |
---|
894 | int pthread_cancel( pthread_t threadID ) libcfa_public __THROW { |
---|
895 | abort("pthread cancel not implemented"); |
---|
896 | return 0; |
---|
897 | } // pthread_cancel |
---|
898 | |
---|
899 | int pthread_setcancelstate( int state, int * oldstate ) libcfa_public __THROW { |
---|
900 | abort("pthread_setcancelstate not implemented"); |
---|
901 | return 0; |
---|
902 | } // pthread_setcancelstate |
---|
903 | |
---|
904 | int pthread_setcanceltype( int type, int * oldtype ) libcfa_public __THROW { |
---|
905 | abort("pthread_setcanceltype not implemented"); |
---|
906 | return 0; |
---|
907 | } // pthread_setcanceltype |
---|
908 | } // extern "C" |
---|
909 | |
---|
910 | #pragma GCC diagnostic pop |
---|