xref: /third_party/musl/libc-test/src/api/pthread.c (revision 570af302)
1#include <pthread.h>
2#define T(t) (t*)0;
3#define C(n) switch(n){case n:;}
4static void f()
5{
6T(pthread_attr_t)
7T(pthread_barrier_t)
8T(pthread_barrierattr_t)
9T(pthread_cond_t)
10T(pthread_condattr_t)
11T(pthread_key_t)
12T(pthread_mutex_t)
13T(pthread_mutexattr_t)
14T(pthread_once_t)
15T(pthread_rwlock_t)
16T(pthread_rwlockattr_t)
17T(pthread_spinlock_t)
18T(pthread_t)
19C(PTHREAD_BARRIER_SERIAL_THREAD)
20C(PTHREAD_CANCEL_ASYNCHRONOUS)
21C(PTHREAD_CANCEL_ENABLE)
22C(PTHREAD_CANCEL_DEFERRED)
23C(PTHREAD_CANCEL_DISABLE)
24{void *x = PTHREAD_CANCELED;}
25C(PTHREAD_CREATE_DETACHED)
26C(PTHREAD_CREATE_JOINABLE)
27C(PTHREAD_MUTEX_DEFAULT)
28C(PTHREAD_MUTEX_ERRORCHECK)
29C(PTHREAD_MUTEX_NORMAL)
30C(PTHREAD_MUTEX_RECURSIVE)
31C(PTHREAD_MUTEX_ROBUST)
32C(PTHREAD_MUTEX_STALLED)
33C(PTHREAD_ONCE_INIT)
34#if defined(POSIX_THREAD_ROBUST_PRIO_INHERIT) || defined(POSIX_THREAD_PRIO_INHERIT)
35C(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)
39C(PTHREAD_PRIO_NONE)
40#endif
41#if defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
42C(PTHREAD_PRIO_PROTECT)
43#endif
44C(PTHREAD_PROCESS_SHARED)
45C(PTHREAD_PROCESS_PRIVATE)
46#ifdef POSIX_THREAD_PRIORITY_SCHEDULING
47C(PTHREAD_EXPLICIT_SCHED)
48C(PTHREAD_INHERIT_SCHED)
49C(PTHREAD_SCOPE_PROCESS)
50C(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#if defined _XOPEN_SOURCE && defined OBSOLETE
137{int(*p)(void) = pthread_getconcurrency;}
138{int(*p)(int) = pthread_setconcurrency;}
139#endif
140{int(*p)(pthread_t,int) = pthread_setschedprio;}
141{int(*p)(pthread_key_t,const void*) = pthread_setspecific;}
142{int(*p)(pthread_spinlock_t*) = pthread_spin_destroy;}
143{int(*p)(pthread_spinlock_t*,int) = pthread_spin_init;}
144{int(*p)(pthread_spinlock_t*) = pthread_spin_lock;}
145{int(*p)(pthread_spinlock_t*) = pthread_spin_trylock;}
146{int(*p)(pthread_spinlock_t*) = pthread_spin_unlock;}
147{void(*p)(void) = pthread_testcancel;}
148#if defined(POSIX_THREAD_ROBUST_PRIO_PROTECT) || defined(POSIX_THREAD_PRIO_PROTECT)
149{int(*p)(const pthread_mutex_t*restrict,int*restrict) = pthread_mutex_getprioceiling;}
150{int(*p)(pthread_mutex_t*restrict,int,int*restrict) = pthread_mutex_setprioceiling;}
151{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprioceiling;}
152{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprioceiling;}
153#endif
154#ifdef POSIX_THREAD_PRIORITY_SCHEDULING
155{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getinheritsched;}
156{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getschedpolicy;}
157{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getscope;}
158{int(*p)(pthread_attr_t*,int) = pthread_attr_setinheritsched;}
159{int(*p)(pthread_attr_t*,int) = pthread_attr_setschedpolicy;}
160{int(*p)(pthread_attr_t*,int) = pthread_attr_setscope;}
161{int(*p)(pthread_t,int*restrict,struct sched_param*restrict) = pthread_getschedparam;}
162{int(*p)(pthread_t,int,const struct sched_param*) = pthread_setschedparam;}
163#endif
164}
165#include <time.h>
166static void g()
167{
168{int(*p)(pthread_t,clockid_t*) = pthread_getcpuclockid;}
169{int(*p)(pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_mutex_timedlock;}
170{int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedrdlock;}
171{int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedwrlock;}
172}
173