path: root/src/time
diff options
authorRich Felker <>2012-09-06 22:44:55 -0400
committerRich Felker <>2012-09-06 22:44:55 -0400
commit400c5e5c8307a2ebe44ef1f203f5a15669f20347 (patch)
tree087a48dc8251fa05f6866af8ebf96b69450b15ab /src/time
parentbac03cdde1137c16b4c194e137310e2748661dcc (diff)
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.
Diffstat (limited to 'src/time')
10 files changed, 11 insertions, 11 deletions
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 <time.h>
-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 <sys/time.h>
#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)
__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 <string.h>
#include <strings.h>
-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 <time.h>
#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 <time.h>
#include <string.h>
-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];