api: shorten function checks (and put each into a different scope)
[libc-test] / src / api / pthread.c
index f28d19c..45210d4 100644 (file)
@@ -43,106 +43,106 @@ C(PTHREAD_SCOPE_SYSTEM)
 {pthread_cond_t x = PTHREAD_COND_INITIALIZER;}
 {pthread_mutex_t x = PTHREAD_MUTEX_INITIALIZER;}
 {pthread_rwlock_t x = PTHREAD_RWLOCK_INITIALIZER;}
-int(*p_pthread_atfork)(void(*)(void),void(*)(void),void(*)(void)) = pthread_atfork;
-int(*p_pthread_attr_destroy)(pthread_attr_t*) = pthread_attr_destroy;
-int(*p_pthread_attr_getdetachstate)(const pthread_attr_t*,int*) = pthread_attr_getdetachstate;
-int(*p_pthread_attr_getguardsize)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getguardsize;
-int(*p_pthread_attr_getinheritsched)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getinheritsched;
-int(*p_pthread_attr_getschedparam)(const pthread_attr_t*restrict,struct sched_param*restrict) = pthread_attr_getschedparam;
-int(*p_pthread_attr_getschedpolicy)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getschedpolicy;
-int(*p_pthread_attr_getscope)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getscope;
-int(*p_pthread_attr_getstack)(const pthread_attr_t*restrict,void**restrict,size_t*restrict) = pthread_attr_getstack;
-int(*p_pthread_attr_getstacksize)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getstacksize;
-int(*p_pthread_attr_init)(pthread_attr_t*) = pthread_attr_init;
-int(*p_pthread_attr_setdetachstate)(pthread_attr_t*,int) = pthread_attr_setdetachstate;
-int(*p_pthread_attr_setguardsize)(pthread_attr_t*,size_t) = pthread_attr_setguardsize;
-int(*p_pthread_attr_setinheritsched)(pthread_attr_t*,int) = pthread_attr_setinheritsched;
-int(*p_pthread_attr_setschedparam)(pthread_attr_t*restrict,const struct sched_param*restrict) = pthread_attr_setschedparam;
-int(*p_pthread_attr_setschedpolicy)(pthread_attr_t*,int) = pthread_attr_setschedpolicy;
-int(*p_pthread_attr_setscope)(pthread_attr_t*,int) = pthread_attr_setscope;
-int(*p_pthread_attr_setstack)(pthread_attr_t*,void*,size_t) = pthread_attr_setstack;
-int(*p_pthread_attr_setstacksize)(pthread_attr_t*,size_t) = pthread_attr_setstacksize;
-int(*p_pthread_barrier_destroy)(pthread_barrier_t*) = pthread_barrier_destroy;
-int(*p_pthread_barrier_init)(pthread_barrier_t*restrict,const pthread_barrierattr_t*restrict,unsigned) = pthread_barrier_init;
-int(*p_pthread_barrier_wait)(pthread_barrier_t*) = pthread_barrier_wait;
-int(*p_pthread_barrierattr_destroy)(pthread_barrierattr_t*) = pthread_barrierattr_destroy;
-int(*p_pthread_barrierattr_getpshared)(const pthread_barrierattr_t*restrict,int*restrict) = pthread_barrierattr_getpshared;
-int(*p_pthread_barrierattr_init)(pthread_barrierattr_t*) = pthread_barrierattr_init;
-int(*p_pthread_barrierattr_setpshared)(pthread_barrierattr_t*,int) = pthread_barrierattr_setpshared;
-int(*p_pthread_cancel)(pthread_t) = pthread_cancel;
-void(*p_pthread_cleanup_pop)(int) = pthread_cleanup_pop;
-void(*p_pthread_cleanup_push)(void(*)(void*),void*) = pthread_cleanup_push;
-int(*p_pthread_cond_broadcast)(pthread_cond_t*) = pthread_cond_broadcast;
-int(*p_pthread_cond_destroy)(pthread_cond_t*) = pthread_cond_destroy;
-int(*p_pthread_cond_init)(pthread_cond_t*restrict,const pthread_condattr_t*restrict) = pthread_cond_init;
-int(*p_pthread_cond_signal)(pthread_cond_t*) = pthread_cond_signal;
-int(*p_pthread_cond_timedwait)(pthread_cond_t*restrict,pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_cond_timedwait;
-int(*p_pthread_cond_wait)(pthread_cond_t*restrict,pthread_mutex_t*restrict) = pthread_cond_wait;
-int(*p_pthread_condattr_destroy)(pthread_condattr_t*) = pthread_condattr_destroy;
-int(*p_pthread_condattr_getclock)(const pthread_condattr_t*restrict,clockid_t*restrict) = pthread_condattr_getclock;
-int(*p_pthread_condattr_getpshared)(const pthread_condattr_t*restrict,int*restrict) = pthread_condattr_getpshared;
-int(*p_pthread_condattr_init)(pthread_condattr_t*) = pthread_condattr_init;
-int(*p_pthread_condattr_setclock)(pthread_condattr_t*,clockid_t) = pthread_condattr_setclock;
-int(*p_pthread_condattr_setpshared)(pthread_condattr_t*,int) = pthread_condattr_setpshared;
-int(*p_pthread_create)(pthread_t*restrict,const pthread_attr_t*restrict,void*(*)(void*),void*restrict) = pthread_create;
-int(*p_pthread_detach)(pthread_t) = pthread_detach;
-int(*p_pthread_equal)(pthread_t,pthread_t) = pthread_equal;
-void(*p_pthread_exit)(void*) = pthread_exit;
-int(*p_pthread_getschedparam)(pthread_t,int*restrict,struct sched_param*restrict) = pthread_getschedparam;
-void*(*p_pthread_getspecific)(pthread_key_t) = pthread_getspecific;
-int(*p_pthread_join)(pthread_t,void**) = pthread_join;
-int(*p_pthread_key_create)(pthread_key_t*,void(*)(void*)) = pthread_key_create;
-int(*p_pthread_key_delete)(pthread_key_t) = pthread_key_delete;
-int(*p_pthread_mutex_consistent)(pthread_mutex_t*) = pthread_mutex_consistent;
-int(*p_pthread_mutex_destroy)(pthread_mutex_t*) = pthread_mutex_destroy;
-int(*p_pthread_mutex_getprioceiling)(const pthread_mutex_t*restrict,int*restrict) = pthread_mutex_getprioceiling;
-int(*p_pthread_mutex_init)(pthread_mutex_t*restrict,const pthread_mutexattr_t*restrict) = pthread_mutex_init;
-int(*p_pthread_mutex_lock)(pthread_mutex_t*) = pthread_mutex_lock;
-int(*p_pthread_mutex_setprioceiling)(pthread_mutex_t*restrict,int,int*restrict) = pthread_mutex_setprioceiling;
-int(*p_pthread_mutex_trylock)(pthread_mutex_t*) = pthread_mutex_trylock;
-int(*p_pthread_mutex_unlock)(pthread_mutex_t*) = pthread_mutex_unlock;
-int(*p_pthread_mutexattr_destroy)(pthread_mutexattr_t*) = pthread_mutexattr_destroy;
-int(*p_pthread_mutexattr_getprioceiling)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprioceiling;
-int(*p_pthread_mutexattr_getprotocol)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprotocol;
-int(*p_pthread_mutexattr_getpshared)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getpshared;
-int(*p_pthread_mutexattr_getrobust)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getrobust;
-int(*p_pthread_mutexattr_gettype)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_gettype;
-int(*p_pthread_mutexattr_init)(pthread_mutexattr_t*) = pthread_mutexattr_init;
-int(*p_pthread_mutexattr_setprioceiling)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprioceiling;
-int(*p_pthread_mutexattr_setprotocol)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprotocol;
-int(*p_pthread_mutexattr_setpshared)(pthread_mutexattr_t*,int) = pthread_mutexattr_setpshared;
-int(*p_pthread_mutexattr_setrobust)(pthread_mutexattr_t*,int) = pthread_mutexattr_setrobust;
-int(*p_pthread_mutexattr_settype)(pthread_mutexattr_t*,int) = pthread_mutexattr_settype;
-int(*p_pthread_once)(pthread_once_t*,void(*)(void)) = pthread_once;
-int(*p_pthread_rwlock_destroy)(pthread_rwlock_t*) = pthread_rwlock_destroy;
-int(*p_pthread_rwlock_init)(pthread_rwlock_t*restrict,const pthread_rwlockattr_t*restrict) = pthread_rwlock_init;
-int(*p_pthread_rwlock_rdlock)(pthread_rwlock_t*) = pthread_rwlock_rdlock;
-int(*p_pthread_rwlock_tryrdlock)(pthread_rwlock_t*) = pthread_rwlock_tryrdlock;
-int(*p_pthread_rwlock_trywrlock)(pthread_rwlock_t*) = pthread_rwlock_trywrlock;
-int(*p_pthread_rwlock_unlock)(pthread_rwlock_t*) = pthread_rwlock_unlock;
-int(*p_pthread_rwlock_wrlock)(pthread_rwlock_t*) = pthread_rwlock_wrlock;
-int(*p_pthread_rwlockattr_destroy)(pthread_rwlockattr_t*) = pthread_rwlockattr_destroy;
-int(*p_pthread_rwlockattr_getpshared)(const pthread_rwlockattr_t*restrict,int*restrict) = pthread_rwlockattr_getpshared;
-int(*p_pthread_rwlockattr_init)(pthread_rwlockattr_t*) = pthread_rwlockattr_init;
-int(*p_pthread_rwlockattr_setpshared)(pthread_rwlockattr_t*,int) = pthread_rwlockattr_setpshared;
-pthread_t(*p_pthread_self)(void) = pthread_self;
-int(*p_pthread_setcancelstate)(int,int*) = pthread_setcancelstate;
-int(*p_pthread_setcanceltype)(int,int*) = pthread_setcanceltype;
-int(*p_pthread_setschedparam)(pthread_t,int,const struct sched_param*) = pthread_setschedparam;
-int(*p_pthread_setschedprio)(pthread_t,int) = pthread_setschedprio;
-int(*p_pthread_setspecific)(pthread_key_t,const void*) = pthread_setspecific;
-int(*p_pthread_spin_destroy)(pthread_spinlock_t*) = pthread_spin_destroy;
-int(*p_pthread_spin_init)(pthread_spinlock_t*,int) = pthread_spin_init;
-int(*p_pthread_spin_lock)(pthread_spinlock_t*) = pthread_spin_lock;
-int(*p_pthread_spin_trylock)(pthread_spinlock_t*) = pthread_spin_trylock;
-int(*p_pthread_spin_unlock)(pthread_spinlock_t*) = pthread_spin_unlock;
-void(*p_pthread_testcancel)(void) = pthread_testcancel;
+{int(*p)(void(*)(void),void(*)(void),void(*)(void)) = pthread_atfork;}
+{int(*p)(pthread_attr_t*) = pthread_attr_destroy;}
+{int(*p)(const pthread_attr_t*,int*) = pthread_attr_getdetachstate;}
+{int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getguardsize;}
+{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getinheritsched;}
+{int(*p)(const pthread_attr_t*restrict,struct sched_param*restrict) = pthread_attr_getschedparam;}
+{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getschedpolicy;}
+{int(*p)(const pthread_attr_t*restrict,int*restrict) = pthread_attr_getscope;}
+{int(*p)(const pthread_attr_t*restrict,void**restrict,size_t*restrict) = pthread_attr_getstack;}
+{int(*p)(const pthread_attr_t*restrict,size_t*restrict) = pthread_attr_getstacksize;}
+{int(*p)(pthread_attr_t*) = pthread_attr_init;}
+{int(*p)(pthread_attr_t*,int) = pthread_attr_setdetachstate;}
+{int(*p)(pthread_attr_t*,size_t) = pthread_attr_setguardsize;}
+{int(*p)(pthread_attr_t*,int) = pthread_attr_setinheritsched;}
+{int(*p)(pthread_attr_t*restrict,const struct sched_param*restrict) = pthread_attr_setschedparam;}
+{int(*p)(pthread_attr_t*,int) = pthread_attr_setschedpolicy;}
+{int(*p)(pthread_attr_t*,int) = pthread_attr_setscope;}
+{int(*p)(pthread_attr_t*,void*,size_t) = pthread_attr_setstack;}
+{int(*p)(pthread_attr_t*,size_t) = pthread_attr_setstacksize;}
+{int(*p)(pthread_barrier_t*) = pthread_barrier_destroy;}
+{int(*p)(pthread_barrier_t*restrict,const pthread_barrierattr_t*restrict,unsigned) = pthread_barrier_init;}
+{int(*p)(pthread_barrier_t*) = pthread_barrier_wait;}
+{int(*p)(pthread_barrierattr_t*) = pthread_barrierattr_destroy;}
+{int(*p)(const pthread_barrierattr_t*restrict,int*restrict) = pthread_barrierattr_getpshared;}
+{int(*p)(pthread_barrierattr_t*) = pthread_barrierattr_init;}
+{int(*p)(pthread_barrierattr_t*,int) = pthread_barrierattr_setpshared;}
+{int(*p)(pthread_t) = pthread_cancel;}
+{void(*p)(int) = pthread_cleanup_pop;}
+{void(*p)(void(*)(void*),void*) = pthread_cleanup_push;}
+{int(*p)(pthread_cond_t*) = pthread_cond_broadcast;}
+{int(*p)(pthread_cond_t*) = pthread_cond_destroy;}
+{int(*p)(pthread_cond_t*restrict,const pthread_condattr_t*restrict) = pthread_cond_init;}
+{int(*p)(pthread_cond_t*) = pthread_cond_signal;}
+{int(*p)(pthread_cond_t*restrict,pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_cond_timedwait;}
+{int(*p)(pthread_cond_t*restrict,pthread_mutex_t*restrict) = pthread_cond_wait;}
+{int(*p)(pthread_condattr_t*) = pthread_condattr_destroy;}
+{int(*p)(const pthread_condattr_t*restrict,clockid_t*restrict) = pthread_condattr_getclock;}
+{int(*p)(const pthread_condattr_t*restrict,int*restrict) = pthread_condattr_getpshared;}
+{int(*p)(pthread_condattr_t*) = pthread_condattr_init;}
+{int(*p)(pthread_condattr_t*,clockid_t) = pthread_condattr_setclock;}
+{int(*p)(pthread_condattr_t*,int) = pthread_condattr_setpshared;}
+{int(*p)(pthread_t*restrict,const pthread_attr_t*restrict,void*(*)(void*),void*restrict) = pthread_create;}
+{int(*p)(pthread_t) = pthread_detach;}
+{int(*p)(pthread_t,pthread_t) = pthread_equal;}
+{void(*p)(void*) = pthread_exit;}
+{int(*p)(pthread_t,int*restrict,struct sched_param*restrict) = pthread_getschedparam;}
+{void*(*p)(pthread_key_t) = pthread_getspecific;}
+{int(*p)(pthread_t,void**) = pthread_join;}
+{int(*p)(pthread_key_t*,void(*)(void*)) = pthread_key_create;}
+{int(*p)(pthread_key_t) = pthread_key_delete;}
+{int(*p)(pthread_mutex_t*) = pthread_mutex_consistent;}
+{int(*p)(pthread_mutex_t*) = pthread_mutex_destroy;}
+{int(*p)(const pthread_mutex_t*restrict,int*restrict) = pthread_mutex_getprioceiling;}
+{int(*p)(pthread_mutex_t*restrict,const pthread_mutexattr_t*restrict) = pthread_mutex_init;}
+{int(*p)(pthread_mutex_t*) = pthread_mutex_lock;}
+{int(*p)(pthread_mutex_t*restrict,int,int*restrict) = pthread_mutex_setprioceiling;}
+{int(*p)(pthread_mutex_t*) = pthread_mutex_trylock;}
+{int(*p)(pthread_mutex_t*) = pthread_mutex_unlock;}
+{int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_destroy;}
+{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprioceiling;}
+{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getprotocol;}
+{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getpshared;}
+{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_getrobust;}
+{int(*p)(const pthread_mutexattr_t*restrict,int*restrict) = pthread_mutexattr_gettype;}
+{int(*p)(pthread_mutexattr_t*) = pthread_mutexattr_init;}
+{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprioceiling;}
+{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setprotocol;}
+{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setpshared;}
+{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_setrobust;}
+{int(*p)(pthread_mutexattr_t*,int) = pthread_mutexattr_settype;}
+{int(*p)(pthread_once_t*,void(*)(void)) = pthread_once;}
+{int(*p)(pthread_rwlock_t*) = pthread_rwlock_destroy;}
+{int(*p)(pthread_rwlock_t*restrict,const pthread_rwlockattr_t*restrict) = pthread_rwlock_init;}
+{int(*p)(pthread_rwlock_t*) = pthread_rwlock_rdlock;}
+{int(*p)(pthread_rwlock_t*) = pthread_rwlock_tryrdlock;}
+{int(*p)(pthread_rwlock_t*) = pthread_rwlock_trywrlock;}
+{int(*p)(pthread_rwlock_t*) = pthread_rwlock_unlock;}
+{int(*p)(pthread_rwlock_t*) = pthread_rwlock_wrlock;}
+{int(*p)(pthread_rwlockattr_t*) = pthread_rwlockattr_destroy;}
+{int(*p)(const pthread_rwlockattr_t*restrict,int*restrict) = pthread_rwlockattr_getpshared;}
+{int(*p)(pthread_rwlockattr_t*) = pthread_rwlockattr_init;}
+{int(*p)(pthread_rwlockattr_t*,int) = pthread_rwlockattr_setpshared;}
+{pthread_t(*p)(void) = pthread_self;}
+{int(*p)(int,int*) = pthread_setcancelstate;}
+{int(*p)(int,int*) = pthread_setcanceltype;}
+{int(*p)(pthread_t,int,const struct sched_param*) = pthread_setschedparam;}
+{int(*p)(pthread_t,int) = pthread_setschedprio;}
+{int(*p)(pthread_key_t,const void*) = pthread_setspecific;}
+{int(*p)(pthread_spinlock_t*) = pthread_spin_destroy;}
+{int(*p)(pthread_spinlock_t*,int) = pthread_spin_init;}
+{int(*p)(pthread_spinlock_t*) = pthread_spin_lock;}
+{int(*p)(pthread_spinlock_t*) = pthread_spin_trylock;}
+{int(*p)(pthread_spinlock_t*) = pthread_spin_unlock;}
+{void(*p)(void) = pthread_testcancel;}
 }
 #include <time.h>
 static void g()
 {
-int(*p_pthread_getcpuclockid)(pthread_t,clockid_t*) = pthread_getcpuclockid;
-int(*p_pthread_mutex_timedlock)(pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_mutex_timedlock;
-int(*p_pthread_rwlock_timedrdlock)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedrdlock;
-int(*p_pthread_rwlock_timedwrlock)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedwrlock;
+{int(*p)(pthread_t,clockid_t*) = pthread_getcpuclockid;}
+{int(*p)(pthread_mutex_t*restrict,const struct timespec*restrict) = pthread_mutex_timedlock;}
+{int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedrdlock;}
+{int(*p)(pthread_rwlock_t*restrict,const struct timespec*restrict) = pthread_rwlock_timedwrlock;}
 }