minor cleanups
[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 C(PTHREAD_PRIO_INHERIT)
35 C(PTHREAD_PRIO_NONE)
36 #ifdef X_RPP_TPP
37 C(PTHREAD_PRIO_PROTECT)
38 #endif
39 C(PTHREAD_PROCESS_SHARED)
40 C(PTHREAD_PROCESS_PRIVATE)
41 #ifdef X_TPS
42 C(PTHREAD_EXPLICIT_SCHED)
43 C(PTHREAD_INHERIT_SCHED)
44 C(PTHREAD_SCOPE_PROCESS)
45 C(PTHREAD_SCOPE_SYSTEM)
46 #endif
47 {pthread_cond_t x = PTHREAD_COND_INITIALIZER;}
48 {pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;}
49 {pthread_rwlock_t x = PTHREAD_RWLOCK_INITIALIZER;}
50 {int(*p)(void(*)(void),void(*)(void),void(*)(void)) = pthread_atfork;}
51 {int(*p)(pthread_attr_t*) = pthread_attr_destroy;}
52 {int(*p)(const pthread_attr_t*,int*) = pthread_attr_getdetachstate;}
53 {int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getguardsize;}
54 {int(*p)(const pthread_attr_t*restrict,struct sched_param*restrict) = pthread_attr_getschedparam;}
55 {int(*p)(const pthread_attr_t*restrict,void**restrict,size_t*restrict) = pthread_attr_getstack;}
56 {int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getstacksize;}
57 {int(*p)(pthread_attr_t*) = pthread_attr_init;}
58 {int(*p)(pthread_attr_t*,int) = pthread_attr_setdetachstate;}
59 {int(*p)(pthread_attr_t*,size_t) = pthread_attr_setguardsize;}
60 {int(*p)(pthread_attr_t*restrict,const struct sched_param*restrict) = pthread_attr_setschedparam;}
61 {int(*p)(pthread_attr_t*,void*,size_t) = pthread_attr_setstack;}
62 {int(*p)(pthread_attr_t*,size_t) = pthread_attr_setstacksize;}
63 {int(*p)(pthread_barrier_t*) = pthread_barrier_destroy;}
64 {int(*p)(pthread_barrier_t*restrict,const pthread_barrierattr_t*restrict,unsigned) = pthread_barrier_init;}
65 {int(*p)(pthread_barrier_t*) = pthread_barrier_wait;}
66 {int(*p)(pthread_barrierattr_t*) = pthread_barrierattr_destroy;}
67 {int(*p)(const pthread_barrierattr_t*restrict,int*restrict) = pthread_barrierattr_getpshared;}
68 {int(*p)(pthread_barrierattr_t*) = pthread_barrierattr_init;}
69 {int(*p)(pthread_barrierattr_t*,int) = pthread_barrierattr_setpshared;}
70 {int(*p)(pthread_t) = pthread_cancel;}
71 #ifndef pthread_cleanup_pop
72 {void(*p)(int) = pthread_cleanup_pop;}
73 #endif
74 #ifndef pthread_cleanup_push
75 {void(*p)(void(*)(void*),void*) = pthread_cleanup_push;}
76 #endif
77 {int(*p)(pthread_cond_t*) = pthread_cond_broadcast;}
78 {int(*p)(pthread_cond_t*) = pthread_cond_destroy;}
79 {int(*p)(pthread_cond_t*restrict,const pthread_condattr_t*restrict) = pthread_cond_init;}
80 {int(*p)(pthread_cond_t*) = pthread_cond_signal;}
81 {int(*p)(pthread_cond_t*restrict,pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_cond_timedwait;}
82 {int(*p)(pthread_cond_t*restrict,pthread_mutex_t*restrict) = pthread_cond_wait;}
83 {int(*p)(pthread_condattr_t*) = pthread_condattr_destroy;}
84 {int(*p)(const pthread_condattr_t*restrict,clockid_t*restrict) = pthread_condattr_getclock;}
85 {int(*p)(const pthread_condattr_t*restrict,int*restrict) = pthread_condattr_getpshared;}
86 {int(*p)(pthread_condattr_t*) = pthread_condattr_init;}
87 {int(*p)(pthread_condattr_t*,clockid_t) = pthread_condattr_setclock;}
88 {int(*p)(pthread_condattr_t*,int) = pthread_condattr_setpshared;}
89 {int(*p)(pthread_t*restrict,const pthread_attr_t*restrict,void*(*)(void*),void*restrict) = pthread_create;}
90 {int(*p)(pthread_t) = pthread_detach;}
91 {int(*p)(pthread_t,pthread_t) = pthread_equal;}
92 {void(*p)(void*) = pthread_exit;}
93 {void*(*p)(pthread_key_t) = pthread_getspecific;}
94 {int(*p)(pthread_t,void**) = pthread_join;}
95 {int(*p)(pthread_key_t*,void(*)(void*)) = pthread_key_create;}
96 {int(*p)(pthread_key_t) = pthread_key_delete;}
97 {int(*p)(pthread_mutex_t*) = pthread_mutex_consistent;}
98 {int(*p)(pthread_mutex_t*) = pthread_mutex_destroy;}
99 {int(*p)(pthread_mutex_t*restrict,const pthread_mutexattr_t*restrict) = pthread_mutex_init;}
100 {int(*p)(pthread_mutex_t*) = pthread_mutex_lock;}
101 {int(*p)(pthread_mutex_t*) = pthread_mutex_trylock;}
102 {int(*p)(pthread_mutex_t*) = pthread_mutex_unlock;}
103 {int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_destroy;}
104 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprotocol;}
105 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getpshared;}
106 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getrobust;}
107 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_gettype;}
108 {int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_init;}
109 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprotocol;}
110 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setpshared;}
111 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setrobust;}
112 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_settype;}
113 {int(*p)(pthread_once_t*,void(*)(void)) = pthread_once;}
114 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_destroy;}
115 {int(*p)(pthread_rwlock_t*restrict,const pthread_rwlockattr_t*restrict) = pthread_rwlock_init;}
116 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_rdlock;}
117 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_tryrdlock;}
118 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_trywrlock;}
119 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_unlock;}
120 {int(*p)(pthread_rwlock_t*) = pthread_rwlock_wrlock;}
121 {int(*p)(pthread_rwlockattr_t*) = pthread_rwlockattr_destroy;}
122 {int(*p)(const pthread_rwlockattr_t*restrict,int*restrict) = pthread_rwlockattr_getpshared;}
123 {int(*p)(pthread_rwlockattr_t*) = pthread_rwlockattr_init;}
124 {int(*p)(pthread_rwlockattr_t*,int) = pthread_rwlockattr_setpshared;}
125 {pthread_t(*p)(void) = pthread_self;}
126 {int(*p)(int,int*) = pthread_setcancelstate;}
127 {int(*p)(int,int*) = pthread_setcanceltype;}
128 {int(*p)(pthread_t,int) = pthread_setschedprio;}
129 {int(*p)(pthread_key_t,const void*) = pthread_setspecific;}
130 {int(*p)(pthread_spinlock_t*) = pthread_spin_destroy;}
131 {int(*p)(pthread_spinlock_t*,int) = pthread_spin_init;}
132 {int(*p)(pthread_spinlock_t*) = pthread_spin_lock;}
133 {int(*p)(pthread_spinlock_t*) = pthread_spin_trylock;}
134 {int(*p)(pthread_spinlock_t*) = pthread_spin_unlock;}
135 {void(*p)(void) = pthread_testcancel;}
136
137 #ifdef X_RPP_TPP
138 {int(*p)(const pthread_mutex_t*restrict,int*restrict) = pthread_mutex_getprioceiling;}
139 {int(*p)(pthread_mutex_t*restrict,int,int*restrict) = pthread_mutex_setprioceiling;}
140 {int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprioceiling;}
141 {int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprioceiling;}
142 #endif
143
144 #ifdef X_TPS
145 {int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getinheritsched;}
146 {int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getschedpolicy;}
147 {int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getscope;}
148 {int(*p)(pthread_attr_t*,int) = pthread_attr_setinheritsched;}
149 {int(*p)(pthread_attr_t*,int) = pthread_attr_setschedpolicy;}
150 {int(*p)(pthread_attr_t*,int) = pthread_attr_setscope;}
151 {int(*p)(pthread_t,int*restrict,struct sched_param*restrict) = pthread_getschedparam;}
152 {int(*p)(pthread_t,int,const struct sched_param*) = pthread_setschedparam;}
153 #endif
154 }
155 #include <time.h>
156 static void g()
157 {
158 {int(*p)(pthread_t,clockid_t*) = pthread_getcpuclockid;}
159 {int(*p)(pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_mutex_timedlock;}
160 {int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedrdlock;}
161 {int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedwrlock;}
162 }