f28d19c312db0f56a1da0aaef38db8b7e48ec9fa
[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_EXPLICIT_SCHED)
28 C(PTHREAD_INHERIT_SCHED)
29 C(PTHREAD_MUTEX_DEFAULT)
30 C(PTHREAD_MUTEX_ERRORCHECK)
31 C(PTHREAD_MUTEX_NORMAL)
32 C(PTHREAD_MUTEX_RECURSIVE)
33 C(PTHREAD_MUTEX_ROBUST)
34 C(PTHREAD_MUTEX_STALLED)
35 C(PTHREAD_ONCE_INIT)
36 C(PTHREAD_PRIO_INHERIT)
37 C(PTHREAD_PRIO_NONE)
38 C(PTHREAD_PRIO_PROTECT)
39 C(PTHREAD_PROCESS_SHARED)
40 C(PTHREAD_PROCESS_PRIVATE)
41 C(PTHREAD_SCOPE_PROCESS)
42 C(PTHREAD_SCOPE_SYSTEM)
43 {pthread_cond_t x = PTHREAD_COND_INITIALIZER;}
44 {pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;}
45 {pthread_rwlock_t x = PTHREAD_RWLOCK_INITIALIZER;}
46 int(*p_pthread_atfork)(void(*)(void),void(*)(void),void(*)(void)) = pthread_atfork;
47 int(*p_pthread_attr_destroy)(pthread_attr_t*) = pthread_attr_destroy;
48 int(*p_pthread_attr_getdetachstate)(const pthread_attr_t*,int*) = pthread_attr_getdetachstate;
49 int(*p_pthread_attr_getguardsize)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getguardsize;
50 int(*p_pthread_attr_getinheritsched)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getinheritsched;
51 int(*p_pthread_attr_getschedparam)(const pthread_attr_t*restrict,struct sched_param*restrict) = pthread_attr_getschedparam;
52 int(*p_pthread_attr_getschedpolicy)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getschedpolicy;
53 int(*p_pthread_attr_getscope)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getscope;
54 int(*p_pthread_attr_getstack)(const pthread_attr_t*restrict,void**restrict,size_t*restrict) = pthread_attr_getstack;
55 int(*p_pthread_attr_getstacksize)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getstacksize;
56 int(*p_pthread_attr_init)(pthread_attr_t*) = pthread_attr_init;
57 int(*p_pthread_attr_setdetachstate)(pthread_attr_t*,int) = pthread_attr_setdetachstate;
58 int(*p_pthread_attr_setguardsize)(pthread_attr_t*,size_t) = pthread_attr_setguardsize;
59 int(*p_pthread_attr_setinheritsched)(pthread_attr_t*,int) = pthread_attr_setinheritsched;
60 int(*p_pthread_attr_setschedparam)(pthread_attr_t*restrict,const struct sched_param*restrict) = pthread_attr_setschedparam;
61 int(*p_pthread_attr_setschedpolicy)(pthread_attr_t*,int) = pthread_attr_setschedpolicy;
62 int(*p_pthread_attr_setscope)(pthread_attr_t*,int) = pthread_attr_setscope;
63 int(*p_pthread_attr_setstack)(pthread_attr_t*,void*,size_t) = pthread_attr_setstack;
64 int(*p_pthread_attr_setstacksize)(pthread_attr_t*,size_t) = pthread_attr_setstacksize;
65 int(*p_pthread_barrier_destroy)(pthread_barrier_t*) = pthread_barrier_destroy;
66 int(*p_pthread_barrier_init)(pthread_barrier_t*restrict,const pthread_barrierattr_t*restrict,unsigned) = pthread_barrier_init;
67 int(*p_pthread_barrier_wait)(pthread_barrier_t*) = pthread_barrier_wait;
68 int(*p_pthread_barrierattr_destroy)(pthread_barrierattr_t*) = pthread_barrierattr_destroy;
69 int(*p_pthread_barrierattr_getpshared)(const pthread_barrierattr_t*restrict,int*restrict) = pthread_barrierattr_getpshared;
70 int(*p_pthread_barrierattr_init)(pthread_barrierattr_t*) = pthread_barrierattr_init;
71 int(*p_pthread_barrierattr_setpshared)(pthread_barrierattr_t*,int) = pthread_barrierattr_setpshared;
72 int(*p_pthread_cancel)(pthread_t) = pthread_cancel;
73 void(*p_pthread_cleanup_pop)(int) = pthread_cleanup_pop;
74 void(*p_pthread_cleanup_push)(void(*)(void*),void*) = pthread_cleanup_push;
75 int(*p_pthread_cond_broadcast)(pthread_cond_t*) = pthread_cond_broadcast;
76 int(*p_pthread_cond_destroy)(pthread_cond_t*) = pthread_cond_destroy;
77 int(*p_pthread_cond_init)(pthread_cond_t*restrict,const pthread_condattr_t*restrict) = pthread_cond_init;
78 int(*p_pthread_cond_signal)(pthread_cond_t*) = pthread_cond_signal;
79 int(*p_pthread_cond_timedwait)(pthread_cond_t*restrict,pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_cond_timedwait;
80 int(*p_pthread_cond_wait)(pthread_cond_t*restrict,pthread_mutex_t*restrict) = pthread_cond_wait;
81 int(*p_pthread_condattr_destroy)(pthread_condattr_t*) = pthread_condattr_destroy;
82 int(*p_pthread_condattr_getclock)(const pthread_condattr_t*restrict,clockid_t*restrict) = pthread_condattr_getclock;
83 int(*p_pthread_condattr_getpshared)(const pthread_condattr_t*restrict,int*restrict) = pthread_condattr_getpshared;
84 int(*p_pthread_condattr_init)(pthread_condattr_t*) = pthread_condattr_init;
85 int(*p_pthread_condattr_setclock)(pthread_condattr_t*,clockid_t) = pthread_condattr_setclock;
86 int(*p_pthread_condattr_setpshared)(pthread_condattr_t*,int) = pthread_condattr_setpshared;
87 int(*p_pthread_create)(pthread_t*restrict,const pthread_attr_t*restrict,void*(*)(void*),void*restrict) = pthread_create;
88 int(*p_pthread_detach)(pthread_t) = pthread_detach;
89 int(*p_pthread_equal)(pthread_t,pthread_t) = pthread_equal;
90 void(*p_pthread_exit)(void*) = pthread_exit;
91 int(*p_pthread_getschedparam)(pthread_t,int*restrict,struct sched_param*restrict) = pthread_getschedparam;
92 void*(*p_pthread_getspecific)(pthread_key_t) = pthread_getspecific;
93 int(*p_pthread_join)(pthread_t,void**) = pthread_join;
94 int(*p_pthread_key_create)(pthread_key_t*,void(*)(void*)) = pthread_key_create;
95 int(*p_pthread_key_delete)(pthread_key_t) = pthread_key_delete;
96 int(*p_pthread_mutex_consistent)(pthread_mutex_t*) = pthread_mutex_consistent;
97 int(*p_pthread_mutex_destroy)(pthread_mutex_t*) = pthread_mutex_destroy;
98 int(*p_pthread_mutex_getprioceiling)(const pthread_mutex_t*restrict,int*restrict) = pthread_mutex_getprioceiling;
99 int(*p_pthread_mutex_init)(pthread_mutex_t*restrict,const pthread_mutexattr_t*restrict) = pthread_mutex_init;
100 int(*p_pthread_mutex_lock)(pthread_mutex_t*) = pthread_mutex_lock;
101 int(*p_pthread_mutex_setprioceiling)(pthread_mutex_t*restrict,int,int*restrict) = pthread_mutex_setprioceiling;
102 int(*p_pthread_mutex_trylock)(pthread_mutex_t*) = pthread_mutex_trylock;
103 int(*p_pthread_mutex_unlock)(pthread_mutex_t*) = pthread_mutex_unlock;
104 int(*p_pthread_mutexattr_destroy)(pthread_mutexattr_t*) = pthread_mutexattr_destroy;
105 int(*p_pthread_mutexattr_getprioceiling)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprioceiling;
106 int(*p_pthread_mutexattr_getprotocol)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprotocol;
107 int(*p_pthread_mutexattr_getpshared)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getpshared;
108 int(*p_pthread_mutexattr_getrobust)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getrobust;
109 int(*p_pthread_mutexattr_gettype)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_gettype;
110 int(*p_pthread_mutexattr_init)(pthread_mutexattr_t*) = pthread_mutexattr_init;
111 int(*p_pthread_mutexattr_setprioceiling)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprioceiling;
112 int(*p_pthread_mutexattr_setprotocol)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprotocol;
113 int(*p_pthread_mutexattr_setpshared)(pthread_mutexattr_t*,int) = pthread_mutexattr_setpshared;
114 int(*p_pthread_mutexattr_setrobust)(pthread_mutexattr_t*,int) = pthread_mutexattr_setrobust;
115 int(*p_pthread_mutexattr_settype)(pthread_mutexattr_t*,int) = pthread_mutexattr_settype;
116 int(*p_pthread_once)(pthread_once_t*,void(*)(void)) = pthread_once;
117 int(*p_pthread_rwlock_destroy)(pthread_rwlock_t*) = pthread_rwlock_destroy;
118 int(*p_pthread_rwlock_init)(pthread_rwlock_t*restrict,const pthread_rwlockattr_t*restrict) = pthread_rwlock_init;
119 int(*p_pthread_rwlock_rdlock)(pthread_rwlock_t*) = pthread_rwlock_rdlock;
120 int(*p_pthread_rwlock_tryrdlock)(pthread_rwlock_t*) = pthread_rwlock_tryrdlock;
121 int(*p_pthread_rwlock_trywrlock)(pthread_rwlock_t*) = pthread_rwlock_trywrlock;
122 int(*p_pthread_rwlock_unlock)(pthread_rwlock_t*) = pthread_rwlock_unlock;
123 int(*p_pthread_rwlock_wrlock)(pthread_rwlock_t*) = pthread_rwlock_wrlock;
124 int(*p_pthread_rwlockattr_destroy)(pthread_rwlockattr_t*) = pthread_rwlockattr_destroy;
125 int(*p_pthread_rwlockattr_getpshared)(const pthread_rwlockattr_t*restrict,int*restrict) = pthread_rwlockattr_getpshared;
126 int(*p_pthread_rwlockattr_init)(pthread_rwlockattr_t*) = pthread_rwlockattr_init;
127 int(*p_pthread_rwlockattr_setpshared)(pthread_rwlockattr_t*,int) = pthread_rwlockattr_setpshared;
128 pthread_t(*p_pthread_self)(void) = pthread_self;
129 int(*p_pthread_setcancelstate)(int,int*) = pthread_setcancelstate;
130 int(*p_pthread_setcanceltype)(int,int*) = pthread_setcanceltype;
131 int(*p_pthread_setschedparam)(pthread_t,int,const struct sched_param*) = pthread_setschedparam;
132 int(*p_pthread_setschedprio)(pthread_t,int) = pthread_setschedprio;
133 int(*p_pthread_setspecific)(pthread_key_t,const void*) = pthread_setspecific;
134 int(*p_pthread_spin_destroy)(pthread_spinlock_t*) = pthread_spin_destroy;
135 int(*p_pthread_spin_init)(pthread_spinlock_t*,int) = pthread_spin_init;
136 int(*p_pthread_spin_lock)(pthread_spinlock_t*) = pthread_spin_lock;
137 int(*p_pthread_spin_trylock)(pthread_spinlock_t*) = pthread_spin_trylock;
138 int(*p_pthread_spin_unlock)(pthread_spinlock_t*) = pthread_spin_unlock;
139 void(*p_pthread_testcancel)(void) = pthread_testcancel;
140 }
141 #include <time.h>
142 static void g()
143 {
144 int(*p_pthread_getcpuclockid)(pthread_t,clockid_t*) = pthread_getcpuclockid;
145 int(*p_pthread_mutex_timedlock)(pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_mutex_timedlock;
146 int(*p_pthread_rwlock_timedrdlock)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedrdlock;
147 int(*p_pthread_rwlock_timedwrlock)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedwrlock;
148 }