update api tests with options
[libc-test] / src / api / pthread.c
1 #include <pthread.h>
2 #define T(t) (t*)0;
3 #define C(n) switch(n){case n:;}
4 static void f()
5 {
6 T(pthread_attr_t)
7 T(pthread_barrier_t)
8 T(pthread_barrierattr_t)
9 T(pthread_cond_t)
10 T(pthread_condattr_t)
11 T(pthread_key_t)
12 T(pthread_mutex_t)
13 T(pthread_mutexattr_t)
14 T(pthread_once_t)
15 T(pthread_rwlock_t)
16 T(pthread_rwlockattr_t)
17 T(pthread_spinlock_t)
18 T(pthread_t)
19 C(PTHREAD_BARRIER_SERIAL_THREAD)
20 C(PTHREAD_CANCEL_ASYNCHRONOUS)
21 C(PTHREAD_CANCEL_ENABLE)
22 C(PTHREAD_CANCEL_DEFERRED)
23 C(PTHREAD_CANCEL_DISABLE)
24 {void *x = PTHREAD_CANCELED;}
25 C(PTHREAD_CREATE_DETACHED)
26 C(PTHREAD_CREATE_JOINABLE)
27 C(PTHREAD_MUTEX_DEFAULT)
28 C(PTHREAD_MUTEX_ERRORCHECK)
29 C(PTHREAD_MUTEX_NORMAL)
30 C(PTHREAD_MUTEX_RECURSIVE)
31 C(PTHREAD_MUTEX_ROBUST)
32 C(PTHREAD_MUTEX_STALLED)
33 C(PTHREAD_ONCE_INIT)
34 #if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT)
35 C(PTHREAD_PRIO_INHERIT)
36 #endif
37 #if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT) \
38  || defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
39 C(PTHREAD_PRIO_NONE)
40 #endif
41 #if defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
42 C(PTHREAD_PRIO_PROTECT)
43 #endif
44 C(PTHREAD_PROCESS_SHARED)
45 C(PTHREAD_PROCESS_PRIVATE)
46 #ifdef POSIX_THREAD_PRIORITY_SCHEDULING
47 C(PTHREAD_EXPLICIT_SCHED)
48 C(PTHREAD_INHERIT_SCHED)
49 C(PTHREAD_SCOPE_PROCESS)
50 C(PTHREAD_SCOPE_SYSTEM)
51 #endif
52 {pthread_cond_t x = PTHREAD_COND_INITIALIZER;}
53 {pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;}
54 {pthread_rwlock_t x = PTHREAD_RWLOCK_INITIALIZER;}
55 {int(*p)(void(*)(void),void(*)(void),void(*)(void)) = pthread_atfork;}
56 {int(*p)(pthread_attr_t*) = pthread_attr_destroy;}
57 {int(*p)(const pthread_attr_t*,int*) = pthread_attr_getdetachstate;}
58 {int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getguardsize;}
59 {int(*p)(const pthread_attr_t*restrict,struct sched_param*restrict) = pthread_attr_getschedparam;}
60 {int(*p)(const pthread_attr_t*restrict,void**restrict,size_t*restrict) = pthread_attr_getstack;}
61 {int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getstacksize;}
62 {int(*p)(pthread_attr_t*) = pthread_attr_init;}
63 {int(*p)(pthread_attr_t*,int) = pthread_attr_setdetachstate;}
64 {int(*p)(pthread_attr_t*,size_t) = pthread_attr_setguardsize;}
65 {int(*p)(pthread_attr_t*restrict,const struct sched_param*restrict) = pthread_attr_setschedparam;}
66 {int(*p)(pthread_attr_t*,void*,size_t) = pthread_attr_setstack;}
67 {int(*p)(pthread_attr_t*,size_t) = pthread_attr_setstacksize;}
68 {int(*p)(pthread_barrier_t*) = pthread_barrier_destroy;}
69 {int(*p)(pthread_barrier_t*restrict,const pthread_barrierattr_t*restrict,unsigned) = pthread_barrier_init;}
70 {int(*p)(pthread_barrier_t*) = pthread_barrier_wait;}
71 {int(*p)(pthread_barrierattr_t*) = pthread_barrierattr_destroy;}
72 {int(*p)(const pthread_barrierattr_t*restrict,int*restrict) = pthread_barrierattr_getpshared;}
73 {int(*p)(pthread_barrierattr_t*) = pthread_barrierattr_init;}
74 {int(*p)(pthread_barrierattr_t*,int) = pthread_barrierattr_setpshared;}
75 {int(*p)(pthread_t) = pthread_cancel;}
76 #ifndef pthread_cleanup_pop
77 {void(*p)(int) = pthread_cleanup_pop;}
78 #endif
79 #ifndef pthread_cleanup_push
80 {void(*p)(void(*)(void*),void*) = pthread_cleanup_push;}
81 #endif
82 {int(*p)(pthread_cond_t*) = pthread_cond_broadcast;}
83 {int(*p)(pthread_cond_t*) = pthread_cond_destroy;}
84 {int(*p)(pthread_cond_t*restrict,const pthread_condattr_t*restrict) = pthread_cond_init;}
85 {int(*p)(pthread_cond_t*) = pthread_cond_signal;}
86 {int(*p)(pthread_cond_t*restrict,pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_cond_timedwait;}
87 {int(*p)(pthread_cond_t*restrict,pthread_mutex_t*restrict) = pthread_cond_wait;}
88 {int(*p)(pthread_condattr_t*) = pthread_condattr_destroy;}
89 {int(*p)(const pthread_condattr_t*restrict,clockid_t*restrict) = pthread_condattr_getclock;}
90 {int(*p)(const pthread_condattr_t*restrict,int*restrict) = pthread_condattr_getpshared;}
91 {int(*p)(pthread_condattr_t*) = pthread_condattr_init;}
92 {int(*p)(pthread_condattr_t*,clockid_t) = pthread_condattr_setclock;}
93 {int(*p)(pthread_condattr_t*,int) = pthread_condattr_setpshared;}
94 {int(*p)(pthread_t*restrict,const pthread_attr_t*restrict,void*(*)(void*),void*restrict) = pthread_create;}
95 {int(*p)(pthread_t) = pthread_detach;}
96 {int(*p)(pthread_t,pthread_t) = pthread_equal;}
97 {void(*p)(void*) = pthread_exit;}
98 {void*(*p)(pthread_key_t) = pthread_getspecific;}
99 {int(*p)(pthread_t,void**) = pthread_join;}
100 {int(*p)(pthread_key_t*,void(*)(void*)) = pthread_key_create;}
101 {int(*p)(pthread_key_t) = pthread_key_delete;}
102 {int(*p)(pthread_mutex_t*) = pthread_mutex_consistent;}
103 {int(*p)(pthread_mutex_t*) = pthread_mutex_destroy;}
104 {int(*p)(pthread_mutex_t*restrict,const pthread_mutexattr_t*restrict) = pthread_mutex_init;}
105 {int(*p)(pthread_mutex_t*) = pthread_mutex_lock;}
106 {int(*p)(pthread_mutex_t*) = pthread_mutex_trylock;}
107 {int(*p)(pthread_mutex_t*) = pthread_mutex_unlock;}
108 {int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_destroy;}
109 #if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT) \
110  || defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
111 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprotocol;}
112 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprotocol;}
113 #endif
114 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getpshared;}
115 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getrobust;}
116 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_gettype;}
117 {int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_init;}
118 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setpshared;}
119 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setrobust;}
120 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_settype;}
121 {int(*p)(pthread_once_t*,void(*)(void)) = pthread_once;}
122 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_destroy;}
123 {int(*p)(pthread_rwlock_t*restrict,const pthread_rwlockattr_t*restrict) = pthread_rwlock_init;}
124 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_rdlock;}
125 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_tryrdlock;}
126 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_trywrlock;}
127 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_unlock;}
128 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_wrlock;}
129 {int(*p)(pthread_rwlockattr_t*) = pthread_rwlockattr_destroy;}
130 {int(*p)(const pthread_rwlockattr_t*restrict,int*restrict) = pthread_rwlockattr_getpshared;}
131 {int(*p)(pthread_rwlockattr_t*) = pthread_rwlockattr_init;}
132 {int(*p)(pthread_rwlockattr_t*,int) = pthread_rwlockattr_setpshared;}
133 {pthread_t(*p)(void) = pthread_self;}
134 {int(*p)(int,int*) = pthread_setcancelstate;}
135 {int(*p)(int,int*) = pthread_setcanceltype;}
136 {int(*p)(pthread_t,int) = pthread_setschedprio;}
137 {int(*p)(pthread_key_t,const void*) = pthread_setspecific;}
138 {int(*p)(pthread_spinlock_t*) = pthread_spin_destroy;}
139 {int(*p)(pthread_spinlock_t*,int) = pthread_spin_init;}
140 {int(*p)(pthread_spinlock_t*) = pthread_spin_lock;}
141 {int(*p)(pthread_spinlock_t*) = pthread_spin_trylock;}
142 {int(*p)(pthread_spinlock_t*) = pthread_spin_unlock;}
143 {void(*p)(void) = pthread_testcancel;}
144 #if defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
145 {int(*p)(const pthread_mutex_t*restrict,int*restrict) = pthread_mutex_getprioceiling;}
146 {int(*p)(pthread_mutex_t*restrict,int,int*restrict) = pthread_mutex_setprioceiling;}
147 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprioceiling;}
148 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprioceiling;}
149 #endif
150 #ifdef POSIX_THREAD_PRIORITY_SCHEDULING
151 {int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getinheritsched;}
152 {int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getschedpolicy;}
153 {int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getscope;}
154 {int(*p)(pthread_attr_t*,int) = pthread_attr_setinheritsched;}
155 {int(*p)(pthread_attr_t*,int) = pthread_attr_setschedpolicy;}
156 {int(*p)(pthread_attr_t*,int) = pthread_attr_setscope;}
157 {int(*p)(pthread_t,int*restrict,struct sched_param*restrict) = pthread_getschedparam;}
158 {int(*p)(pthread_t,int,const struct sched_param*) = pthread_setschedparam;}
159 #endif
160 }
161 #include <time.h>
162 static void g()
163 {
164 {int(*p)(pthread_t,clockid_t*) = pthread_getcpuclockid;}
165 {int(*p)(pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_mutex_timedlock;}
166 {int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedrdlock;}
167 {int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedwrlock;}
168 }