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/time/__asctime.c | 2 +- src/time/asctime_r.c | 4 ++-- src/time/gettimeofday.c | 2 +- src/time/gmtime_r.c | 2 +- src/time/localtime_r.c | 2 +- src/time/strftime.c | 2 +- src/time/strptime.c | 2 +- src/time/timer_create.c | 2 +- src/time/timer_settime.c | 2 +- src/time/wcsftime.c | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/time') diff --git a/src/time/__asctime.c b/src/time/__asctime.c index 7cc4f503..5362f0db 100644 --- a/src/time/__asctime.c +++ b/src/time/__asctime.c @@ -5,7 +5,7 @@ const char *__langinfo(nl_item); -char *__asctime(const struct tm *tm, char *buf) +char *__asctime(const struct tm *restrict tm, char *restrict buf) { /* FIXME: change __langinfo to __C_langinfo once we have locales */ if (snprintf(buf, 26, "%.3s %.3s%3d %.2d:%.2d:%.2d %d\n", diff --git a/src/time/asctime_r.c b/src/time/asctime_r.c index e51b8804..7dfbb121 100644 --- a/src/time/asctime_r.c +++ b/src/time/asctime_r.c @@ -1,8 +1,8 @@ #include -char *__asctime(const struct tm *, char *); +char *__asctime(const struct tm *restrict, char *restrict); -char *asctime_r(const struct tm *tm, char *buf) +char *asctime_r(const struct tm *restrict tm, char *restrict buf) { return __asctime(tm, buf); } diff --git a/src/time/gettimeofday.c b/src/time/gettimeofday.c index 09afb70b..691f8e90 100644 --- a/src/time/gettimeofday.c +++ b/src/time/gettimeofday.c @@ -2,7 +2,7 @@ #include #include "syscall.h" -int gettimeofday(struct timeval *tv, void *tz) +int gettimeofday(struct timeval *restrict tv, void *restrict tz) { struct timespec ts; if (!tv) return 0; diff --git a/src/time/gmtime_r.c b/src/time/gmtime_r.c index 5b565a65..13a2548f 100644 --- a/src/time/gmtime_r.c +++ b/src/time/gmtime_r.c @@ -2,7 +2,7 @@ #include "__time.h" -struct tm *gmtime_r(const time_t *t, struct tm *result) +struct tm *gmtime_r(const time_t *restrict t, struct tm *restrict result) { __time_to_tm(*t, result); result->tm_isdst = 0; diff --git a/src/time/localtime_r.c b/src/time/localtime_r.c index 2bf10378..389a5917 100644 --- a/src/time/localtime_r.c +++ b/src/time/localtime_r.c @@ -2,7 +2,7 @@ #include "__time.h" -struct tm *localtime_r(const time_t *t, struct tm *result) +struct tm *localtime_r(const time_t *restrict t, struct tm *restrict result) { __tzset(); __time_to_tm(*t - __timezone, result); diff --git a/src/time/strftime.c b/src/time/strftime.c index f1b94631..b69a83a4 100644 --- a/src/time/strftime.c +++ b/src/time/strftime.c @@ -8,7 +8,7 @@ const char *__langinfo(nl_item); -size_t strftime(char *s, size_t n, const char *f, const struct tm *tm) +size_t strftime(char *restrict s, size_t n, const char *restrict f, const struct tm *restrict tm) { nl_item item; int val; diff --git a/src/time/strptime.c b/src/time/strptime.c index 4c0bb26c..0f66e6c6 100644 --- a/src/time/strptime.c +++ b/src/time/strptime.c @@ -7,7 +7,7 @@ #include #include -char *strptime(const char *s, const char *f, struct tm *tm) +char *strptime(const char *restrict s, const char *restrict f, struct tm *restrict tm) { int i, w, neg, adj, min, range, *dest; const char *ex; diff --git a/src/time/timer_create.c b/src/time/timer_create.c index 813678a1..560f1a84 100644 --- a/src/time/timer_create.c +++ b/src/time/timer_create.c @@ -76,7 +76,7 @@ static void *start(void *arg) return 0; } -int timer_create(clockid_t clk, struct sigevent *evp, timer_t *res) +int timer_create(clockid_t clk, struct sigevent *restrict evp, timer_t *restrict res) { static pthread_once_t once = PTHREAD_ONCE_INIT; pthread_t td; diff --git a/src/time/timer_settime.c b/src/time/timer_settime.c index c400d45c..baf5076b 100644 --- a/src/time/timer_settime.c +++ b/src/time/timer_settime.c @@ -1,7 +1,7 @@ #include #include "pthread_impl.h" -int timer_settime(timer_t t, int flags, const struct itimerspec *val, struct itimerspec *old) +int timer_settime(timer_t t, int flags, const struct itimerspec *restrict val, struct itimerspec *restrict old) { if ((uintptr_t)t >= 0x100000) t = ((pthread_t)t)->result; return syscall(SYS_timer_settime, (long)t, flags, val, old); diff --git a/src/time/wcsftime.c b/src/time/wcsftime.c index 7db76922..da6c1f8a 100644 --- a/src/time/wcsftime.c +++ b/src/time/wcsftime.c @@ -2,7 +2,7 @@ #include #include -size_t wcsftime(wchar_t *wcs, size_t n, const wchar_t *f, const struct tm *tm) +size_t wcsftime(wchar_t *restrict wcs, size_t n, const wchar_t *restrict f, const struct tm *restrict tm) { size_t k, n0=n; char out[100], in[4]; -- cgit v1.2.1