ESBMC
Efficient SMT-based Context-Bounded Model Checker
Loading...
Searching...
No Matches
pthread.h
Go to the documentation of this file.
1/* Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
2 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
19
20#pragma once
21
22#include <__esbmc/stddefs.h>
23
24#include <stddef.h>
25#include <stdint.h>
26
27#include <sched.h>
28
30
31#ifndef _MSVC
32#define NULL 0
33#endif
34
35/* Full definition required because the type is used in pthread function
36 * parameters below and user code may use it as a complete type. */
37#include <time.h>
38
39typedef int32_t __clockid_t;
40
41typedef unsigned long int pthread_t;
42
43typedef union pthread_attr_t
44{
45 long int __align;
47
48
49typedef struct
50{
51 int __lock;
52 /* Repurposed as this mutex's waiter count; see __ESBMC_mutex_waiters. */
53 unsigned int __count;
54 /* Thread holding the mutex; only meaningful while __lock is 1. */
56 /* PTHREAD_MUTEX_NORMAL / _RECURSIVE / _ERRORCHECK, from the attribute
57 passed to pthread_mutex_init. */
58 int __kind;
59 /* The owner's nesting depth, which only a recursive mutex takes above 1. */
60 unsigned int __depth;
62
63/* Mutex initializer. PTHREAD_MUTEX_NORMAL is 0, so a statically initialised
64 mutex gets the default kind. */
65#define PTHREAD_MUTEX_INITIALIZER { 0, 0, 0, 0, 0, }
66
67/* __align holds the mutex kind; see __ESBMC_mutexattr_kind. */
68typedef union
69{
72
73
74typedef struct pthread_cond_t
75{
76 int __lock;
77 unsigned int __futex;
78 unsigned int __nwaiters;
80
81/* Conditional variable handling. */
82#define PTHREAD_COND_INITIALIZER { 0, 0, 0, }
83
84typedef union
85{
88
89
90/* Keys for thread-specific data */
91typedef unsigned int pthread_key_t;
92
93
94/* Once-only execution */
95typedef int pthread_once_t;
96
97
98//#if defined __USE_UNIX98 || defined __USE_XOPEN2K
99//jmorse - we always want this, regardless of feature flags.
100typedef struct {
103 /* Threads currently blocked on this lock; see __ESBMC_rwlock_waiters. */
104 unsigned int __waiters;
106
107/* Read-write lock initializer. */
108#define PTHREAD_RWLOCK_INITIALIZER { 0, }
109
110typedef union
111{
112 long int __align;
114//#endif
115
116
117/* Always exposed: ESBMC never defines __USE_XOPEN2K, so guarding these made
118 barriers and spinlocks unusable outright (#6478). */
119/* POSIX spinlock data type. Both fields are ESBMC bookkeeping: __lock holds
120 the state and __waiters the blocked-thread count, as for pthread_mutex_t. */
121typedef struct
122{
124 unsigned int __waiters;
126
127
128/* POSIX barriers data type. The structure of the type is
129 deliberately not exposed. */
130typedef struct
131{
132 unsigned int __count;
133 unsigned int __arrived;
134 /* Bumped every time the barrier opens, so a waiter can tell that the
135 round it arrived in has completed. */
136 unsigned int __generation;
137 unsigned int __waiters;
139
140typedef union
141{
144
146{
148};
149
150#if __WORDSIZE == 32
151/* Extra attributes for the cleanup functions. */
152# define __cleanup_fct_attribute __attribute__ ((__regparm__ (1)))
153#endif
154
155/* Detach state. */
156enum
157{
159#define PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_JOINABLE
161#define PTHREAD_CREATE_DETACHED PTHREAD_CREATE_DETACHED
162};
163
164
165/* Mutex types. */
166enum
167{
172 ,
177};
178
179
180#ifdef __USE_XOPEN2K
181/* Robust mutex or not flags. */
182enum
183{
184 PTHREAD_MUTEX_STALLED,
185 PTHREAD_MUTEX_STALLED_NP = PTHREAD_MUTEX_STALLED,
186 PTHREAD_MUTEX_ROBUST,
187 PTHREAD_MUTEX_ROBUST_NP = PTHREAD_MUTEX_ROBUST
188};
189#endif
190
191
192#ifdef __USE_UNIX98
193/* Mutex protocols. */
194enum
195{
196 PTHREAD_PRIO_NONE,
197 PTHREAD_PRIO_INHERIT,
198 PTHREAD_PRIO_PROTECT
199};
200#endif
201
202/* Read-write lock types. */
203#if defined __USE_UNIX98 || defined __USE_XOPEN2K
204enum
205{
206 PTHREAD_RWLOCK_PREFER_READER_NP,
207 PTHREAD_RWLOCK_PREFER_WRITER_NP,
208 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP,
209 PTHREAD_RWLOCK_DEFAULT_NP = PTHREAD_RWLOCK_PREFER_READER_NP
210};
211#endif /* Unix98 or XOpen2K */
212
213
214/* Scheduler inheritance. */
215enum
216{
218#define PTHREAD_INHERIT_SCHED PTHREAD_INHERIT_SCHED
220#define PTHREAD_EXPLICIT_SCHED PTHREAD_EXPLICIT_SCHED
221};
222
223
224/* Scope handling. */
225enum
226{
228#define PTHREAD_SCOPE_SYSTEM PTHREAD_SCOPE_SYSTEM
230#define PTHREAD_SCOPE_PROCESS PTHREAD_SCOPE_PROCESS
231};
232
233
234/* Process shared or private flag. */
235enum
236{
238#define PTHREAD_PROCESS_PRIVATE PTHREAD_PROCESS_PRIVATE
240#define PTHREAD_PROCESS_SHARED PTHREAD_PROCESS_SHARED
241};
242
243
244
245
246/* Cleanup buffers */
248{
249 void (*__routine) (void *); /* Function to call. */
250 void *__arg; /* Its argument. */
251 int __canceltype; /* Saved cancellation type. */
252 struct _pthread_cleanup_buffer *__prev; /* Chaining of cleanup functions. */
253};
254
255/* Cancellation */
256enum
257{
259#define PTHREAD_CANCEL_ENABLE PTHREAD_CANCEL_ENABLE
261#define PTHREAD_CANCEL_DISABLE PTHREAD_CANCEL_DISABLE
262};
263enum
264{
266#define PTHREAD_CANCEL_DEFERRED PTHREAD_CANCEL_DEFERRED
268#define PTHREAD_CANCEL_ASYNCHRONOUS PTHREAD_CANCEL_ASYNCHRONOUS
269};
270#define PTHREAD_CANCELED ((void *) -1)
271
272
273/* Single execution handling. */
274#define PTHREAD_ONCE_INIT 0
275
276
277/* Value returned by 'pthread_barrier_wait' for one of the threads after
278 the required number of threads have called this function.
279 -1 is distinct from 0 and all errno constants */
280#define PTHREAD_BARRIER_SERIAL_THREAD -1
281
282
283/* Create a new thread, starting with execution of START-ROUTINE
284 getting passed ARG. Creation attributed come from ATTR. The new
285 handle is stored in *NEWTHREAD. */
286extern int pthread_create (pthread_t *__restrict __newthread,
287 __const pthread_attr_t *__restrict __attr,
288 void *(*__start_routine) (void *),
289 void *__restrict __arg);
290
291/* Terminate calling thread.
292
293 The registered cleanup handlers are called via exception handling
294 so we cannot mark this function with __THROW.*/
295extern void pthread_exit (void *__retval) __attribute__ ((__noreturn__));
296
297/* Make calling thread wait for termination of the thread TH. The
298 exit status of the thread is stored in *THREAD_RETURN, if THREAD_RETURN
299 is not NULL.
300
301 This function is a cancellation point and therefore not marked with
302 __THROW. */
303extern int pthread_join (pthread_t __th, void **__thread_return);
304
305/* Indicate that the thread TH is never to be joined with PTHREAD_JOIN.
306 The resources of TH will therefore be freed immediately when it
307 terminates, instead of waiting for another thread to perform PTHREAD_JOIN
308 on it. */
309extern int pthread_detach (pthread_t __th);
310
311
312/* Obtain the identifier of the current thread. */
314
315/* Compare two thread identifiers. */
316extern int pthread_equal (pthread_t __thread1, pthread_t __thread2);
317
318/* push and pop thread cancellation clean-up handlers */
319void pthread_cleanup_push(void (*routine)(void *),
320 void *arg);
321void pthread_cleanup_pop(int execute);
322
323/* Thread attribute handling. */
324
325/* Initialize thread attribute *ATTR with default attributes
326 (detachstate is PTHREAD_JOINABLE, scheduling policy is SCHED_OTHER,
327 no user-provided stack). */
329
330/* Destroy thread attribute *ATTR. */
332
333/* Get detach state attribute. */
334extern int pthread_attr_getdetachstate (__const pthread_attr_t *__attr,
335 int *__detachstate);
336
337/* Set detach state attribute. */
339 int __detachstate);
340
341
342/* Get the size of the guard area created for stack overflow protection. */
343extern int pthread_attr_getguardsize (__const pthread_attr_t *__attr,
344 size_t *__guardsize);
345
346/* Set the size of the guard area created for stack overflow protection. */
348 size_t __guardsize);
349
350/* Return in *PARAM the scheduling parameters of *ATTR. */
351extern int pthread_attr_getschedparam (__const pthread_attr_t *__restrict
352 __attr,
353 struct sched_param *__restrict __param);
354
355/* Set scheduling parameters (priority, etc) in *ATTR according to PARAM. */
356extern int pthread_attr_setschedparam (pthread_attr_t *__restrict __attr,
357 __const struct sched_param *__restrict
358 __param);
359
360/* Return in *POLICY the scheduling policy of *ATTR. */
361extern int pthread_attr_getschedpolicy (__const pthread_attr_t *__restrict
362 __attr, int *__restrict __policy);
363
364/* Set scheduling policy in *ATTR according to POLICY. */
365extern int pthread_attr_setschedpolicy (pthread_attr_t *__attr, int __policy);
366
367/* Return in *INHERIT the scheduling inheritance mode of *ATTR. */
368extern int pthread_attr_getinheritsched (__const pthread_attr_t *__restrict
369 __attr, int *__restrict __inherit);
370
371/* Set scheduling inheritance mode in *ATTR according to INHERIT. */
373 int __inherit);
374
375
376/* Return in *SCOPE the scheduling contention scope of *ATTR. */
377extern int pthread_attr_getscope (__const pthread_attr_t *__restrict __attr,
378 int *__restrict __scope);
379
380/* Set scheduling contention scope in *ATTR according to SCOPE. */
381extern int pthread_attr_setscope (pthread_attr_t *__attr, int __scope);
382
383/* Return the previously set address for the stack. */
384extern int pthread_attr_getstackaddr (__const pthread_attr_t *__restrict
385 __attr, void **__restrict __stackaddr);
386
387/* Set the starting address of the stack of the thread to be created.
388 Depending on whether the stack grows up or down the value must either
389 be higher or lower than all the address in the memory block. The
390 minimal size of the block must be PTHREAD_STACK_MIN. */
392 void *__stackaddr);
393
394/* Return the currently used minimal stack size. */
395extern int pthread_attr_getstacksize (__const pthread_attr_t *__restrict
396 __attr, size_t *__restrict __stacksize);
397
398/* Add information about the minimum stack size needed for the thread
399 to be started. This size must never be less than PTHREAD_STACK_MIN
400 and must also not exceed the system limits. */
402 size_t __stacksize);
403
404#ifdef __USE_XOPEN2K
405/* Return the previously set address for the stack. */
406extern int pthread_attr_getstack (__const pthread_attr_t *__restrict __attr,
407 void **__restrict __stackaddr,
408 size_t *__restrict __stacksize);
409
410/* The following two interfaces are intended to replace the last two. They
411 require setting the address as well as the size since only setting the
412 address will make the implementation on some architectures impossible. */
413extern int pthread_attr_setstack (pthread_attr_t *__attr, void *__stackaddr,
414 size_t __stacksize);
415#endif
416
417/* Functions for scheduling control. */
418
419/* Set the scheduling parameters for TARGET_THREAD according to POLICY
420 and *PARAM. */
421extern int pthread_setschedparam (pthread_t __target_thread, int __policy,
422 __const struct sched_param *__param);
423
424/* Return in *POLICY and *PARAM the scheduling parameters for TARGET_THREAD. */
425extern int pthread_getschedparam (pthread_t __target_thread,
426 int *__restrict __policy,
427 struct sched_param *__restrict __param);
428
429/* Set the scheduling priority for TARGET_THREAD. */
430extern int pthread_setschedprio (pthread_t __target_thread, int __prio);
431
432#ifdef __USE_UNIX98
433/* Determine level of concurrency. */
434extern int pthread_getconcurrency (void);
435
436/* Set new concurrency level to LEVEL. */
437extern int pthread_setconcurrency (int __level);
438#endif
439
440/* Functions for handling initialization. */
441
442/* Guarantee that the initialization function INIT_ROUTINE will be called
443 only once, even if pthread_once is executed several times with the
444 same ONCE_CONTROL argument. ONCE_CONTROL must point to a static or
445 extern variable initialized to PTHREAD_ONCE_INIT.
446
447 The initialization functions might throw exception which is why
448 this function is not marked with __THROW. */
449extern int pthread_once (pthread_once_t *__once_control,
450 void (*__init_routine) (void));
451
452
453/* Functions for handling cancellation.
454
455 Note that these functions are explicitly not marked to not throw an
456 exception in C++ code. If cancellation is implemented by unwinding
457 this is necessary to have the compiler generate the unwind information. */
458
459/* Set cancelability state of current thread to STATE, returning old
460 state in *OLDSTATE if OLDSTATE is not NULL. */
461extern int pthread_setcancelstate (int __state, int *__oldstate);
462
463/* Set cancellation state of current thread to TYPE, returning the old
464 type in *OLDTYPE if OLDTYPE is not NULL. */
465extern int pthread_setcanceltype (int __type, int *__oldtype);
466
467/* Cancel THREAD immediately or at the next possibility. */
468extern int pthread_cancel (pthread_t __th);
469
470/* Test for pending cancellation for the current thread and terminate
471 the thread as per pthread_exit(PTHREAD_CANCELED) if it has been
472 cancelled. */
473extern void pthread_testcancel (void);
474
475/* No special attributes by default. */
476#ifndef __cleanup_fct_attribute
477# define __cleanup_fct_attribute
478#endif
479
480/* Mutex handling. */
481
482/* Initialize a mutex. */
484 __const pthread_mutexattr_t *__mutexattr);
485
486/* Destroy a mutex. */
487extern int pthread_mutex_destroy (pthread_mutex_t *__mutex);
488
489/* Try locking a mutex. */
490extern int pthread_mutex_trylock (pthread_mutex_t *__mutex);
491
492/* Lock a mutex. */
494
495#ifdef __USE_XOPEN2K
496/* Wait until lock becomes available, or specified time passes. */
497extern int pthread_mutex_timedlock (pthread_mutex_t *__restrict __mutex,
498 __const struct timespec *__restrict
499 __abstime);
500#endif
501
502/* Unlock a mutex. */
504
505
506/* Get the priority ceiling of MUTEX. */
508 __restrict __mutex,
509 int *__restrict __prioceiling);
510
511/* Set the priority ceiling of MUTEX to PRIOCEILING, return old
512 priority ceiling value in *OLD_CEILING. */
513extern int pthread_mutex_setprioceiling (pthread_mutex_t *__restrict __mutex,
514 int __prioceiling,
515 int *__restrict __old_ceiling);
516
517
518#ifdef __USE_XOPEN2K8
519/* Declare the state protected by MUTEX as consistent. */
520extern int pthread_mutex_consistent (pthread_mutex_t *__mutex);
521#endif
522
523
524/* Functions for handling mutex attributes. */
525
526/* Initialize mutex attribute object ATTR with default attributes
527 (kind is PTHREAD_MUTEX_TIMED_NP). */
529
530/* Destroy mutex attribute object ATTR. */
532
533/* Get the process-shared flag of the mutex attribute ATTR. */
535 __restrict __attr,
536 int *__restrict __pshared);
537
538/* Set the process-shared flag of the mutex attribute ATTR. */
540 int __pshared);
541
542// #if defined __USE_UNIX98 || defined __USE_XOPEN2K8
543// fbrausse: always expose, no harm done
544/* Return in *KIND the mutex kind attribute in *ATTR. */
545extern int pthread_mutexattr_gettype (__const pthread_mutexattr_t *__restrict
546 __attr, int *__restrict __kind);
547
548/* Set the mutex kind attribute in *ATTR to KIND (either PTHREAD_MUTEX_NORMAL,
549 PTHREAD_MUTEX_RECURSIVE, PTHREAD_MUTEX_ERRORCHECK, or
550 PTHREAD_MUTEX_DEFAULT). */
551extern int pthread_mutexattr_settype (pthread_mutexattr_t *__attr, int __kind);
552// #endif
553
554/* Return in *PROTOCOL the mutex protocol attribute in *ATTR. */
556 __restrict __attr,
557 int *__restrict __protocol);
558
559/* Set the mutex protocol attribute in *ATTR to PROTOCOL (either
560 PTHREAD_PRIO_NONE, PTHREAD_PRIO_INHERIT, or PTHREAD_PRIO_PROTECT). */
562 int __protocol);
563
564/* Return in *PRIOCEILING the mutex prioceiling attribute in *ATTR. */
566 __restrict __attr,
567 int *__restrict __prioceiling);
568
569/* Set the mutex prioceiling attribute in *ATTR to PRIOCEILING. */
571 int __prioceiling);
572
573#ifdef __USE_XOPEN2K
574/* Get the robustness flag of the mutex attribute ATTR. */
575extern int pthread_mutexattr_getrobust (__const pthread_mutexattr_t *__attr,
576 int *__robustness);
577
578/* Set the robustness flag of the mutex attribute ATTR. */
579extern int pthread_mutexattr_setrobust (pthread_mutexattr_t *__attr,
580 int __robustness);
581#endif
582
583
584/* Functions for handling read-write locks. Unguarded because ESBMC defines
585 neither __USE_UNIX98 nor __USE_XOPEN2K, which would leave the
586 --deadlock-check -D renames with no prototype to rewrite. */
587
588/* Initialize read-write lock RWLOCK using attributes ATTR, or use
589 the default values if later is NULL. */
590extern int pthread_rwlock_init (pthread_rwlock_t *__restrict __rwlock,
591 __const pthread_rwlockattr_t *__restrict
592 __attr);
593
594/* Destroy read-write lock RWLOCK. */
595extern int pthread_rwlock_destroy (pthread_rwlock_t *__rwlock);
596
597/* Acquire read lock for RWLOCK. */
598extern int pthread_rwlock_rdlock (pthread_rwlock_t *__rwlock);
599
600/* Try to acquire read lock for RWLOCK. */
601extern int pthread_rwlock_tryrdlock (pthread_rwlock_t *__rwlock);
602
603# ifdef __USE_XOPEN2K
604/* Try to acquire read lock for RWLOCK or return after specfied time. */
605extern int pthread_rwlock_timedrdlock (pthread_rwlock_t *__restrict __rwlock,
606 __const struct timespec *__restrict
607 __abstime);
608# endif
609
610/* Acquire write lock for RWLOCK. */
611extern int pthread_rwlock_wrlock (pthread_rwlock_t *__rwlock);
612
613/* Try to acquire write lock for RWLOCK. */
614extern int pthread_rwlock_trywrlock (pthread_rwlock_t *__rwlock);
615
616# ifdef __USE_XOPEN2K
617/* Try to acquire write lock for RWLOCK or return after specfied time. */
618extern int pthread_rwlock_timedwrlock (pthread_rwlock_t *__restrict __rwlock,
619 __const struct timespec *__restrict
620 __abstime);
621# endif
622
623/* Unlock RWLOCK. */
624extern int pthread_rwlock_unlock (pthread_rwlock_t *__rwlock);
625
626
627/* Functions for handling read-write lock attributes. */
628
629/* Initialize attribute object ATTR with default values. */
631
632/* Destroy attribute object ATTR. */
634
635/* Return current setting of process-shared attribute of ATTR in PSHARED. */
637 __restrict __attr,
638 int *__restrict __pshared);
639
640/* Set process-shared attribute of ATTR to PSHARED. */
642 int __pshared);
643
644/* Return current setting of reader/writer preference. */
646 __restrict __attr,
647 int *__restrict __pref);
648
649/* Set reader/write preference. */
651 int __pref);
652
653
654/* Functions for handling conditional variables. */
655
656/* Initialize condition variable COND using attributes ATTR, or use
657 the default values if later is NULL. */
658extern int pthread_cond_init (pthread_cond_t *__restrict __cond,
659 __const pthread_condattr_t *__restrict
660 __cond_attr);
661
662/* Destroy condition variable COND. */
663extern int pthread_cond_destroy (pthread_cond_t *__cond);
664
665/* Wake up one thread waiting for condition variable COND. */
666extern int pthread_cond_signal (pthread_cond_t *__cond);
667
668/* Wake up all threads waiting for condition variables COND. */
669extern int pthread_cond_broadcast (pthread_cond_t *__cond);
670
671/* Wait for condition variable COND to be signaled or broadcast.
672 MUTEX is assumed to be locked before.
673
674 This function is a cancellation point and therefore not marked with
675 _THROW. */
676extern int pthread_cond_wait (pthread_cond_t *__restrict __cond,
677 pthread_mutex_t *__restrict __mutex);
678
679/* Wait for condition variable COND to be signaled or broadcast until
680 ABSTIME. MUTEX is assumed to be locked before. ABSTIME is an
681 absolute time specification; zero is the beginning of the epoch
682 (00:00:00 GMT, January 1, 1970).
683
684 This function is a cancellation point and therefore not marked with
685 __THROW. */
686extern int pthread_cond_timedwait (pthread_cond_t *__restrict __cond,
687 pthread_mutex_t *__restrict __mutex,
688 __const struct timespec *__restrict
689 __abstime);
690
691/* Functions for handling condition variable attributes. */
692
693/* Initialize condition variable attribute ATTR. */
695
696/* Destroy condition variable attribute ATTR. */
698
699/* Get the process-shared flag of the condition variable attribute ATTR. */
701 __restrict __attr,
702 int *__restrict __pshared);
703
704/* Set the process-shared flag of the condition variable attribute ATTR. */
706 int __pshared);
707
708#ifdef __USE_XOPEN2K
709/* Get the clock selected for the conditon variable attribute ATTR. */
710extern int pthread_condattr_getclock (__const pthread_condattr_t *
711 __restrict __attr,
712 __clockid_t *__restrict __clock_id);
713
714/* Set the clock selected for the conditon variable attribute ATTR. */
715extern int pthread_condattr_setclock (pthread_condattr_t *__attr,
716 __clockid_t __clock_id);
717#endif
718
719
720/* Always exposed; see the type definitions above. */
721/* Functions to handle spinlocks. */
722
723/* Initialize the spinlock LOCK. If PSHARED is nonzero the spinlock can
724 be shared between different processes. */
725extern int pthread_spin_init (pthread_spinlock_t *__lock, int __pshared);
726
727/* Destroy the spinlock LOCK. */
728extern int pthread_spin_destroy (pthread_spinlock_t *__lock);
729
730/* Wait until spinlock LOCK is retrieved. */
731extern int pthread_spin_lock (pthread_spinlock_t *__lock);
732
733/* Try to lock spinlock LOCK. */
734extern int pthread_spin_trylock (pthread_spinlock_t *__lock);
735
736/* Release spinlock LOCK. */
737extern int pthread_spin_unlock (pthread_spinlock_t *__lock);
738
739
740/* Functions to handle barriers. */
741
742/* Initialize BARRIER with the attributes in ATTR. The barrier is
743 opened when COUNT waiters arrived. */
744extern int pthread_barrier_init (pthread_barrier_t *__restrict __barrier,
745 __const pthread_barrierattr_t *__restrict
746 __attr, unsigned int __count);
747
748/* Destroy a previously dynamically initialized barrier BARRIER. */
749extern int pthread_barrier_destroy (pthread_barrier_t *__barrier);
750
751/* Wait on barrier BARRIER. */
752extern int pthread_barrier_wait (pthread_barrier_t *__barrier);
753
754
755/* Initialize barrier attribute ATTR. */
757
758/* Destroy previously dynamically initialized barrier attribute ATTR. */
760
761/* Get the process-shared flag of the barrier attribute ATTR. */
763 __restrict __attr,
764 int *__restrict __pshared);
765
766/* Set the process-shared flag of the barrier attribute ATTR. */
768 int __pshared);
769
770
771/* Functions for handling thread-specific data. */
772
773/* Create a key value identifying a location in the thread-specific
774 data area. Each thread maintains a distinct thread-specific data
775 area. DESTR_FUNCTION, if non-NULL, is called with the value
776 associated to that key when the key is destroyed.
777 DESTR_FUNCTION is not called if the value associated is NULL when
778 the key is destroyed. */
779extern int pthread_key_create (pthread_key_t *__key,
780 void (*__destr_function) (void *));
781
782/* Destroy KEY. */
784
785/* Return current value of the thread-specific data slot identified by KEY. */
786extern void *pthread_getspecific (pthread_key_t __key);
787
788/* Store POINTER in the thread-specific data slot identified by KEY. */
790 __const void *__pointer);
791
792
793#ifdef __USE_XOPEN2K
794/* Get ID of CPU-time clock for thread THREAD_ID. */
795extern int pthread_getcpuclockid (pthread_t __thread_id,
796 __clockid_t *__clock_id);
797#endif
798
799
800/* Install handlers to be called when a new process is created with FORK.
801 The PREPARE handler is called in the parent process just before performing
802 FORK. The PARENT handler is called in the parent process just after FORK.
803 The CHILD handler is called in the child process. Each of the three
804 handlers can be NULL, meaning that no handler needs to be called at that
805 point.
806 PTHREAD_ATFORK can be called several times, in which case the PREPARE
807 handlers are called in LIFO order (last added with PTHREAD_ATFORK,
808 first called before FORK), and the PARENT and CHILD handlers are called
809 in FIFO (first added, first called). */
810
811extern int pthread_atfork (void (*__prepare) (void),
812 void (*__parent) (void),
813 void (*__child) (void));
814
815
816#ifdef __USE_EXTERN_INLINES
817/* Optimizations. */
818__extern_inline int
819__NTH (pthread_equal (pthread_t __thread1, pthread_t __thread2))
820{
821 return __thread1 == __thread2;
822}
823#endif
824
#define __const__
Definition linux.hpp:89
int pthread_mutex_setprioceiling(pthread_mutex_t *__restrict __mutex, int __prioceiling, int *__restrict __old_ceiling)
int pthread_spin_lock(pthread_spinlock_t *__lock)
Definition pthread_lib.c:999
int pthread_mutexattr_getpshared(__const pthread_mutexattr_t *__restrict __attr, int *__restrict __pshared)
int pthread_rwlockattr_getpshared(__const pthread_rwlockattr_t *__restrict __attr, int *__restrict __pshared)
#define PTHREAD_PROCESS_SHARED
Definition pthread.h:240
int pthread_attr_getschedpolicy(__const pthread_attr_t *__restrict __attr, int *__restrict __policy)
int pthread_condattr_destroy(pthread_condattr_t *__attr)
int pthread_cancel(pthread_t __th)
Send a cancellation request to thread th.
Definition pthread_lib.c:332
int pthread_rwlock_unlock(pthread_rwlock_t *__rwlock)
Definition pthread_lib.c:829
int pthread_setspecific(pthread_key_t __key, __const void *__pointer)
int pthread_rwlock_rdlock(pthread_rwlock_t *__rwlock)
Definition pthread_lib.c:761
int pthread_attr_setguardsize(pthread_attr_t *__attr, size_t __guardsize)
@ PTHREAD_MUTEX_RECURSIVE
Definition pthread.h:174
@ PTHREAD_MUTEX_ERRORCHECK
Definition pthread.h:175
@ PTHREAD_MUTEX_TIMED_NP
Definition pthread.h:168
@ PTHREAD_MUTEX_ADAPTIVE_NP
Definition pthread.h:171
@ PTHREAD_MUTEX_NORMAL
Definition pthread.h:173
@ PTHREAD_MUTEX_ERRORCHECK_NP
Definition pthread.h:170
@ PTHREAD_MUTEX_RECURSIVE_NP
Definition pthread.h:169
@ PTHREAD_MUTEX_DEFAULT
Definition pthread.h:176
int pthread_mutex_unlock(pthread_mutex_t *__mutex)
int pthread_rwlock_wrlock(pthread_rwlock_t *__rwlock)
Definition pthread_lib.c:849
int pthread_mutexattr_getprotocol(__const pthread_mutexattr_t *__restrict __attr, int *__restrict __protocol)
int pthread_attr_setinheritsched(pthread_attr_t *__attr, int __inherit)
int pthread_attr_setscope(pthread_attr_t *__attr, int __scope)
int pthread_once(pthread_once_t *__once_control, void(*__init_routine)(void))
Definition pthread_lib.c:1278
int pthread_attr_getdetachstate(__const pthread_attr_t *__attr, int *__detachstate)
int pthread_mutexattr_settype(pthread_mutexattr_t *__attr, int __kind)
Definition pthread_lib.c:445
int pthread_spin_destroy(pthread_spinlock_t *__lock)
Definition pthread_lib.c:994
int pthread_attr_getguardsize(__const pthread_attr_t *__attr, size_t *__guardsize)
int pthread_condattr_init(pthread_condattr_t *__attr)
#define PTHREAD_CREATE_DETACHED
Definition pthread.h:161
int pthread_attr_setdetachstate(pthread_attr_t *__attr, int __detachstate)
int pthread_setcanceltype(int __type, int *__oldtype)
Set the calling thread's cancellation type.
Definition pthread_lib.c:355
int pthread_attr_setstacksize(pthread_attr_t *__attr, size_t __stacksize)
int pthread_getschedparam(pthread_t __target_thread, int *__restrict __policy, struct sched_param *__restrict __param)
#define PTHREAD_PROCESS_PRIVATE
Definition pthread.h:238
#define PTHREAD_INHERIT_SCHED
Definition pthread.h:218
int pthread_key_delete(pthread_key_t __key)
int pthread_mutex_lock(pthread_mutex_t *__mutex)
int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *__attr, int __pref)
int pthread_attr_getscope(__const pthread_attr_t *__restrict __attr, int *__restrict __scope)
int pthread_condattr_getpshared(__const pthread_condattr_t *__restrict __attr, int *__restrict __pshared)
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *__attr, int __pshared)
int pthread_rwlockattr_init(pthread_rwlockattr_t *__attr)
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *__attr)
int pthread_barrierattr_init(pthread_barrierattr_t *__attr)
Definition pthread_lib.c:890
int pthread_attr_getstackaddr(__const pthread_attr_t *__restrict __attr, void **__restrict __stackaddr)
int pthread_cond_timedwait(pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex, __const struct timespec *__restrict __abstime)
int pthread_setschedparam(pthread_t __target_thread, int __policy, __const struct sched_param *__param)
int pthread_spin_init(pthread_spinlock_t *__lock, int __pshared)
Definition pthread_lib.c:983
pthread_t pthread_self(void) __attribute__((__const__))
Definition pthread_lib.c:311
void pthread_cleanup_push(void(*routine)(void *), void *arg)
Push a cleanup handler onto the current thread's cleanup stack.
Definition pthread_lib.c:1340
unsigned long int pthread_t
Definition pthread.h:41
#define PTHREAD_CANCEL_DISABLE
Definition pthread.h:261
int pthread_atfork(void(*__prepare)(void), void(*__parent)(void), void(*__child)(void))
int pthread_mutexattr_setprotocol(pthread_mutexattr_t *__attr, int __protocol)
int pthread_cond_destroy(pthread_cond_t *__cond)
Definition pthread_lib.c:1083
#define PTHREAD_CANCEL_DEFERRED
Definition pthread.h:266
int pthread_rwlock_trywrlock(pthread_rwlock_t *__rwlock)
Definition pthread_lib.c:815
unsigned int pthread_key_t
Definition pthread.h:91
int pthread_join(pthread_t __th, void **__thread_return)
int pthread_attr_getstacksize(__const pthread_attr_t *__restrict __attr, size_t *__restrict __stacksize)
int pthread_attr_setschedpolicy(pthread_attr_t *__attr, int __policy)
int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *__attr, int __prioceiling)
int pthread_barrier_wait(pthread_barrier_t *__barrier)
Definition pthread_lib.c:945
int pthread_attr_init(pthread_attr_t *__attr)
void pthread_exit(void *__retval) __attribute__((__noreturn__))
Definition pthread_lib.c:281
int pthread_once_t
Definition pthread.h:95
int pthread_mutex_getprioceiling(__const pthread_mutex_t *__restrict __mutex, int *__restrict __prioceiling)
int pthread_barrierattr_setpshared(pthread_barrierattr_t *__attr, int __pshared)
Definition pthread_lib.c:909
int32_t __clockid_t
Definition pthread.h:39
int pthread_spin_trylock(pthread_spinlock_t *__lock)
Definition pthread_lib.c:1028
int pthread_attr_setschedparam(pthread_attr_t *__restrict __attr, __const struct sched_param *__restrict __param)
int pthread_detach(pthread_t __th)
Definition pthread_lib.c:1307
int pthread_mutex_trylock(pthread_mutex_t *__mutex)
Definition pthread_lib.c:682
int pthread_condattr_setpshared(pthread_condattr_t *__attr, int __pshared)
#define PTHREAD_CANCEL_ASYNCHRONOUS
Definition pthread.h:268
#define PTHREAD_CANCEL_ENABLE
Definition pthread.h:259
int pthread_setschedprio(pthread_t __target_thread, int __prio)
#define PTHREAD_SCOPE_SYSTEM
Definition pthread.h:228
int pthread_rwlock_tryrdlock(pthread_rwlock_t *__rwlock)
Definition pthread_lib.c:798
int pthread_attr_getinheritsched(__const pthread_attr_t *__restrict __attr, int *__restrict __inherit)
int pthread_cond_init(pthread_cond_t *__restrict __cond, __const pthread_condattr_t *__restrict __cond_attr)
int pthread_barrierattr_getpshared(__const pthread_barrierattr_t *__restrict __attr, int *__restrict __pshared)
int pthread_rwlock_init(pthread_rwlock_t *__restrict __rwlock, __const pthread_rwlockattr_t *__restrict __attr)
int pthread_mutex_destroy(pthread_mutex_t *__mutex)
Definition pthread_lib.c:729
int pthread_barrier_destroy(pthread_barrier_t *__barrier)
Definition pthread_lib.c:933
int pthread_spin_unlock(pthread_spinlock_t *__lock)
Definition pthread_lib.c:1044
int pthread_mutexattr_destroy(pthread_mutexattr_t *__attr)
Definition pthread_lib.c:439
int pthread_mutexattr_init(pthread_mutexattr_t *__attr)
Definition pthread_lib.c:432
int pthread_setcancelstate(int __state, int *__oldstate)
Set the calling thread's cancellability state.
Definition pthread_lib.c:342
#define PTHREAD_EXPLICIT_SCHED
Definition pthread.h:220
int pthread_key_create(pthread_key_t *__key, void(*__destr_function)(void *))
Definition pthread_lib.c:1202
int pthread_cond_broadcast(pthread_cond_t *__cond)
Definition pthread_lib.c:1062
int pthread_mutex_init(pthread_mutex_t *__mutex, __const pthread_mutexattr_t *__mutexattr)
int pthread_rwlock_destroy(pthread_rwlock_t *__rwlock)
Definition pthread_lib.c:740
int pthread_attr_setstackaddr(pthread_attr_t *__attr, void *__stackaddr)
int pthread_attr_getschedparam(__const pthread_attr_t *__restrict __attr, struct sched_param *__restrict __param)
int pthread_barrier_init(pthread_barrier_t *__restrict __barrier, __const pthread_barrierattr_t *__restrict __attr, unsigned int __count)
#define PTHREAD_SCOPE_PROCESS
Definition pthread.h:230
int pthread_cond_signal(pthread_cond_t *__cond)
Definition pthread_lib.c:1092
int pthread_equal(pthread_t __thread1, pthread_t __thread2)
Definition pthread_lib.c:1258
int pthread_attr_destroy(pthread_attr_t *__attr)
int pthread_cond_wait(pthread_cond_t *__restrict __cond, pthread_mutex_t *__restrict __mutex)
int pthread_mutexattr_gettype(__const pthread_mutexattr_t *__restrict __attr, int *__restrict __kind)
void pthread_testcancel(void)
Deliver a pending cancellation if cancelstate is PTHREAD_CANCEL_ENABLE.
Definition pthread_lib.c:318
int pthread_rwlockattr_getkind_np(__const pthread_rwlockattr_t *__restrict __attr, int *__restrict __pref)
int pthread_mutexattr_setpshared(pthread_mutexattr_t *__attr, int __pshared)
int pthread_create(pthread_t *__restrict __newthread, __const pthread_attr_t *__restrict __attr, void *(*__start_routine)(void *), void *__restrict __arg)
int pthread_mutexattr_getprioceiling(__const pthread_mutexattr_t *__restrict __attr, int *__restrict __prioceiling)
int pthread_barrierattr_destroy(pthread_barrierattr_t *__attr)
Definition pthread_lib.c:895
void * pthread_getspecific(pthread_key_t __key)
Definition pthread_lib.c:1222
#define PTHREAD_CREATE_JOINABLE
Definition pthread.h:159
void pthread_cleanup_pop(int execute)
Pop a cleanup handler from the current thread's cleanup stack and optionally execute it.
Definition pthread_lib.c:1375
struct mapping_t_fast __attribute__
Definition pthread_lib.c:86
#define __ESBMC_C_CPP_END
Definition stddefs.h:9
#define __ESBMC_C_CPP_BEGIN
Definition stddefs.h:8
Definition pthread.h:248
void(* __routine)(void *)
Definition pthread.h:249
int __canceltype
Definition pthread.h:251
struct _pthread_cleanup_buffer * __prev
Definition pthread.h:252
void * __arg
Definition pthread.h:250
Definition pthread.h:131
unsigned int __arrived
Definition pthread.h:133
unsigned int __waiters
Definition pthread.h:137
unsigned int __generation
Definition pthread.h:136
unsigned int __count
Definition pthread.h:132
Definition pthread.h:75
unsigned int __futex
Definition pthread.h:77
unsigned int __nwaiters
Definition pthread.h:78
int __lock
Definition pthread.h:76
Definition pthread.h:50
int __kind
Definition pthread.h:58
unsigned int __count
Definition pthread.h:53
int __lock
Definition pthread.h:51
unsigned int __depth
Definition pthread.h:60
int __owner
Definition pthread.h:55
Definition pthread.h:100
unsigned int __waiters
Definition pthread.h:104
int __readers
Definition pthread.h:101
int __writer
Definition pthread.h:102
Definition pthread.h:122
unsigned int __waiters
Definition pthread.h:124
int __lock
Definition pthread.h:123
Definition pthread.h:146
int __sched_priority
Definition pthread.h:147
Definition time.h:69
Definition pthread.h:44
long int __align
Definition pthread.h:45
Definition pthread.h:141
int __align
Definition pthread.h:142
Definition pthread.h:85
int __align
Definition pthread.h:86
Definition pthread.h:69
int __align
Definition pthread.h:70
Definition pthread.h:111
long int __align
Definition pthread.h:112