| 1 | /*
|
|---|
| 2 | All specification references correspond to pages in the Standard for Information Technology
|
|---|
| 3 | Portable Operating System Interface (POSIX)IEEE Computer Society Base Specifications, Issue 7.
|
|---|
| 4 |
|
|---|
| 5 | Standard modifications to each translation:
|
|---|
| 6 | header files are altered
|
|---|
| 7 | errors are changed to assertion violations with appropriate messages
|
|---|
| 8 | appropriate definitions are changed to input variables
|
|---|
| 9 | */
|
|---|
| 10 |
|
|---|
| 11 | #ifndef _PTHREAD_
|
|---|
| 12 | #define _PTHREAD_
|
|---|
| 13 | #ifdef NULL
|
|---|
| 14 | #else
|
|---|
| 15 | #define NULL ((void*)0)
|
|---|
| 16 | #endif
|
|---|
| 17 | /*#ifdef __SVCOMP__
|
|---|
| 18 | #else
|
|---|
| 19 | #include <svcomp.h>
|
|---|
| 20 | #endif*/
|
|---|
| 21 |
|
|---|
| 22 | // don't think this should be here, but this is using CIVL's $proc
|
|---|
| 23 | // need to talk about it...
|
|---|
| 24 | #include <civlc.cvh>
|
|---|
| 25 | #include<civl-pthread.cvh>
|
|---|
| 26 |
|
|---|
| 27 | //Mutex types
|
|---|
| 28 | enum{
|
|---|
| 29 | PTHREAD_MUTEX_NORMAL,
|
|---|
| 30 | PTHREAD_MUTEX_RECURSIVE,
|
|---|
| 31 | PTHREAD_MUTEX_ERRORCHECK
|
|---|
| 32 | };
|
|---|
| 33 |
|
|---|
| 34 | enum{
|
|---|
| 35 | PTHREAD_MUTEX_STALLED,
|
|---|
| 36 | PTHREAD_MUTEX_ROBUST
|
|---|
| 37 | };
|
|---|
| 38 |
|
|---|
| 39 | enum{
|
|---|
| 40 | PTHREAD_CREATE_JOINABLE,
|
|---|
| 41 | PTHREAD_CREATE_DETACHED
|
|---|
| 42 | };
|
|---|
| 43 |
|
|---|
| 44 | enum{
|
|---|
| 45 | PTHREAD_SCOPE_SYSTEM,
|
|---|
| 46 | PTHREAD_SCOPE_PROCESS
|
|---|
| 47 | };
|
|---|
| 48 |
|
|---|
| 49 | enum{
|
|---|
| 50 | PTHREAD_INHERIT_SCHED,
|
|---|
| 51 | PTHREAD_EXPLICIT_SCHED
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | enum{
|
|---|
| 55 | PTHREAD_PROCESS_SHARED,
|
|---|
| 56 | PTHREAD_PROCESS_PRIVATE,
|
|---|
| 57 | };
|
|---|
| 58 |
|
|---|
| 59 | enum{
|
|---|
| 60 | PTHREAD_BARRIER_SERIAL_THREAD
|
|---|
| 61 | };
|
|---|
| 62 |
|
|---|
| 63 | //Error definitions
|
|---|
| 64 | enum{
|
|---|
| 65 | EINVAL, //Designates an invalid value
|
|---|
| 66 | ENOTSUP,
|
|---|
| 67 | EOWNERDEAD, //Designates the termination of the owning thread
|
|---|
| 68 | EBUSY, //Mutex is already locked
|
|---|
| 69 | EDEADLK, //If mutex type is errorcheck and already owns the mutex
|
|---|
| 70 | EPERM, //If mutex is robust or errorcheck and does not own the mutex
|
|---|
| 71 | ERSCH
|
|---|
| 72 | };
|
|---|
| 73 |
|
|---|
| 74 | typedef struct pthread_mutexattr_t pthread_mutexattr_t;
|
|---|
| 75 | typedef struct pthread_mutex_t pthread_mutex_t;
|
|---|
| 76 | typedef struct pthread_barrierattr_t pthread_barrierattr_t;
|
|---|
| 77 | typedef struct pthread_barrier_t pthread_barrier_t;
|
|---|
| 78 | typedef struct pthread_spinlock_t pthread_spinlock_t;
|
|---|
| 79 | //typedef struct pthread_attr_t pthread_attr_t;
|
|---|
| 80 | typedef struct pthread_rwlockattr_t pthread_rwlockattr_t;
|
|---|
| 81 | typedef struct pthread_rwlock_t pthread_rwlock_t;
|
|---|
| 82 | typedef struct pthread_cond_t pthread_cond_t;
|
|---|
| 83 | typedef int pthread_condattr_t;
|
|---|
| 84 | //typedef struct pthread_t pthread_t;
|
|---|
| 85 |
|
|---|
| 86 | extern pthread_mutex_t PTHREAD_MUTEX_INITIALIZER;// {0,$proc_null,0,0,{0,0,0,PTHREAD_MUTEX_NORMAL,0}}
|
|---|
| 87 |
|
|---|
| 88 | // Function Prototypes
|
|---|
| 89 | int pthread_attr_destroy(pthread_attr_t *);
|
|---|
| 90 | int pthread_attr_setdetachstate(pthread_attr_t *, int);
|
|---|
| 91 | int pthread_attr_getdetachstate(const pthread_attr_t *, int *);
|
|---|
| 92 | int pthread_attr_init(pthread_attr_t *);
|
|---|
| 93 | int pthread_spin_init(pthread_spinlock_t *, int);
|
|---|
| 94 | int pthread_spin_destroy(pthread_spinlock_t *);
|
|---|
| 95 | int pthread_spin_lock(pthread_spinlock_t *);
|
|---|
| 96 | int pthread_spin_unlock(pthread_spinlock_t *);
|
|---|
| 97 | int pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *);
|
|---|
| 98 | int pthread_rwlock_destroy(pthread_rwlock_t *);
|
|---|
| 99 | int pthread_rwlock_rdlock(pthread_rwlock_t *);
|
|---|
| 100 | int pthread_rwlock_wrlock(pthread_rwlock_t *);
|
|---|
| 101 | int pthread_rwlock_unlock(pthread_rwlock_t *);
|
|---|
| 102 | int pthread_barrierattr_init(pthread_barrierattr_t *);
|
|---|
| 103 | int pthread_barrierattr_destroy(pthread_barrierattr_t *);
|
|---|
| 104 | int pthread_barrier_init(pthread_barrier_t *, const pthread_barrierattr_t *, int);
|
|---|
| 105 | int pthread_barrier_destroy(pthread_barrier_t *);
|
|---|
| 106 | int pthread_barrier_wait(pthread_barrier_t *);
|
|---|
| 107 | int pthread_mutexattr_init(pthread_mutexattr_t *);
|
|---|
| 108 | int pthread_mutexattr_destroy(pthread_mutexattr_t *);
|
|---|
| 109 | int pthread_mutexattr_getrobust(const pthread_mutexattr_t *, int *);
|
|---|
| 110 | int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int);
|
|---|
| 111 | int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *);
|
|---|
| 112 | int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int);
|
|---|
| 113 | int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *, int *);
|
|---|
| 114 | int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int);
|
|---|
| 115 | int pthread_mutexattr_gettype(const pthread_mutexattr_t *, int *);
|
|---|
| 116 | int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
|
|---|
| 117 | int pthread_mutexattr_getprioceiling(const pthread_mutexattr_t *, int *);
|
|---|
| 118 | int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int);
|
|---|
| 119 | int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *);
|
|---|
| 120 | int pthread_mutex_destroy(pthread_mutex_t *);
|
|---|
| 121 | int pthread_cond_init(pthread_cond_t * restrict, const pthread_condattr_t * restrict);
|
|---|
| 122 | int pthread_cond_destroy(pthread_cond_t *);
|
|---|
| 123 | int pthread_equal(pthread_t, pthread_t);
|
|---|
| 124 | int pthread_create(pthread_t *, const pthread_attr_t *, void *(*)(void*), void *);
|
|---|
| 125 | int pthread_join(pthread_t, void **);
|
|---|
| 126 | void pthread_exit(void *);
|
|---|
| 127 | int pthread_mutex_lock(pthread_mutex_t *);
|
|---|
| 128 | int pthread_mutex_trylock(pthread_mutex_t *);
|
|---|
| 129 | int pthread_mutex_unlock(pthread_mutex_t *);
|
|---|
| 130 | int pthread_mutex_consistent(pthread_mutex_t *);
|
|---|
| 131 | int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
|
|---|
| 132 | int pthread_cond_signal(pthread_cond_t *);
|
|---|
| 133 | int pthread_cond_broadcast(pthread_cond_t *);
|
|---|
| 134 | pthread_t pthread_self(void);
|
|---|
| 135 |
|
|---|
| 136 |
|
|---|
| 137 | // function declarations needed for transformer:
|
|---|
| 138 | void $pthread_exit_main(void *value_ptr, $pthread_pool_t $pthread_pool);
|
|---|
| 139 |
|
|---|
| 140 | pthread_t $pthread_self($pthread_pool_t pool);
|
|---|
| 141 |
|
|---|
| 142 | int $pthread_mutex_lock(pthread_mutex_t *mutex, $pthread_pool_t $pthread_pool);
|
|---|
| 143 |
|
|---|
| 144 | int $pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex, $pthread_pool_t $pthread_pool);
|
|---|
| 145 |
|
|---|
| 146 | #endif
|
|---|