From 400c5e5c8307a2ebe44ef1f203f5a15669f20347 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 6 Sep 2012 22:44:55 -0400 Subject: use restrict everywhere it's required by c99 and/or posix 2008 to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict. --- src/thread/pthread_attr_getguardsize.c | 2 +- src/thread/pthread_attr_getschedparam.c | 2 +- src/thread/pthread_attr_getscope.c | 2 +- src/thread/pthread_attr_getstack.c | 2 +- src/thread/pthread_attr_getstacksize.c | 2 +- src/thread/pthread_attr_setschedparam.c | 2 +- src/thread/pthread_barrier_init.c | 2 +- src/thread/pthread_barrierattr_getpshared.c | 2 +- src/thread/pthread_cond_init.c | 2 +- src/thread/pthread_cond_timedwait.c | 2 +- src/thread/pthread_cond_wait.c | 2 +- src/thread/pthread_condattr_getclock.c | 2 +- src/thread/pthread_condattr_getpshared.c | 2 +- src/thread/pthread_create.c | 2 +- src/thread/pthread_mutex_init.c | 2 +- src/thread/pthread_mutex_timedlock.c | 2 +- src/thread/pthread_mutexattr_getpshared.c | 2 +- src/thread/pthread_mutexattr_getrobust.c | 2 +- src/thread/pthread_mutexattr_gettype.c | 2 +- src/thread/pthread_rwlock_init.c | 2 +- src/thread/pthread_rwlock_timedrdlock.c | 2 +- src/thread/pthread_rwlock_timedwrlock.c | 2 +- src/thread/pthread_rwlockattr_getpshared.c | 2 +- src/thread/pthread_sigmask.c | 2 +- src/thread/sem_getvalue.c | 2 +- src/thread/sem_timedwait.c | 2 +- 26 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/thread') diff --git a/src/thread/pthread_attr_getguardsize.c b/src/thread/pthread_attr_getguardsize.c index 71133f80..93ba05dd 100644 --- a/src/thread/pthread_attr_getguardsize.c +++ b/src/thread/pthread_attr_getguardsize.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_attr_getguardsize(const pthread_attr_t *a, size_t *size) +int pthread_attr_getguardsize(const pthread_attr_t *restrict a, size_t *restrict size) { *size = a->_a_guardsize + DEFAULT_GUARD_SIZE; return 0; diff --git a/src/thread/pthread_attr_getschedparam.c b/src/thread/pthread_attr_getschedparam.c index 804f6f0f..5806bdf1 100644 --- a/src/thread/pthread_attr_getschedparam.c +++ b/src/thread/pthread_attr_getschedparam.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_attr_getschedparam(const pthread_attr_t *a, struct sched_param *param) +int pthread_attr_getschedparam(const pthread_attr_t *restrict a, struct sched_param *restrict param) { param->sched_priority = 0; return 0; diff --git a/src/thread/pthread_attr_getscope.c b/src/thread/pthread_attr_getscope.c index fc42a52f..c0167b6a 100644 --- a/src/thread/pthread_attr_getscope.c +++ b/src/thread/pthread_attr_getscope.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_attr_getscope(const pthread_attr_t *a, int *scope) +int pthread_attr_getscope(const pthread_attr_t *restrict a, int *restrict scope) { return 0; } diff --git a/src/thread/pthread_attr_getstack.c b/src/thread/pthread_attr_getstack.c index 07ac5926..70adbb03 100644 --- a/src/thread/pthread_attr_getstack.c +++ b/src/thread/pthread_attr_getstack.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_attr_getstack(const pthread_attr_t *a, void **addr, size_t *size) +int pthread_attr_getstack(const pthread_attr_t *restrict a, void **restrict addr, size_t *restrict size) { if (!a->_a_stackaddr) return EINVAL; diff --git a/src/thread/pthread_attr_getstacksize.c b/src/thread/pthread_attr_getstacksize.c index 9575203d..f69cc1e6 100644 --- a/src/thread/pthread_attr_getstacksize.c +++ b/src/thread/pthread_attr_getstacksize.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_attr_getstacksize(const pthread_attr_t *a, size_t *size) +int pthread_attr_getstacksize(const pthread_attr_t *restrict a, size_t *restrict size) { *size = a->_a_stacksize + DEFAULT_STACK_SIZE; return 0; diff --git a/src/thread/pthread_attr_setschedparam.c b/src/thread/pthread_attr_setschedparam.c index b305f2fa..77ce9c98 100644 --- a/src/thread/pthread_attr_setschedparam.c +++ b/src/thread/pthread_attr_setschedparam.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_attr_setschedparam(pthread_attr_t *a, const struct sched_param *param) +int pthread_attr_setschedparam(pthread_attr_t *restrict a, const struct sched_param *restrict param) { if (param->sched_priority) return ENOTSUP; return 0; diff --git a/src/thread/pthread_barrier_init.c b/src/thread/pthread_barrier_init.c index ccaab4eb..01e8cd6b 100644 --- a/src/thread/pthread_barrier_init.c +++ b/src/thread/pthread_barrier_init.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_barrier_init(pthread_barrier_t *b, const pthread_barrierattr_t *a, unsigned count) +int pthread_barrier_init(pthread_barrier_t *restrict b, const pthread_barrierattr_t *restrict a, unsigned count) { if (count-1 > INT_MAX-1) return EINVAL; *b = (pthread_barrier_t){ ._b_limit = count-1 | (a?*a:0) }; diff --git a/src/thread/pthread_barrierattr_getpshared.c b/src/thread/pthread_barrierattr_getpshared.c index 8428bbec..df337c29 100644 --- a/src/thread/pthread_barrierattr_getpshared.c +++ b/src/thread/pthread_barrierattr_getpshared.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_barrierattr_getpshared(const pthread_barrierattr_t *a, int *pshared) +int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared) { *pshared = !!*a; return 0; diff --git a/src/thread/pthread_cond_init.c b/src/thread/pthread_cond_init.c index 03aff768..2eac30f1 100644 --- a/src/thread/pthread_cond_init.c +++ b/src/thread/pthread_cond_init.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_cond_init(pthread_cond_t *c, const pthread_condattr_t *a) +int pthread_cond_init(pthread_cond_t *restrict c, const pthread_condattr_t *restrict a) { memset(c, 0, sizeof *c); if (a) { diff --git a/src/thread/pthread_cond_timedwait.c b/src/thread/pthread_cond_timedwait.c index 1d0f578c..1f25c8e7 100644 --- a/src/thread/pthread_cond_timedwait.c +++ b/src/thread/pthread_cond_timedwait.c @@ -36,7 +36,7 @@ static void cleanup(void *p) pthread_mutex_lock(cm->m); } -int pthread_cond_timedwait(pthread_cond_t *c, pthread_mutex_t *m, const struct timespec *ts) +int pthread_cond_timedwait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m, const struct timespec *restrict ts) { struct cm cm = { .c=c, .m=m }; int r, e=0, seq; diff --git a/src/thread/pthread_cond_wait.c b/src/thread/pthread_cond_wait.c index eb70e5f7..8735bf14 100644 --- a/src/thread/pthread_cond_wait.c +++ b/src/thread/pthread_cond_wait.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_cond_wait(pthread_cond_t *c, pthread_mutex_t *m) +int pthread_cond_wait(pthread_cond_t *restrict c, pthread_mutex_t *restrict m) { return pthread_cond_timedwait(c, m, 0); } diff --git a/src/thread/pthread_condattr_getclock.c b/src/thread/pthread_condattr_getclock.c index a77cc3e0..d2933843 100644 --- a/src/thread/pthread_condattr_getclock.c +++ b/src/thread/pthread_condattr_getclock.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_condattr_getclock(const pthread_condattr_t *a, clockid_t *clk) +int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk) { *clk = *a & 0x7fffffff; return 0; diff --git a/src/thread/pthread_condattr_getpshared.c b/src/thread/pthread_condattr_getpshared.c index b620976c..4991e495 100644 --- a/src/thread/pthread_condattr_getpshared.c +++ b/src/thread/pthread_condattr_getpshared.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_condattr_getpshared(const pthread_condattr_t *a, int *pshared) +int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared) { *pshared = *a>>31; return 0; diff --git a/src/thread/pthread_create.c b/src/thread/pthread_create.c index 52b48d6f..4567b41c 100644 --- a/src/thread/pthread_create.c +++ b/src/thread/pthread_create.c @@ -84,7 +84,7 @@ static void init_file_lock(FILE *f) if (f && f->lock<0) f->lock = 0; } -int pthread_create(pthread_t *res, const pthread_attr_t *attr, void *(*entry)(void *), void *arg) +int pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict attr, void *(*entry)(void *), void *restrict arg) { int ret; size_t size = DEFAULT_STACK_SIZE + DEFAULT_GUARD_SIZE; diff --git a/src/thread/pthread_mutex_init.c b/src/thread/pthread_mutex_init.c index 75ddf02b..fb689271 100644 --- a/src/thread/pthread_mutex_init.c +++ b/src/thread/pthread_mutex_init.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_mutex_init(pthread_mutex_t *m, const pthread_mutexattr_t *a) +int pthread_mutex_init(pthread_mutex_t *restrict m, const pthread_mutexattr_t *restrict a) { memset(m, 0, sizeof *m); if (a) m->_m_type = *a & 7; diff --git a/src/thread/pthread_mutex_timedlock.c b/src/thread/pthread_mutex_timedlock.c index 44bd4bbe..c24270d8 100644 --- a/src/thread/pthread_mutex_timedlock.c +++ b/src/thread/pthread_mutex_timedlock.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *at) +int pthread_mutex_timedlock(pthread_mutex_t *restrict m, const struct timespec *restrict at) { int r, t; diff --git a/src/thread/pthread_mutexattr_getpshared.c b/src/thread/pthread_mutexattr_getpshared.c index 3e0438b3..e7340b1a 100644 --- a/src/thread/pthread_mutexattr_getpshared.c +++ b/src/thread/pthread_mutexattr_getpshared.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_mutexattr_getpshared(const pthread_mutexattr_t *a, int *pshared) +int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared) { *pshared = *a>>31; return 0; diff --git a/src/thread/pthread_mutexattr_getrobust.c b/src/thread/pthread_mutexattr_getrobust.c index b83cb7c6..4d176f20 100644 --- a/src/thread/pthread_mutexattr_getrobust.c +++ b/src/thread/pthread_mutexattr_getrobust.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_mutexattr_getrobust(const pthread_mutexattr_t *a, int *robust) +int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust) { *robust = *a / 4U % 2; return 0; diff --git a/src/thread/pthread_mutexattr_gettype.c b/src/thread/pthread_mutexattr_gettype.c index 9edb16c6..7688b068 100644 --- a/src/thread/pthread_mutexattr_gettype.c +++ b/src/thread/pthread_mutexattr_gettype.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_mutexattr_gettype(const pthread_mutexattr_t *a, int *type) +int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type) { *type = *a & 3; return 0; diff --git a/src/thread/pthread_rwlock_init.c b/src/thread/pthread_rwlock_init.c index f87d566c..29003bc6 100644 --- a/src/thread/pthread_rwlock_init.c +++ b/src/thread/pthread_rwlock_init.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_rwlock_init(pthread_rwlock_t *rw, const pthread_rwlockattr_t *a) +int pthread_rwlock_init(pthread_rwlock_t *restrict rw, const pthread_rwlockattr_t *restrict a) { memset(rw, 0, sizeof *rw); if (a) { diff --git a/src/thread/pthread_rwlock_timedrdlock.c b/src/thread/pthread_rwlock_timedrdlock.c index b5cb404a..c0c94c97 100644 --- a/src/thread/pthread_rwlock_timedrdlock.c +++ b/src/thread/pthread_rwlock_timedrdlock.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_rwlock_timedrdlock(pthread_rwlock_t *rw, const struct timespec *at) +int pthread_rwlock_timedrdlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at) { int r, t; while ((r=pthread_rwlock_tryrdlock(rw))==EBUSY) { diff --git a/src/thread/pthread_rwlock_timedwrlock.c b/src/thread/pthread_rwlock_timedwrlock.c index aa2fd199..339a1679 100644 --- a/src/thread/pthread_rwlock_timedwrlock.c +++ b/src/thread/pthread_rwlock_timedwrlock.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_rwlock_timedwrlock(pthread_rwlock_t *rw, const struct timespec *at) +int pthread_rwlock_timedwrlock(pthread_rwlock_t *restrict rw, const struct timespec *restrict at) { int r, t; while ((r=pthread_rwlock_trywrlock(rw))==EBUSY) { diff --git a/src/thread/pthread_rwlockattr_getpshared.c b/src/thread/pthread_rwlockattr_getpshared.c index 0217bf4e..02fd8c80 100644 --- a/src/thread/pthread_rwlockattr_getpshared.c +++ b/src/thread/pthread_rwlockattr_getpshared.c @@ -1,6 +1,6 @@ #include "pthread_impl.h" -int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *a, int *pshared) +int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared) { *pshared = *(int *)a; return 0; diff --git a/src/thread/pthread_sigmask.c b/src/thread/pthread_sigmask.c index cddc2bca..f6102ad4 100644 --- a/src/thread/pthread_sigmask.c +++ b/src/thread/pthread_sigmask.c @@ -3,7 +3,7 @@ #include #include "syscall.h" -int pthread_sigmask(int how, const sigset_t *set, sigset_t *old) +int pthread_sigmask(int how, const sigset_t *restrict set, sigset_t *restrict old) { int ret; if ((unsigned)how - SIG_BLOCK > 2U) return EINVAL; diff --git a/src/thread/sem_getvalue.c b/src/thread/sem_getvalue.c index 643c0968..d9d83071 100644 --- a/src/thread/sem_getvalue.c +++ b/src/thread/sem_getvalue.c @@ -1,6 +1,6 @@ #include -int sem_getvalue(sem_t *sem, int *valp) +int sem_getvalue(sem_t *restrict sem, int *restrict valp) { int val = sem->__val[0]; *valp = val < 0 ? 0 : val; diff --git a/src/thread/sem_timedwait.c b/src/thread/sem_timedwait.c index 64b4342c..6d0d0114 100644 --- a/src/thread/sem_timedwait.c +++ b/src/thread/sem_timedwait.c @@ -6,7 +6,7 @@ static void cleanup(void *p) a_dec(p); } -int sem_timedwait(sem_t *sem, const struct timespec *at) +int sem_timedwait(sem_t *restrict sem, const struct timespec *restrict at) { while (sem_trywait(sem)) { int r; -- cgit v1.2.1