svn commit: r337992 - in head: include lib/libthr/thread share/man/man3

Pedro F. Giffuni pfg at FreeBSD.org
Sat Aug 18 01:05:45 UTC 2018


Author: pfg
Date: Sat Aug 18 01:05:38 2018
New Revision: 337992
URL: https://svnweb.freebsd.org/changeset/base/337992

Log:
  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

Modified:
  head/include/pthread.h
  head/lib/libthr/thread/thr_attr.c
  head/lib/libthr/thread/thr_barrier.c
  head/lib/libthr/thread/thr_barrierattr.c
  head/lib/libthr/thread/thr_cond.c
  head/lib/libthr/thread/thr_condattr.c
  head/lib/libthr/thread/thr_create.c
  head/lib/libthr/thread/thr_getschedparam.c
  head/lib/libthr/thread/thr_mutex.c
  head/lib/libthr/thread/thr_mutexattr.c
  head/lib/libthr/thread/thr_rwlock.c
  head/lib/libthr/thread/thr_rwlockattr.c
  head/share/man/man3/pthread.3
  head/share/man/man3/pthread_attr.3
  head/share/man/man3/pthread_barrier_destroy.3
  head/share/man/man3/pthread_barrierattr.3
  head/share/man/man3/pthread_cond_init.3
  head/share/man/man3/pthread_cond_wait.3
  head/share/man/man3/pthread_create.3
  head/share/man/man3/pthread_mutex_init.3
  head/share/man/man3/pthread_mutex_timedlock.3
  head/share/man/man3/pthread_mutexattr.3
  head/share/man/man3/pthread_rwlock_init.3
  head/share/man/man3/pthread_rwlock_timedrdlock.3
  head/share/man/man3/pthread_rwlock_timedwrlock.3
  head/share/man/man3/pthread_rwlockattr_getpshared.3
  head/share/man/man3/pthread_schedparam.3

Modified: head/include/pthread.h
==============================================================================
--- head/include/pthread.h	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/include/pthread.h	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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_barrieratt
 		}
 
 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 (*) (voi
 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

Modified: head/lib/libthr/thread/thr_attr.c
==============================================================================
--- head/lib/libthr/thread/thr_attr.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_attr.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -199,7 +199,8 @@ _pthread_attr_getdetachstate(const pthread_attr_t *att
 __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,
 __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 *at
 __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
 __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 *att
 __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,
 __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, in
 __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;
 

Modified: head/lib/libthr/thread/thr_barrier.c
==============================================================================
--- head/lib/libthr/thread/thr_barrier.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_barrier.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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;

Modified: head/lib/libthr/thread/thr_barrierattr.c
==============================================================================
--- head/lib/libthr/thread/thr_barrierattr.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_barrierattr.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -58,8 +58,8 @@ _pthread_barrierattr_destroy(pthread_barrierattr_t *at
 }
 
 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)

Modified: head/lib/libthr/thread/thr_cond.c
==============================================================================
--- head/lib/libthr/thread/thr_cond.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_cond.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -149,7 +149,8 @@ init_static(struct pthread *thread, pthread_cond_t *co
 	}
 
 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
 }
 
 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 ||

Modified: head/lib/libthr/thread/thr_condattr.c
==============================================================================
--- head/lib/libthr/thread/thr_condattr.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_condattr.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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, c
 }
 
 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)

Modified: head/lib/libthr/thread/thr_create.c
==============================================================================
--- head/lib/libthr/thread/thr_create.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_create.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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;

Modified: head/lib/libthr/thread/thr_getschedparam.c
==============================================================================
--- head/lib/libthr/thread/thr_getschedparam.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_getschedparam.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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;

Modified: head/lib/libthr/thread/thr_mutex.c
==============================================================================
--- head/lib/libthr/thread/thr_mutex.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_mutex.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -66,12 +66,12 @@ _Static_assert(sizeof(struct pthread_mutex) <= PAGE_SI
  * 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 st
 }
 
 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
-_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;

Modified: head/lib/libthr/thread/thr_mutexattr.c
==============================================================================
--- head/lib/libthr/thread/thr_mutexattr.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_mutexattr.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -150,7 +150,8 @@ _pthread_mutexattr_settype(pthread_mutexattr_t *attr, 
 }
 
 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 *att
 }
 
 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 *ma
 }
 
 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;
 

Modified: head/lib/libthr/thread/thr_rwlock.c
==============================================================================
--- head/lib/libthr/thread/thr_rwlock.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_rwlock.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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));
 }

Modified: head/lib/libthr/thread/thr_rwlockattr.c
==============================================================================
--- head/lib/libthr/thread/thr_rwlockattr.c	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/lib/libthr/thread/thr_rwlockattr.c	Sat Aug 18 01:05:38 2018	(r337992)
@@ -57,8 +57,9 @@ _pthread_rwlockattr_destroy(pthread_rwlockattr_t *rwlo
 }
 
 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;

Modified: head/share/man/man3/pthread.3
==============================================================================
--- head/share/man/man3/pthread.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_attr.3
==============================================================================
--- head/share/man/man3/pthread_attr.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_attr.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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 .

Modified: head/share/man/man3/pthread_barrier_destroy.3
==============================================================================
--- head/share/man/man3/pthread_barrier_destroy.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_barrier_destroy.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_barrierattr.3
==============================================================================
--- head/share/man/man3/pthread_barrierattr.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_barrierattr.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_cond_init.3
==============================================================================
--- head/share/man/man3/pthread_cond_init.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_cond_init.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_cond_wait.3
==============================================================================
--- head/share/man/man3/pthread_cond_wait.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_cond_wait.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_create.3
==============================================================================
--- head/share/man/man3/pthread_create.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_create.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_mutex_init.3
==============================================================================
--- head/share/man/man3/pthread_mutex_init.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_mutex_init.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_mutex_timedlock.3
==============================================================================
--- head/share/man/man3/pthread_mutex_timedlock.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_mutex_timedlock.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_mutexattr.3
==============================================================================
--- head/share/man/man3/pthread_mutexattr.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_mutexattr.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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 .

Modified: head/share/man/man3/pthread_rwlock_init.3
==============================================================================
--- head/share/man/man3/pthread_rwlock_init.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_rwlock_init.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_rwlock_timedrdlock.3
==============================================================================
--- head/share/man/man3/pthread_rwlock_timedrdlock.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_rwlock_timedrdlock.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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 .

Modified: head/share/man/man3/pthread_rwlock_timedwrlock.3
==============================================================================
--- head/share/man/man3/pthread_rwlock_timedwrlock.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_rwlock_timedwrlock.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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 .

Modified: head/share/man/man3/pthread_rwlockattr_getpshared.3
==============================================================================
--- head/share/man/man3/pthread_rwlockattr_getpshared.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_rwlockattr_getpshared.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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

Modified: head/share/man/man3/pthread_schedparam.3
==============================================================================
--- head/share/man/man3/pthread_schedparam.3	Fri Aug 17 21:19:18 2018	(r337991)
+++ head/share/man/man3/pthread_schedparam.3	Sat Aug 18 01:05:38 2018	(r337992)
@@ -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


More information about the svn-src-all mailing list