From b6413b6db8756c1ecae5e575e6516f811966046f Mon Sep 17 00:00:00 2001 From: "Pedro F. Giffuni" Date: Sat, 18 Aug 2018 01:05:38 +0000 Subject: [PATCH] POSIX compliance improvements in the pthread(3) functions. This basically adds makes use of the C99 restrict keyword, and also adds some 'const's to four threading functions: pthread_mutexattr_gettype(), pthread_mutexattr_getprioceiling(), pthread_mutexattr_getprotocol(), and pthread_mutex_getprioceiling. The changes are in accordance to POSIX/SUSv4-2018. Hinted by: DragonFlyBSD Relnotes: yes MFC after: 1 month Differential Revision: D16722 --- include/pthread.h | 91 +++++++++++-------- lib/libthr/thread/thr_attr.c | 21 +++-- lib/libthr/thread/thr_barrier.c | 4 +- lib/libthr/thread/thr_barrierattr.c | 4 +- lib/libthr/thread/thr_cond.c | 11 ++- lib/libthr/thread/thr_condattr.c | 6 +- lib/libthr/thread/thr_create.c | 5 +- lib/libthr/thread/thr_getschedparam.c | 4 +- lib/libthr/thread/thr_mutex.c | 28 +++--- lib/libthr/thread/thr_mutexattr.c | 9 +- lib/libthr/thread/thr_rwlock.c | 8 +- lib/libthr/thread/thr_rwlockattr.c | 5 +- share/man/man3/pthread.3 | 8 +- share/man/man3/pthread_attr.3 | 12 +-- share/man/man3/pthread_barrier_destroy.3 | 4 +- share/man/man3/pthread_barrierattr.3 | 4 +- share/man/man3/pthread_cond_init.3 | 4 +- share/man/man3/pthread_cond_wait.3 | 4 +- share/man/man3/pthread_create.3 | 4 +- share/man/man3/pthread_mutex_init.3 | 4 +- share/man/man3/pthread_mutex_timedlock.3 | 4 +- share/man/man3/pthread_mutexattr.3 | 8 +- share/man/man3/pthread_rwlock_init.3 | 4 +- share/man/man3/pthread_rwlock_timedrdlock.3 | 4 +- share/man/man3/pthread_rwlock_timedwrlock.3 | 4 +- .../man/man3/pthread_rwlockattr_getpshared.3 | 4 +- share/man/man3/pthread_schedparam.3 | 4 +- 27 files changed, 153 insertions(+), 119 deletions(-) diff --git a/include/pthread.h b/include/pthread.h index c58a9fe5e36..c22ad216d01 100644 --- a/include/pthread.h +++ b/include/pthread.h @@ -153,10 +153,10 @@ int pthread_attr_destroy(pthread_attr_t *); int pthread_attr_getstack( const pthread_attr_t * __restrict, void ** __restrict, size_t * __restrict); -int pthread_attr_getstacksize(const pthread_attr_t *, - size_t *); -int pthread_attr_getguardsize(const pthread_attr_t *, - size_t *); +int pthread_attr_getstacksize(const pthread_attr_t * __restrict, + size_t * __restrict); +int pthread_attr_getguardsize(const pthread_attr_t * __restrict, + size_t * __restrict); int pthread_attr_getstackaddr(const pthread_attr_t *, void **); int pthread_attr_getdetachstate(const pthread_attr_t *, int *); @@ -168,12 +168,12 @@ int pthread_attr_setstack(pthread_attr_t *, void *, int pthread_attr_setstackaddr(pthread_attr_t *, void *); int pthread_attr_setdetachstate(pthread_attr_t *, int); int pthread_barrier_destroy(pthread_barrier_t *); -int pthread_barrier_init(pthread_barrier_t *, - const pthread_barrierattr_t *, unsigned); +int pthread_barrier_init(pthread_barrier_t * __restrict, + const pthread_barrierattr_t * __restrict, unsigned); int pthread_barrier_wait(pthread_barrier_t *); int pthread_barrierattr_destroy(pthread_barrierattr_t *); int pthread_barrierattr_getpshared( - const pthread_barrierattr_t *, int *); + const pthread_barrierattr_t * __restrict, int * __restrict); int pthread_barrierattr_init(pthread_barrierattr_t *); int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int); @@ -191,24 +191,27 @@ int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int); } int pthread_condattr_destroy(pthread_condattr_t *); -int pthread_condattr_getclock(const pthread_condattr_t *, - clockid_t *); +int pthread_condattr_getclock(const pthread_condattr_t * __restrict, + clockid_t * __restrict); int pthread_condattr_getpshared(const pthread_condattr_t *, int *); int pthread_condattr_init(pthread_condattr_t *); int pthread_condattr_setclock(pthread_condattr_t *, clockid_t); int pthread_condattr_setpshared(pthread_condattr_t *, int); int pthread_cond_broadcast(pthread_cond_t *); int pthread_cond_destroy(pthread_cond_t *); -int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *); +int pthread_cond_init(pthread_cond_t * __restrict, + const pthread_condattr_t * __restrict); int pthread_cond_signal(pthread_cond_t *); int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t * __mutex, const struct timespec *) __requires_exclusive(*__mutex); -int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t * __mutex) +int pthread_cond_wait(pthread_cond_t * __restrict, + pthread_mutex_t * __restrict __mutex) __requires_exclusive(*__mutex); -int pthread_create(pthread_t *, const pthread_attr_t *, - void *(*) (void *), void *); +int pthread_create(pthread_t * __restrict, + const pthread_attr_t * __restrict, void *(*) (void *), + void * __restrict); int pthread_detach(pthread_t); int pthread_equal(pthread_t, pthread_t); void pthread_exit(void *) __dead2; @@ -219,40 +222,44 @@ int pthread_key_create(pthread_key_t *, void (*) (void *)); int pthread_key_delete(pthread_key_t); int pthread_mutexattr_init(pthread_mutexattr_t *); int pthread_mutexattr_destroy(pthread_mutexattr_t *); -int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, - int *); -int pthread_mutexattr_gettype(pthread_mutexattr_t *, int *); +int pthread_mutexattr_getpshared( + const pthread_mutexattr_t * __restrict, + int * __restrict); +int pthread_mutexattr_gettype( + const pthread_mutexattr_t * __restrict, int * __restrict); int pthread_mutexattr_settype(pthread_mutexattr_t *, int); int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int); int pthread_mutex_consistent(pthread_mutex_t * __mutex) __requires_exclusive(*__mutex); int pthread_mutex_destroy(pthread_mutex_t * __mutex) __requires_unlocked(*__mutex); -int pthread_mutex_init(pthread_mutex_t * __mutex, - const pthread_mutexattr_t *) +int pthread_mutex_init(pthread_mutex_t * __restrict __mutex, + const pthread_mutexattr_t * __restrict) __requires_unlocked(*__mutex); int pthread_mutex_lock(pthread_mutex_t * __mutex) __locks_exclusive(*__mutex); int pthread_mutex_trylock(pthread_mutex_t * __mutex) __trylocks_exclusive(0, *__mutex); -int pthread_mutex_timedlock(pthread_mutex_t * __mutex, - const struct timespec *) +int pthread_mutex_timedlock(pthread_mutex_t * __restrict __mutex, + const struct timespec * __restrict) __trylocks_exclusive(0, *__mutex); int pthread_mutex_unlock(pthread_mutex_t * __mutex) __unlocks(*__mutex); int pthread_once(pthread_once_t *, void (*) (void)); int pthread_rwlock_destroy(pthread_rwlock_t * __rwlock) __requires_unlocked(*__rwlock); -int pthread_rwlock_init(pthread_rwlock_t * __rwlock, - const pthread_rwlockattr_t *) +int pthread_rwlock_init(pthread_rwlock_t * __restrict __rwlock, + const pthread_rwlockattr_t * __restrict) __requires_unlocked(*__rwlock); int pthread_rwlock_rdlock(pthread_rwlock_t * __rwlock) __locks_shared(*__rwlock); -int pthread_rwlock_timedrdlock(pthread_rwlock_t * __rwlock, - const struct timespec *) +int pthread_rwlock_timedrdlock( + pthread_rwlock_t * __restrict __rwlock, + const struct timespec * __restrict) __trylocks_shared(0, *__rwlock); -int pthread_rwlock_timedwrlock(pthread_rwlock_t * __rwlock, - const struct timespec *) +int pthread_rwlock_timedwrlock( + pthread_rwlock_t * __restrict __rwlock, + const struct timespec * __restrict) __trylocks_exclusive(0, *__rwlock); int pthread_rwlock_tryrdlock(pthread_rwlock_t * __rwlock) __trylocks_shared(0, *__rwlock); @@ -265,8 +272,9 @@ int pthread_rwlock_wrlock(pthread_rwlock_t * __rwlock) int pthread_rwlockattr_destroy(pthread_rwlockattr_t *); int pthread_rwlockattr_getkind_np(const pthread_rwlockattr_t *, int *); -int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *, - int *); +int pthread_rwlockattr_getpshared( + const pthread_rwlockattr_t * __restrict, + int * __restrict); int pthread_rwlockattr_init(pthread_rwlockattr_t *); int pthread_rwlockattr_setkind_np(pthread_rwlockattr_t *, int); @@ -295,30 +303,39 @@ int pthread_setprio(pthread_t, int); void pthread_yield(void); #endif -int pthread_mutexattr_getprioceiling(pthread_mutexattr_t *, int *); +int pthread_mutexattr_getprioceiling( + const pthread_mutexattr_t * __restrict, + int * __restrict); int pthread_mutexattr_setprioceiling(pthread_mutexattr_t *, int); -int pthread_mutex_getprioceiling(pthread_mutex_t *, int *); -int pthread_mutex_setprioceiling(pthread_mutex_t *, int, int *); +int pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict, + int * __restrict); +int pthread_mutex_setprioceiling(pthread_mutex_t * __restrict, int, + int * __restrict); -int pthread_mutexattr_getprotocol(pthread_mutexattr_t *, int *); +int pthread_mutexattr_getprotocol( + const pthread_mutexattr_t * __restrict, + int * __restrict); int pthread_mutexattr_setprotocol(pthread_mutexattr_t *, int); int pthread_mutexattr_getrobust( pthread_mutexattr_t * __restrict, int * __restrict); int pthread_mutexattr_setrobust(pthread_mutexattr_t *, int); -int pthread_attr_getinheritsched(const pthread_attr_t *, int *); +int pthread_attr_getinheritsched(const pthread_attr_t * __restrict, + int * __restrict); int pthread_attr_getschedparam(const pthread_attr_t *, struct sched_param *); -int pthread_attr_getschedpolicy(const pthread_attr_t *, int *); -int pthread_attr_getscope(const pthread_attr_t *, int *); +int pthread_attr_getschedpolicy(const pthread_attr_t * __restrict, + int * __restrict); +int pthread_attr_getscope(const pthread_attr_t * __restrict, + int * __restrict); int pthread_attr_setinheritsched(pthread_attr_t *, int); int pthread_attr_setschedparam(pthread_attr_t *, const struct sched_param *); int pthread_attr_setschedpolicy(pthread_attr_t *, int); int pthread_attr_setscope(pthread_attr_t *, int); -int pthread_getschedparam(pthread_t pthread, int *, - struct sched_param *); +int pthread_getschedparam(pthread_t pthread, int * __restrict, + struct sched_param * __restrict); int pthread_setschedparam(pthread_t, int, const struct sched_param *); #if __XSI_VISIBLE diff --git a/lib/libthr/thread/thr_attr.c b/lib/libthr/thread/thr_attr.c index 4a5b4afc93e..8639ebba3e2 100644 --- a/lib/libthr/thread/thr_attr.c +++ b/lib/libthr/thread/thr_attr.c @@ -199,7 +199,8 @@ _pthread_attr_getdetachstate(const pthread_attr_t *attr, int *detachstate) __weak_reference(_pthread_attr_getguardsize, pthread_attr_getguardsize); int -_pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize) +_pthread_attr_getguardsize(const pthread_attr_t *__restrict attr, + size_t *__restrict guardsize) { int ret; @@ -217,7 +218,8 @@ _pthread_attr_getguardsize(const pthread_attr_t *attr, size_t *guardsize) __weak_reference(_pthread_attr_getinheritsched, pthread_attr_getinheritsched); int -_pthread_attr_getinheritsched(const pthread_attr_t *attr, int *sched_inherit) +_pthread_attr_getinheritsched(const pthread_attr_t * __restrict attr, + int * __restrict sched_inherit) { int ret = 0; @@ -232,7 +234,8 @@ _pthread_attr_getinheritsched(const pthread_attr_t *attr, int *sched_inherit) __weak_reference(_pthread_attr_getschedparam, pthread_attr_getschedparam); int -_pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *param) +_pthread_attr_getschedparam(const pthread_attr_t * __restrict attr, + struct sched_param * __restrict param) { int ret = 0; @@ -247,7 +250,8 @@ _pthread_attr_getschedparam(const pthread_attr_t *attr, struct sched_param *para __weak_reference(_pthread_attr_getschedpolicy, pthread_attr_getschedpolicy); int -_pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) +_pthread_attr_getschedpolicy(const pthread_attr_t * __restrict attr, + int * __restrict policy) { int ret = 0; @@ -262,7 +266,8 @@ _pthread_attr_getschedpolicy(const pthread_attr_t *attr, int *policy) __weak_reference(_pthread_attr_getscope, pthread_attr_getscope); int -_pthread_attr_getscope(const pthread_attr_t *attr, int *contentionscope) +_pthread_attr_getscope(const pthread_attr_t * __restrict attr, + int * __restrict contentionscope) { int ret = 0; @@ -320,7 +325,8 @@ _pthread_attr_getstackaddr(const pthread_attr_t *attr, void **stackaddr) __weak_reference(_pthread_attr_getstacksize, pthread_attr_getstacksize); int -_pthread_attr_getstacksize(const pthread_attr_t *attr, size_t *stacksize) +_pthread_attr_getstacksize(const pthread_attr_t * __restrict attr, + size_t * __restrict stacksize) { int ret; @@ -440,7 +446,8 @@ _pthread_attr_setinheritsched(pthread_attr_t *attr, int sched_inherit) __weak_reference(_pthread_attr_setschedparam, pthread_attr_setschedparam); int -_pthread_attr_setschedparam(pthread_attr_t *attr, const struct sched_param *param) +_pthread_attr_setschedparam(pthread_attr_t * __restrict attr, + const struct sched_param * __restrict param) { int policy; diff --git a/lib/libthr/thread/thr_barrier.c b/lib/libthr/thread/thr_barrier.c index 890e8a60f71..fa205ad509c 100644 --- a/lib/libthr/thread/thr_barrier.c +++ b/lib/libthr/thread/thr_barrier.c @@ -96,8 +96,8 @@ _pthread_barrier_destroy(pthread_barrier_t *barrier) } int -_pthread_barrier_init(pthread_barrier_t *barrier, - const pthread_barrierattr_t *attr, unsigned count) +_pthread_barrier_init(pthread_barrier_t * __restrict barrier, + const pthread_barrierattr_t * __restrict attr, unsigned count) { pthread_barrier_t bar; int pshared; diff --git a/lib/libthr/thread/thr_barrierattr.c b/lib/libthr/thread/thr_barrierattr.c index 66ba7305026..09d8c9cff60 100644 --- a/lib/libthr/thread/thr_barrierattr.c +++ b/lib/libthr/thread/thr_barrierattr.c @@ -58,8 +58,8 @@ _pthread_barrierattr_destroy(pthread_barrierattr_t *attr) } int -_pthread_barrierattr_getpshared(const pthread_barrierattr_t *attr, - int *pshared) +_pthread_barrierattr_getpshared(const pthread_barrierattr_t * __restrict attr, + int * __restrict pshared) { if (attr == NULL || *attr == NULL) diff --git a/lib/libthr/thread/thr_cond.c b/lib/libthr/thread/thr_cond.c index 9b6c787f961..ecaf787aa51 100644 --- a/lib/libthr/thread/thr_cond.c +++ b/lib/libthr/thread/thr_cond.c @@ -149,7 +149,8 @@ init_static(struct pthread *thread, pthread_cond_t *cond) } int -_pthread_cond_init(pthread_cond_t *cond, const pthread_condattr_t *cond_attr) +_pthread_cond_init(pthread_cond_t * __restrict cond, + const pthread_condattr_t * __restrict cond_attr) { *cond = NULL; @@ -374,15 +375,17 @@ _pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) } int -__pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex) +__pthread_cond_wait(pthread_cond_t * __restrict cond, + pthread_mutex_t * __restrict mutex) { return (cond_wait_common(cond, mutex, NULL, 1)); } int -_pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, - const struct timespec * abstime) +_pthread_cond_timedwait(pthread_cond_t * __restrict cond, + pthread_mutex_t * __restrict mutex, + const struct timespec * __restrict abstime) { if (abstime == NULL || abstime->tv_sec < 0 || abstime->tv_nsec < 0 || diff --git a/lib/libthr/thread/thr_condattr.c b/lib/libthr/thread/thr_condattr.c index b98f695d7bc..0a06d004cef 100644 --- a/lib/libthr/thread/thr_condattr.c +++ b/lib/libthr/thread/thr_condattr.c @@ -82,7 +82,8 @@ _pthread_condattr_destroy(pthread_condattr_t *attr) } int -_pthread_condattr_getclock(const pthread_condattr_t *attr, clockid_t *clock_id) +_pthread_condattr_getclock(const pthread_condattr_t * __restrict attr, + clockid_t * __restrict clock_id) { if (attr == NULL || *attr == NULL) return (EINVAL); @@ -106,7 +107,8 @@ _pthread_condattr_setclock(pthread_condattr_t *attr, clockid_t clock_id) } int -_pthread_condattr_getpshared(const pthread_condattr_t *attr, int *pshared) +_pthread_condattr_getpshared(const pthread_condattr_t * __restrict attr, + int * __restrict pshared) { if (attr == NULL || *attr == NULL) diff --git a/lib/libthr/thread/thr_create.c b/lib/libthr/thread/thr_create.c index 3f54f5c4c8d..69150ee6f8e 100644 --- a/lib/libthr/thread/thr_create.c +++ b/lib/libthr/thread/thr_create.c @@ -52,8 +52,9 @@ static void thread_start(struct pthread *curthread); __weak_reference(_pthread_create, pthread_create); int -_pthread_create(pthread_t * thread, const pthread_attr_t * attr, - void *(*start_routine) (void *), void *arg) +_pthread_create(pthread_t * __restrict thread, + const pthread_attr_t * __restrict attr, void *(*start_routine) (void *), + void * __restrict arg) { struct pthread *curthread, *new_thread; struct thr_param param; diff --git a/lib/libthr/thread/thr_getschedparam.c b/lib/libthr/thread/thr_getschedparam.c index 8301b4bf874..5785438f308 100644 --- a/lib/libthr/thread/thr_getschedparam.c +++ b/lib/libthr/thread/thr_getschedparam.c @@ -47,8 +47,8 @@ __FBSDID("$FreeBSD$"); __weak_reference(_pthread_getschedparam, pthread_getschedparam); int -_pthread_getschedparam(pthread_t pthread, int *policy, - struct sched_param *param) +_pthread_getschedparam(pthread_t pthread, int * __restrict policy, + struct sched_param * __restrict param) { struct pthread *curthread = _get_curthread(); int ret = 0; diff --git a/lib/libthr/thread/thr_mutex.c b/lib/libthr/thread/thr_mutex.c index f3f815c9968..d2d9f5b54c1 100644 --- a/lib/libthr/thread/thr_mutex.c +++ b/lib/libthr/thread/thr_mutex.c @@ -66,12 +66,12 @@ _Static_assert(sizeof(struct pthread_mutex) <= PAGE_SIZE, * Prototypes */ int __pthread_mutex_consistent(pthread_mutex_t *mutex); -int __pthread_mutex_init(pthread_mutex_t *mutex, - const pthread_mutexattr_t *mutex_attr); +int __pthread_mutex_init(pthread_mutex_t * __restrict mutex, + const pthread_mutexattr_t * __restrict mutex_attr); int __pthread_mutex_trylock(pthread_mutex_t *mutex); int __pthread_mutex_lock(pthread_mutex_t *mutex); -int __pthread_mutex_timedlock(pthread_mutex_t *mutex, - const struct timespec *abstime); +int __pthread_mutex_timedlock(pthread_mutex_t * __restrict mutex, + const struct timespec * __restrict abstime); int _pthread_mutex_getspinloops_np(pthread_mutex_t *mutex, int *count); int _pthread_mutex_setspinloops_np(pthread_mutex_t *mutex, int count); int __pthread_mutex_setspinloops_np(pthread_mutex_t *mutex, int count); @@ -376,8 +376,8 @@ shared_mutex_init(struct pthread_mutex *pmtx, const struct } int -__pthread_mutex_init(pthread_mutex_t *mutex, - const pthread_mutexattr_t *mutex_attr) +__pthread_mutex_init(pthread_mutex_t * __restrict mutex, + const pthread_mutexattr_t * __restrict mutex_attr) { struct pthread_mutex *pmtx; int ret; @@ -392,7 +392,7 @@ __pthread_mutex_init(pthread_mutex_t *mutex, return (mutex_init(mutex, mutex_attr ? *mutex_attr : NULL, calloc)); } - pmtx = __thr_pshared_offpage(mutex, 1); + pmtx = __thr_pshared_offpage(__DECONST(void *, mutex), 1); if (pmtx == NULL) return (EFAULT); *mutex = THR_PSHARED_PTR; @@ -748,8 +748,8 @@ __pthread_mutex_lock(pthread_mutex_t *mutex) } int -__pthread_mutex_timedlock(pthread_mutex_t *mutex, - const struct timespec *abstime) +__pthread_mutex_timedlock(pthread_mutex_t * __restrict mutex, + const struct timespec * __restrict abstime) { struct pthread_mutex *m; int ret; @@ -995,13 +995,13 @@ mutex_unlock_common(struct pthread_mutex *m, bool cv, int *mtx_defer) } int -_pthread_mutex_getprioceiling(pthread_mutex_t *mutex, - int *prioceiling) +_pthread_mutex_getprioceiling(const pthread_mutex_t * __restrict mutex, + int * __restrict prioceiling) { struct pthread_mutex *m; if (*mutex == THR_PSHARED_PTR) { - m = __thr_pshared_offpage(mutex, 0); + m = __thr_pshared_offpage(__DECONST(void *, mutex), 0); if (m == NULL) return (EINVAL); shared_mutex_init(m, NULL); @@ -1017,8 +1017,8 @@ _pthread_mutex_getprioceiling(pthread_mutex_t *mutex, } int -_pthread_mutex_setprioceiling(pthread_mutex_t *mutex, - int ceiling, int *old_ceiling) +_pthread_mutex_setprioceiling(pthread_mutex_t * __restrict mutex, + int ceiling, int * __restrict old_ceiling) { struct pthread *curthread; struct pthread_mutex *m, *m1, *m2; diff --git a/lib/libthr/thread/thr_mutexattr.c b/lib/libthr/thread/thr_mutexattr.c index 5becec38ffb..8313728e5cf 100644 --- a/lib/libthr/thread/thr_mutexattr.c +++ b/lib/libthr/thread/thr_mutexattr.c @@ -150,7 +150,8 @@ _pthread_mutexattr_settype(pthread_mutexattr_t *attr, int type) } int -_pthread_mutexattr_gettype(pthread_mutexattr_t *attr, int *type) +_pthread_mutexattr_gettype(const pthread_mutexattr_t * __restrict attr, + int * __restrict type) { int ret; @@ -202,7 +203,8 @@ _pthread_mutexattr_setpshared(pthread_mutexattr_t *attr, int pshared) } int -_pthread_mutexattr_getprotocol(pthread_mutexattr_t *mattr, int *protocol) +_pthread_mutexattr_getprotocol(const pthread_mutexattr_t * __restrict mattr, + int * __restrict protocol) { int ret = 0; @@ -230,7 +232,8 @@ _pthread_mutexattr_setprotocol(pthread_mutexattr_t *mattr, int protocol) } int -_pthread_mutexattr_getprioceiling(pthread_mutexattr_t *mattr, int *prioceiling) +_pthread_mutexattr_getprioceiling(const pthread_mutexattr_t * __restrict mattr, + int * __restrict prioceiling) { int ret = 0; diff --git a/lib/libthr/thread/thr_rwlock.c b/lib/libthr/thread/thr_rwlock.c index 139e74557a5..3eb837c0ff3 100644 --- a/lib/libthr/thread/thr_rwlock.c +++ b/lib/libthr/thread/thr_rwlock.c @@ -225,8 +225,8 @@ _pthread_rwlock_rdlock (pthread_rwlock_t *rwlock) } int -_pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock, - const struct timespec *abstime) +_pthread_rwlock_timedrdlock(pthread_rwlock_t * __restrict rwlock, + const struct timespec * __restrict abstime) { return (rwlock_rdlock_common(rwlock, abstime)); } @@ -337,8 +337,8 @@ _pthread_rwlock_wrlock (pthread_rwlock_t *rwlock) } int -_pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock, - const struct timespec *abstime) +_pthread_rwlock_timedwrlock(pthread_rwlock_t * __restrict rwlock, + const struct timespec * __restrict abstime) { return (rwlock_wrlock_common (rwlock, abstime)); } diff --git a/lib/libthr/thread/thr_rwlockattr.c b/lib/libthr/thread/thr_rwlockattr.c index 76013f59c30..b0b8e70a44c 100644 --- a/lib/libthr/thread/thr_rwlockattr.c +++ b/lib/libthr/thread/thr_rwlockattr.c @@ -57,8 +57,9 @@ _pthread_rwlockattr_destroy(pthread_rwlockattr_t *rwlockattr) } int -_pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *rwlockattr, - int *pshared) +_pthread_rwlockattr_getpshared( + const pthread_rwlockattr_t * __restrict rwlockattr, + int * __restrict pshared) { *pshared = (*rwlockattr)->pshared; diff --git a/share/man/man3/pthread.3 b/share/man/man3/pthread.3 index 9a0c5c80736..8a437b1cedb 100644 --- a/share/man/man3/pthread.3 +++ b/share/man/man3/pthread.3 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd August 12, 2014 +.Dd August 17, 2018 .Dt PTHREAD 3 .Os .Sh NAME @@ -236,17 +236,17 @@ Set the detach state in a thread attributes object. Destroy a mutex attributes object. .It Xo .Ft int -.Fn pthread_mutexattr_getprioceiling "pthread_mutexattr_t *attr" "int *ceiling" +.Fn pthread_mutexattr_getprioceiling "const pthread_mutexattr_t *restrict attr" "int *restrict ceiling" .Xc Obtain priority ceiling attribute of mutex attribute object. .It Xo .Ft int -.Fn pthread_mutexattr_getprotocol "pthread_mutexattr_t *attr" "int *protocol" +.Fn pthread_mutexattr_getprotocol "const pthread_mutexattr_t *restrict attr" "int *restrict protocol" .Xc Obtain protocol attribute of mutex attribute object. .It Xo .Ft int -.Fn pthread_mutexattr_gettype "pthread_mutexattr_t *attr" "int *type" +.Fn pthread_mutexattr_gettype "const pthread_mutexattr_t *restrict attr" "int *restrict type" .Xc Obtain the mutex type attribute in the specified mutex attributes object. .It Xo diff --git a/share/man/man3/pthread_attr.3 b/share/man/man3/pthread_attr.3 index d6d98012783..6ce889386d5 100644 --- a/share/man/man3/pthread_attr.3 +++ b/share/man/man3/pthread_attr.3 @@ -26,7 +26,7 @@ .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd January 8, 2010 +.Dd August 17, 2018 .Dt PTHREAD_ATTR 3 .Os .Sh NAME @@ -66,11 +66,11 @@ .Ft int .Fn pthread_attr_setstacksize "pthread_attr_t *attr" "size_t stacksize" .Ft int -.Fn pthread_attr_getstacksize "const pthread_attr_t *attr" "size_t *stacksize" +.Fn pthread_attr_getstacksize "const pthread_attr_t *restrict attr" "size_t *restrict stacksize" .Ft int .Fn pthread_attr_setguardsize "pthread_attr_t *attr" "size_t guardsize" .Ft int -.Fn pthread_attr_getguardsize "const pthread_attr_t *attr" "size_t *guardsize" +.Fn pthread_attr_getguardsize "const pthread_attr_t * restrict attr" "size_t * restrict guardsize" .Ft int .Fn pthread_attr_setstackaddr "pthread_attr_t *attr" "void *stackaddr" .Ft int @@ -82,7 +82,7 @@ .Ft int .Fn pthread_attr_setinheritsched "pthread_attr_t *attr" "int inheritsched" .Ft int -.Fn pthread_attr_getinheritsched "const pthread_attr_t *attr" "int *inheritsched" +.Fn pthread_attr_getinheritsched "const pthread_attr_t *restrict attr" "int *restrct inheritsched" .Ft int .Fn pthread_attr_setschedparam "pthread_attr_t *attr" "const struct sched_param *param" .Ft int @@ -90,11 +90,11 @@ .Ft int .Fn pthread_attr_setschedpolicy "pthread_attr_t *attr" "int policy" .Ft int -.Fn pthread_attr_getschedpolicy "const pthread_attr_t *attr" "int *policy" +.Fn pthread_attr_getschedpolicy "const pthread_attr_t *restrict attr" "int *restrict policy" .Ft int .Fn pthread_attr_setscope "pthread_attr_t *attr" "int contentionscope" .Ft int -.Fn pthread_attr_getscope "const pthread_attr_t *attr" "int *contentionscope" +.Fn pthread_attr_getscope "const pthread_attr_t *restrict attr" "int *restrict contentionscope" .Sh DESCRIPTION Thread attributes are used to specify parameters to .Fn pthread_create . diff --git a/share/man/man3/pthread_barrier_destroy.3 b/share/man/man3/pthread_barrier_destroy.3 index 1b150a5ab9f..fbbf88c00e9 100644 --- a/share/man/man3/pthread_barrier_destroy.3 +++ b/share/man/man3/pthread_barrier_destroy.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd February 19, 2004 +.Dd August 17, 2018 .Dt PTHREAD_BARRIER 3 .Os .Sh NAME @@ -37,7 +37,7 @@ .Ft int .Fn pthread_barrier_destroy "pthread_barrier_t *barrier" .Ft int -.Fn pthread_barrier_init "pthread_barrier_t *barrier" "const pthread_barrierattr_t *attr" "unsigned count" +.Fn pthread_barrier_init "pthread_barrier_t *restrict barrier" "const pthread_barrierattr_t *attr" "unsigned count" .Ft int .Fn pthread_barrier_wait "pthread_barrier_t *barrier" .Sh DESCRIPTION diff --git a/share/man/man3/pthread_barrierattr.3 b/share/man/man3/pthread_barrierattr.3 index bbf37d90cad..74c3c4f6333 100644 --- a/share/man/man3/pthread_barrierattr.3 +++ b/share/man/man3/pthread_barrierattr.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 31, 2016 +.Dd August 17, 2018 .Dt PTHREAD_BARRIERATTR 3 .Os .Sh NAME @@ -38,7 +38,7 @@ .Ft int .Fn pthread_barrierattr_destroy "pthread_barrierattr_t *attr" .Ft int -.Fn pthread_barrierattr_getpshared "const pthread_barrierattr_t *attr" "int *pshared" +.Fn pthread_barrierattr_getpshared "const pthread_barrierattr_t *restrict attr" "int *restrict pshared" .Ft int .Fn pthread_barrierattr_init "pthread_barrierattr_t *attr" .Ft int diff --git a/share/man/man3/pthread_cond_init.3 b/share/man/man3/pthread_cond_init.3 index 415ce02efaa..8f13a34fd75 100644 --- a/share/man/man3/pthread_cond_init.3 +++ b/share/man/man3/pthread_cond_init.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 4, 2006 +.Dd August 17, 2018 .Dt PTHREAD_COND_INIT 3 .Os .Sh NAME @@ -38,7 +38,7 @@ .Sh SYNOPSIS .In pthread.h .Ft int -.Fn pthread_cond_init "pthread_cond_t *cond" "const pthread_condattr_t *attr" +.Fn pthread_cond_init "pthread_cond_t *restrict cond" "const pthread_condattr_t *restrict attr" .Sh DESCRIPTION The .Fn pthread_cond_init diff --git a/share/man/man3/pthread_cond_wait.3 b/share/man/man3/pthread_cond_wait.3 index 427c34717bb..ed6b73ee239 100644 --- a/share/man/man3/pthread_cond_wait.3 +++ b/share/man/man3/pthread_cond_wait.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 29, 2016 +.Dd August 17, 2018 .Dt PTHREAD_COND_WAIT 3 .Os .Sh NAME @@ -38,7 +38,7 @@ .Sh SYNOPSIS .In pthread.h .Ft int -.Fn pthread_cond_wait "pthread_cond_t *cond" "pthread_mutex_t *mutex" +.Fn pthread_cond_wait "pthread_cond_t *restrict cond" "pthread_mutex_t *restrict mutex" .Sh DESCRIPTION The .Fn pthread_cond_wait diff --git a/share/man/man3/pthread_create.3 b/share/man/man3/pthread_create.3 index 43d9ed2fcae..3cb7760e26b 100644 --- a/share/man/man3/pthread_create.3 +++ b/share/man/man3/pthread_create.3 @@ -30,7 +30,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 2, 2016 +.Dd August 17, 2018 .Dt PTHREAD_CREATE 3 .Os .Sh NAME @@ -41,7 +41,7 @@ .Sh SYNOPSIS .In pthread.h .Ft int -.Fn pthread_create "pthread_t *thread" "const pthread_attr_t *attr" "void *(*start_routine)(void *)" "void *arg" +.Fn pthread_create "pthread_t *restrict thread" "const pthread_attr_t *restrict attr" "void *(*start_routine)(void *)" "void *restrict arg" .Sh DESCRIPTION The .Fn pthread_create diff --git a/share/man/man3/pthread_mutex_init.3 b/share/man/man3/pthread_mutex_init.3 index a5a1eca0df1..934a323d3a3 100644 --- a/share/man/man3/pthread_mutex_init.3 +++ b/share/man/man3/pthread_mutex_init.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd November 4, 2006 +.Dd August 17, 2018 .Dt PTHREAD_MUTEX_INIT 3 .Os .Sh NAME @@ -38,7 +38,7 @@ .Sh SYNOPSIS .In pthread.h .Ft int -.Fn pthread_mutex_init "pthread_mutex_t *mutex" "const pthread_mutexattr_t *attr" +.Fn pthread_mutex_init "pthread_mutex_t *restrict mutex" "const pthread_mutexattr_t *restrict attr" .Sh DESCRIPTION The .Fn pthread_mutex_init diff --git a/share/man/man3/pthread_mutex_timedlock.3 b/share/man/man3/pthread_mutex_timedlock.3 index 384ee9dd4ae..26ea0a2a02c 100644 --- a/share/man/man3/pthread_mutex_timedlock.3 +++ b/share/man/man3/pthread_mutex_timedlock.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd April 29, 2016 +.Dd August 17, 2018 .Dt PTHREAD_MUTEX_TIMEDLOCK 3 .Os .Sh NAME @@ -36,7 +36,7 @@ .In pthread.h .In time.h .Ft int -.Fn pthread_mutex_timedlock "pthread_mutex_t *mutex" "const struct timespec *abs_timeout" +.Fn pthread_mutex_timedlock "pthread_mutex_t *restrict mutex" "const struct timespec *restrict abs_timeout" .Sh DESCRIPTION The .Fn pthread_mutex_timedlock diff --git a/share/man/man3/pthread_mutexattr.3 b/share/man/man3/pthread_mutexattr.3 index e7042d532f2..61773a4e2eb 100644 --- a/share/man/man3/pthread_mutexattr.3 +++ b/share/man/man3/pthread_mutexattr.3 @@ -26,7 +26,7 @@ .\" EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd April 29, 2016 +.Dd August 17, 2018 .Dt PTHREAD_MUTEXATTR 3 .Os .Sh NAME @@ -52,11 +52,11 @@ .Ft int .Fn pthread_mutexattr_setprioceiling "pthread_mutexattr_t *attr" "int prioceiling" .Ft int -.Fn pthread_mutexattr_getprioceiling "pthread_mutexattr_t *attr" "int *prioceiling" +.Fn pthread_mutexattr_getprioceiling "const pthread_mutexattr_t *attr" "int *prioceiling" .Ft int .Fn pthread_mutexattr_setprotocol "pthread_mutexattr_t *attr" "int protocol" .Ft int -.Fn pthread_mutexattr_getprotocol "pthread_mutexattr_t *attr" "int *protocol" +.Fn pthread_mutexattr_getprotocol "const pthread_mutexattr_t *restrict attr" "int *restrict protocol" .Ft int .Fn pthread_mutexattr_setrobust "pthread_mutexattr_t *attr" "int robust" .Ft int @@ -64,7 +64,7 @@ .Ft int .Fn pthread_mutexattr_settype "pthread_mutexattr_t *attr" "int type" .Ft int -.Fn pthread_mutexattr_gettype "pthread_mutexattr_t *attr" "int *type" +.Fn pthread_mutexattr_gettype "const pthread_mutexattr_t *restrict attr" "int *restrict type" .Sh DESCRIPTION Mutex attributes are used to specify parameters to .Fn pthread_mutex_init . diff --git a/share/man/man3/pthread_rwlock_init.3 b/share/man/man3/pthread_rwlock_init.3 index 1b0023c59ba..3b99032889d 100644 --- a/share/man/man3/pthread_rwlock_init.3 +++ b/share/man/man3/pthread_rwlock_init.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd May 31, 2016 +.Dd August 17, 2018 .Dt PTHREAD_RWLOCK_INIT 3 .Os .Sh NAME @@ -35,7 +35,7 @@ .Sh SYNOPSIS .In pthread.h .Ft int -.Fn pthread_rwlock_init "pthread_rwlock_t *lock" "const pthread_rwlockattr_t *attr" +.Fn pthread_rwlock_init "pthread_rwlock_t *restrict lock" "const pthread_rwlockattr_t *restrict attr" .Sh DESCRIPTION The .Fn pthread_rwlock_init diff --git a/share/man/man3/pthread_rwlock_timedrdlock.3 b/share/man/man3/pthread_rwlock_timedrdlock.3 index 78b74700ce7..2f012f516c1 100644 --- a/share/man/man3/pthread_rwlock_timedrdlock.3 +++ b/share/man/man3/pthread_rwlock_timedrdlock.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 16, 2004 +.Dd August 17, 2018 .Dt PTHREAD_RWLOCK_TIMEDRDLOCK 3 .Os .Sh NAME @@ -35,7 +35,7 @@ .Sh SYNOPSIS .In pthread.h .Ft int -.Fn pthread_rwlock_timedrdlock "pthread_rwlock_t *rwlock" "const struct timespec *abs_timeout" +.Fn pthread_rwlock_timedrdlock "pthread_rwlock_t *restrict rwlock" "const struct timespec *restrict abs_timeout" .Sh DESCRIPTION This function acquires a read lock on the read-write lock .Fa rwlock . diff --git a/share/man/man3/pthread_rwlock_timedwrlock.3 b/share/man/man3/pthread_rwlock_timedwrlock.3 index 0941dbb99fa..041c0e54cd4 100644 --- a/share/man/man3/pthread_rwlock_timedwrlock.3 +++ b/share/man/man3/pthread_rwlock_timedwrlock.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd January 16, 2004 +.Dd August 17, 2018 .Dt PTHREAD_RWLOCK_TIMEDWRLOCK 3 .Os .Sh NAME @@ -35,7 +35,7 @@ .Sh SYNOPSIS .In pthread.h .Ft int -.Fn pthread_rwlock_timedwrlock "pthread_rwlock_t *rwlock" "const struct timespec *abs_timeout" +.Fn pthread_rwlock_timedwrlock "pthread_rwlock_t *restrict rwlock" "const struct timespec *restrict abs_timeout" .Sh DESCRIPTION This function acquires a write lock on the read-write lock .Fa rwlock . diff --git a/share/man/man3/pthread_rwlockattr_getpshared.3 b/share/man/man3/pthread_rwlockattr_getpshared.3 index 3e2f451dc72..63ef5240939 100644 --- a/share/man/man3/pthread_rwlockattr_getpshared.3 +++ b/share/man/man3/pthread_rwlockattr_getpshared.3 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd March 22, 1999 +.Dd August 17, 2018 .Dt PTHREAD_RWLOCKATTR_GETPSHARED 3 .Os .Sh NAME @@ -35,7 +35,7 @@ .Sh SYNOPSIS .In pthread.h .Ft int -.Fn pthread_rwlockattr_getpshared "const pthread_rwlockattr_t *attr" "int *pshared" +.Fn pthread_rwlockattr_getpshared "const pthread_rwlockattr_t *restrict attr" "int *restrict pshared" .Sh DESCRIPTION The .Fn pthread_rwlockattr_getpshared diff --git a/share/man/man3/pthread_schedparam.3 b/share/man/man3/pthread_schedparam.3 index 52d72cc1dd9..9d8b98a89d9 100644 --- a/share/man/man3/pthread_schedparam.3 +++ b/share/man/man3/pthread_schedparam.3 @@ -27,7 +27,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 16, 2006 +.Dd August 17, 2018 .Dt PTHREAD_SCHEDPARAM 3 .Os .Sh NAME @@ -41,7 +41,7 @@ .Ft int .Fn pthread_setschedparam "pthread_t thread" "int policy" "const struct sched_param *param" .Ft int -.Fn pthread_getschedparam "pthread_t thread" "int *policy" "struct sched_param *param" +.Fn pthread_getschedparam "pthread_t thread" "int *restrict policy" "struct sched_param *restrict param" .Sh DESCRIPTION The .Fn pthread_setschedparam -- 2.45.0