summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-09-06 22:44:55 -0400
committerRich Felker <dalias@aerifal.cx>2012-09-06 22:44:55 -0400
commit400c5e5c8307a2ebe44ef1f203f5a15669f20347 (patch)
tree087a48dc8251fa05f6866af8ebf96b69450b15ab /src
parentbac03cdde1137c16b4c194e137310e2748661dcc (diff)
downloadmusl-400c5e5c8307a2ebe44ef1f203f5a15669f20347.tar.gz
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')
-rw-r--r--src/aio/lio_listio.c4
-rw-r--r--src/dirent/readdir_r.c2
-rw-r--r--src/ldso/dlsym.c4
-rw-r--r--src/ldso/dynlink.c4
-rw-r--r--src/locale/iconv.c2
-rw-r--r--src/locale/strfmon.c4
-rw-r--r--src/locale/strftime_l.c2
-rw-r--r--src/locale/strxfrm.c2
-rw-r--r--src/locale/strxfrm_l.c2
-rw-r--r--src/locale/wcsxfrm.c2
-rw-r--r--src/locale/wcsxfrm_l.c2
-rw-r--r--src/misc/realpath.c2
-rw-r--r--src/misc/wordexp.c2
-rw-r--r--src/mq/mq_setattr.c2
-rw-r--r--src/mq/mq_timedreceive.c2
-rw-r--r--src/multibyte/mbrlen.c2
-rw-r--r--src/multibyte/mbrtowc.c2
-rw-r--r--src/multibyte/mbsnrtowcs.c2
-rw-r--r--src/multibyte/mbsrtowcs.c2
-rw-r--r--src/multibyte/mbstowcs.c2
-rw-r--r--src/multibyte/mbtowc.c2
-rw-r--r--src/multibyte/wcrtomb.c2
-rw-r--r--src/multibyte/wcsnrtombs.c2
-rw-r--r--src/multibyte/wcsrtombs.c2
-rw-r--r--src/multibyte/wcstombs.c5
-rw-r--r--src/network/accept.c2
-rw-r--r--src/network/getaddrinfo.c2
-rw-r--r--src/network/getnameinfo.c6
-rw-r--r--src/network/getpeername.c2
-rw-r--r--src/network/getsockname.c2
-rw-r--r--src/network/getsockopt.c2
-rw-r--r--src/network/inet_ntop.c2
-rw-r--r--src/network/inet_pton.c2
-rw-r--r--src/network/recvfrom.c2
-rw-r--r--src/process/posix_spawn.c12
-rw-r--r--src/process/posix_spawn_file_actions_addopen.c2
-rw-r--r--src/process/posix_spawnattr_getflags.c2
-rw-r--r--src/process/posix_spawnattr_getpgroup.c2
-rw-r--r--src/process/posix_spawnattr_getsigdefault.c2
-rw-r--r--src/process/posix_spawnattr_getsigmask.c2
-rw-r--r--src/process/posix_spawnattr_setsigdefault.c2
-rw-r--r--src/process/posix_spawnattr_setsigmask.c2
-rw-r--r--src/process/posix_spawnp.c10
-rw-r--r--src/regex/glob.c2
-rw-r--r--src/regex/regcomp.c2
-rw-r--r--src/regex/regerror.c2
-rw-r--r--src/regex/regexec.c4
-rw-r--r--src/select/pselect.c2
-rw-r--r--src/select/select.c2
-rw-r--r--src/signal/setitimer.c2
-rw-r--r--src/signal/sigaction.c4
-rw-r--r--src/signal/sigaltstack.c2
-rw-r--r--src/signal/sigprocmask.c2
-rw-r--r--src/signal/sigtimedwait.c2
-rw-r--r--src/signal/sigwait.c2
-rw-r--r--src/signal/sigwaitinfo.c2
-rw-r--r--src/stat/fstatat.c2
-rw-r--r--src/stat/lstat.c2
-rw-r--r--src/stat/stat.c2
-rw-r--r--src/stat/statvfs.c2
-rw-r--r--src/stdio/dprintf.c2
-rw-r--r--src/stdio/fgetpos.c2
-rw-r--r--src/stdio/fgets.c2
-rw-r--r--src/stdio/fgetws.c2
-rw-r--r--src/stdio/fmemopen.c2
-rw-r--r--src/stdio/fopen.c2
-rw-r--r--src/stdio/fprintf.c2
-rw-r--r--src/stdio/fputs.c2
-rw-r--r--src/stdio/fputws.c2
-rw-r--r--src/stdio/fread.c2
-rw-r--r--src/stdio/freopen.c2
-rw-r--r--src/stdio/fscanf.c2
-rw-r--r--src/stdio/fwprintf.c2
-rw-r--r--src/stdio/fwrite.c4
-rw-r--r--src/stdio/fwscanf.c2
-rw-r--r--src/stdio/getdelim.c2
-rw-r--r--src/stdio/getline.c2
-rw-r--r--src/stdio/printf.c2
-rw-r--r--src/stdio/scanf.c2
-rw-r--r--src/stdio/setbuf.c2
-rw-r--r--src/stdio/setvbuf.c2
-rw-r--r--src/stdio/snprintf.c2
-rw-r--r--src/stdio/sprintf.c2
-rw-r--r--src/stdio/sscanf.c2
-rw-r--r--src/stdio/swprintf.c2
-rw-r--r--src/stdio/swscanf.c2
-rw-r--r--src/stdio/vdprintf.c2
-rw-r--r--src/stdio/vfprintf.c2
-rw-r--r--src/stdio/vfscanf.c2
-rw-r--r--src/stdio/vfwprintf.c2
-rw-r--r--src/stdio/vfwscanf.c2
-rw-r--r--src/stdio/vprintf.c2
-rw-r--r--src/stdio/vscanf.c2
-rw-r--r--src/stdio/vsnprintf.c2
-rw-r--r--src/stdio/vsprintf.c2
-rw-r--r--src/stdio/vsscanf.c2
-rw-r--r--src/stdio/vswprintf.c2
-rw-r--r--src/stdio/vswscanf.c2
-rw-r--r--src/stdio/vwprintf.c2
-rw-r--r--src/stdio/vwscanf.c2
-rw-r--r--src/stdio/wprintf.c2
-rw-r--r--src/stdio/wscanf.c2
-rw-r--r--src/stdlib/strtod.c6
-rw-r--r--src/stdlib/strtol.c12
-rw-r--r--src/stdlib/wcstod.c6
-rw-r--r--src/stdlib/wcstol.c12
-rw-r--r--src/string/memccpy.c2
-rw-r--r--src/string/memcpy.c2
-rw-r--r--src/string/stpcpy.c2
-rw-r--r--src/string/stpncpy.c2
-rw-r--r--src/string/strcat.c2
-rw-r--r--src/string/strcpy.c2
-rw-r--r--src/string/strncat.c2
-rw-r--r--src/string/strncpy.c2
-rw-r--r--src/string/strtok.c2
-rw-r--r--src/string/strtok_r.c2
-rw-r--r--src/string/swab.c2
-rw-r--r--src/string/wcpcpy.c2
-rw-r--r--src/string/wcpncpy.c2
-rw-r--r--src/string/wcscat.c2
-rw-r--r--src/string/wcscpy.c2
-rw-r--r--src/string/wcsncat.c2
-rw-r--r--src/string/wcsncpy.c2
-rw-r--r--src/string/wcsstr.c2
-rw-r--r--src/string/wcstok.c2
-rw-r--r--src/string/wmemcpy.c2
-rw-r--r--src/thread/pthread_attr_getguardsize.c2
-rw-r--r--src/thread/pthread_attr_getschedparam.c2
-rw-r--r--src/thread/pthread_attr_getscope.c2
-rw-r--r--src/thread/pthread_attr_getstack.c2
-rw-r--r--src/thread/pthread_attr_getstacksize.c2
-rw-r--r--src/thread/pthread_attr_setschedparam.c2
-rw-r--r--src/thread/pthread_barrier_init.c2
-rw-r--r--src/thread/pthread_barrierattr_getpshared.c2
-rw-r--r--src/thread/pthread_cond_init.c2
-rw-r--r--src/thread/pthread_cond_timedwait.c2
-rw-r--r--src/thread/pthread_cond_wait.c2
-rw-r--r--src/thread/pthread_condattr_getclock.c2
-rw-r--r--src/thread/pthread_condattr_getpshared.c2
-rw-r--r--src/thread/pthread_create.c2
-rw-r--r--src/thread/pthread_mutex_init.c2
-rw-r--r--src/thread/pthread_mutex_timedlock.c2
-rw-r--r--src/thread/pthread_mutexattr_getpshared.c2
-rw-r--r--src/thread/pthread_mutexattr_getrobust.c2
-rw-r--r--src/thread/pthread_mutexattr_gettype.c2
-rw-r--r--src/thread/pthread_rwlock_init.c2
-rw-r--r--src/thread/pthread_rwlock_timedrdlock.c2
-rw-r--r--src/thread/pthread_rwlock_timedwrlock.c2
-rw-r--r--src/thread/pthread_rwlockattr_getpshared.c2
-rw-r--r--src/thread/pthread_sigmask.c2
-rw-r--r--src/thread/sem_getvalue.c2
-rw-r--r--src/thread/sem_timedwait.c2
-rw-r--r--src/time/__asctime.c2
-rw-r--r--src/time/asctime_r.c4
-rw-r--r--src/time/gettimeofday.c2
-rw-r--r--src/time/gmtime_r.c2
-rw-r--r--src/time/localtime_r.c2
-rw-r--r--src/time/strftime.c2
-rw-r--r--src/time/strptime.c2
-rw-r--r--src/time/timer_create.c2
-rw-r--r--src/time/timer_settime.c2
-rw-r--r--src/time/wcsftime.c2
-rw-r--r--src/unistd/readlink.c2
-rw-r--r--src/unistd/readlinkat.c2
164 files changed, 199 insertions, 198 deletions
diff --git a/src/aio/lio_listio.c b/src/aio/lio_listio.c
index 8c851ca3..30f7cc05 100644
--- a/src/aio/lio_listio.c
+++ b/src/aio/lio_listio.c
@@ -64,7 +64,7 @@ static void *wait_thread(void *p)
return 0;
}
-int lio_listio(int mode, struct aiocb *const cbs[], int cnt, struct sigevent *sev)
+int lio_listio(int mode, struct aiocb *restrict const cbs[restrict], int cnt, struct sigevent *restrict sev)
{
int i, ret;
struct lio_state *st=0;
@@ -81,7 +81,7 @@ int lio_listio(int mode, struct aiocb *const cbs[], int cnt, struct sigevent *se
}
st->cnt = cnt;
st->sev = sev;
- memcpy(st->cbs, cbs, cnt*sizeof *cbs);
+ memcpy(st->cbs, (void*) cbs, cnt*sizeof *cbs);
}
for (i=0; i<cnt; i++) {
diff --git a/src/dirent/readdir_r.c b/src/dirent/readdir_r.c
index d3d7c608..639d49a1 100644
--- a/src/dirent/readdir_r.c
+++ b/src/dirent/readdir_r.c
@@ -5,7 +5,7 @@
#include "__dirent.h"
#include "libc.h"
-int readdir_r(DIR *dir, struct dirent *buf, struct dirent **result)
+int readdir_r(DIR *restrict dir, struct dirent *restrict buf, struct dirent **restrict result)
{
struct dirent *de;
int errno_save = errno;
diff --git a/src/ldso/dlsym.c b/src/ldso/dlsym.c
index 33693143..c0f50e92 100644
--- a/src/ldso/dlsym.c
+++ b/src/ldso/dlsym.c
@@ -1,8 +1,8 @@
#include <dlfcn.h>
-void *__dlsym(void *, const char *, void *);
+void *__dlsym(void *restrict, const char *restrict, void *restrict);
-void *dlsym(void *p, const char *s)
+void *dlsym(void *restrict p, const char *restrict s)
{
return __dlsym(p, s, 0);
}
diff --git a/src/ldso/dynlink.c b/src/ldso/dynlink.c
index 93a4b44c..1c181339 100644
--- a/src/ldso/dynlink.c
+++ b/src/ldso/dynlink.c
@@ -973,7 +973,7 @@ int __dladdr(void *addr, Dl_info *info)
return 1;
}
-void *__dlsym(void *p, const char *s, void *ra)
+void *__dlsym(void *restrict p, const char *restrict s, void *restrict ra)
{
void *res;
pthread_rwlock_rdlock(&lock);
@@ -986,7 +986,7 @@ void *dlopen(const char *file, int mode)
{
return 0;
}
-void *__dlsym(void *p, const char *s, void *ra)
+void *__dlsym(void *restrict p, const char *restrict s, void *restrict ra)
{
return 0;
}
diff --git a/src/locale/iconv.c b/src/locale/iconv.c
index 508d322e..7b341fe9 100644
--- a/src/locale/iconv.c
+++ b/src/locale/iconv.c
@@ -139,7 +139,7 @@ static void put_32(unsigned char *s, unsigned c, int e)
#define mbrtowc_utf8 mbrtowc
#define wctomb_utf8 wctomb
-size_t iconv(iconv_t cd0, char **in, size_t *inb, char **out, size_t *outb)
+size_t iconv(iconv_t cd0, char **restrict in, size_t *restrict inb, char **restrict out, size_t *restrict outb)
{
size_t x=0;
unsigned long cd = (unsigned long)cd0;
diff --git a/src/locale/strfmon.c b/src/locale/strfmon.c
index 81dfe38f..f510d9a4 100644
--- a/src/locale/strfmon.c
+++ b/src/locale/strfmon.c
@@ -75,7 +75,7 @@ static ssize_t vstrfmon_l(char *s, size_t n, locale_t loc, const char *fmt, va_l
return s-s0;
}
-ssize_t strfmon_l(char *s, size_t n, locale_t loc, const char *fmt, ...)
+ssize_t strfmon_l(char *restrict s, size_t n, locale_t loc, const char *restrict fmt, ...)
{
va_list ap;
ssize_t ret;
@@ -88,7 +88,7 @@ ssize_t strfmon_l(char *s, size_t n, locale_t loc, const char *fmt, ...)
}
-ssize_t strfmon(char *s, size_t n, const char *fmt, ...)
+ssize_t strfmon(char *restrict s, size_t n, const char *restrict fmt, ...)
{
va_list ap;
ssize_t ret;
diff --git a/src/locale/strftime_l.c b/src/locale/strftime_l.c
index 70b2f151..f19f5bf3 100644
--- a/src/locale/strftime_l.c
+++ b/src/locale/strftime_l.c
@@ -1,7 +1,7 @@
#include <locale.h>
#include <time.h>
-size_t strftime_l(char *s, size_t n, const char *f, const struct tm *tm, locale_t l)
+size_t strftime_l(char *restrict s, size_t n, const char *restrict f, const struct tm *restrict tm, locale_t l)
{
return strftime(s, n, f, tm);
}
diff --git a/src/locale/strxfrm.c b/src/locale/strxfrm.c
index 8f123399..d40be9e1 100644
--- a/src/locale/strxfrm.c
+++ b/src/locale/strxfrm.c
@@ -1,7 +1,7 @@
#include <string.h>
/* collate only by code points */
-size_t strxfrm(char *dest, const char *src, size_t n)
+size_t strxfrm(char *restrict dest, const char *restrict src, size_t n)
{
size_t l = strlen(src);
if (n > l) strcpy(dest, src);
diff --git a/src/locale/strxfrm_l.c b/src/locale/strxfrm_l.c
index 78e56554..81a7badf 100644
--- a/src/locale/strxfrm_l.c
+++ b/src/locale/strxfrm_l.c
@@ -1,6 +1,6 @@
#include <string.h>
-size_t strxfrm_l(char *dest, const char *src, size_t n, locale_t l)
+size_t strxfrm_l(char *restrict dest, const char *restrict src, size_t n, locale_t l)
{
return strxfrm(dest, src, n);
}
diff --git a/src/locale/wcsxfrm.c b/src/locale/wcsxfrm.c
index 5f76e5a7..bfa01b5b 100644
--- a/src/locale/wcsxfrm.c
+++ b/src/locale/wcsxfrm.c
@@ -1,7 +1,7 @@
#include <wchar.h>
/* collate only by code points */
-size_t wcsxfrm(wchar_t *dest, const wchar_t *src, size_t n)
+size_t wcsxfrm(wchar_t *restrict dest, const wchar_t *restrict src, size_t n)
{
size_t l = wcslen(src);
if (l >= n) {
diff --git a/src/locale/wcsxfrm_l.c b/src/locale/wcsxfrm_l.c
index 831998e9..66a00193 100644
--- a/src/locale/wcsxfrm_l.c
+++ b/src/locale/wcsxfrm_l.c
@@ -1,6 +1,6 @@
#include <wchar.h>
-size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, locale_t locale)
+size_t wcsxfrm_l(wchar_t *restrict dest, const wchar_t *restrict src, size_t n, locale_t locale)
{
return wcsxfrm(dest, src, n);
}
diff --git a/src/misc/realpath.c b/src/misc/realpath.c
index ef156fcf..57568179 100644
--- a/src/misc/realpath.c
+++ b/src/misc/realpath.c
@@ -6,7 +6,7 @@
#include <errno.h>
#include <unistd.h>
-char *realpath(const char *filename, char *resolved)
+char *realpath(const char *restrict filename, char *restrict resolved)
{
int fd;
ssize_t r;
diff --git a/src/misc/wordexp.c b/src/misc/wordexp.c
index 15adddbe..617706e5 100644
--- a/src/misc/wordexp.c
+++ b/src/misc/wordexp.c
@@ -147,7 +147,7 @@ static int do_wordexp(const char *s, wordexp_t *we, int flags)
return err;
}
-int wordexp(const char *s, wordexp_t *we, int flags)
+int wordexp(const char *restrict s, wordexp_t *restrict we, int flags)
{
int r, cs;
pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &cs);
diff --git a/src/mq/mq_setattr.c b/src/mq/mq_setattr.c
index 9064fa07..eae022e9 100644
--- a/src/mq/mq_setattr.c
+++ b/src/mq/mq_setattr.c
@@ -1,7 +1,7 @@
#include <mqueue.h>
#include "syscall.h"
-int mq_setattr(mqd_t mqd, const struct mq_attr *new, struct mq_attr *old)
+int mq_setattr(mqd_t mqd, const struct mq_attr *restrict new, struct mq_attr *restrict old)
{
return syscall(SYS_mq_getsetattr, mqd, new, old);
}
diff --git a/src/mq/mq_timedreceive.c b/src/mq/mq_timedreceive.c
index 099f213a..2cef6a86 100644
--- a/src/mq/mq_timedreceive.c
+++ b/src/mq/mq_timedreceive.c
@@ -1,7 +1,7 @@
#include <mqueue.h>
#include "syscall.h"
-ssize_t mq_timedreceive(mqd_t mqd, char *msg, size_t len, unsigned *prio, const struct timespec *at)
+ssize_t mq_timedreceive(mqd_t mqd, char *restrict msg, size_t len, unsigned *restrict prio, const struct timespec *restrict at)
{
return syscall_cp(SYS_mq_timedreceive, mqd, msg, len, prio, at);
}
diff --git a/src/multibyte/mbrlen.c b/src/multibyte/mbrlen.c
index c9a9f033..c9714ef8 100644
--- a/src/multibyte/mbrlen.c
+++ b/src/multibyte/mbrlen.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t mbrlen(const char *s, size_t n, mbstate_t *st)
+size_t mbrlen(const char *restrict s, size_t n, mbstate_t *restrict st)
{
static unsigned internal;
return mbrtowc(0, s, n, st ? st : (mbstate_t *)&internal);
diff --git a/src/multibyte/mbrtowc.c b/src/multibyte/mbrtowc.c
index 291537f8..cc497810 100644
--- a/src/multibyte/mbrtowc.c
+++ b/src/multibyte/mbrtowc.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t mbrtowc(wchar_t *wc, const char *src, size_t n, mbstate_t *st)
+size_t mbrtowc(wchar_t *restrict wc, const char *restrict src, size_t n, mbstate_t *restrict st)
{
static unsigned internal_state;
unsigned c;
diff --git a/src/multibyte/mbsnrtowcs.c b/src/multibyte/mbsnrtowcs.c
index f42e30d9..33457f95 100644
--- a/src/multibyte/mbsnrtowcs.c
+++ b/src/multibyte/mbsnrtowcs.c
@@ -12,7 +12,7 @@
#include "internal.h"
-size_t mbsnrtowcs(wchar_t *wcs, const char **src, size_t n, size_t wn, mbstate_t *st)
+size_t mbsnrtowcs(wchar_t *restrict wcs, const char **restrict src, size_t n, size_t wn, mbstate_t *restrict st)
{
size_t l, cnt=0, n2;
wchar_t *ws, wbuf[256];
diff --git a/src/multibyte/mbsrtowcs.c b/src/multibyte/mbsrtowcs.c
index ebf0d6c9..8313d37b 100644
--- a/src/multibyte/mbsrtowcs.c
+++ b/src/multibyte/mbsrtowcs.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t mbsrtowcs(wchar_t *ws, const char **src, size_t wn, mbstate_t *st)
+size_t mbsrtowcs(wchar_t *restrict ws, const char **restrict src, size_t wn, mbstate_t *restrict st)
{
unsigned c;
const unsigned char *s = (const void *)*src;
diff --git a/src/multibyte/mbstowcs.c b/src/multibyte/mbstowcs.c
index 23e1d925..5071baf7 100644
--- a/src/multibyte/mbstowcs.c
+++ b/src/multibyte/mbstowcs.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t mbstowcs(wchar_t *ws, const char *s, size_t wn)
+size_t mbstowcs(wchar_t *restrict ws, const char *restrict s, size_t wn)
{
mbstate_t st = { 0 };
return mbsrtowcs(ws, (void*)&s, wn, &st);
diff --git a/src/multibyte/mbtowc.c b/src/multibyte/mbtowc.c
index bdcaeb3c..b5dd7e3c 100644
--- a/src/multibyte/mbtowc.c
+++ b/src/multibyte/mbtowc.c
@@ -11,7 +11,7 @@
#include "internal.h"
-int mbtowc(wchar_t *wc, const char *s, size_t n)
+int mbtowc(wchar_t *restrict wc, const char *restrict s, size_t n)
{
mbstate_t st = { 0 };
n = mbrtowc(wc, s, n, &st);
diff --git a/src/multibyte/wcrtomb.c b/src/multibyte/wcrtomb.c
index 36180c8f..250649f5 100644
--- a/src/multibyte/wcrtomb.c
+++ b/src/multibyte/wcrtomb.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t wcrtomb(char *s, wchar_t wc, mbstate_t *st)
+size_t wcrtomb(char *restrict s, wchar_t wc, mbstate_t *restrict st)
{
if (!s) return 1;
if ((unsigned)wc < 0x80) {
diff --git a/src/multibyte/wcsnrtombs.c b/src/multibyte/wcsnrtombs.c
index 70b0cacb..a2e308b3 100644
--- a/src/multibyte/wcsnrtombs.c
+++ b/src/multibyte/wcsnrtombs.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t wcsnrtombs(char *dst, const wchar_t **wcs, size_t wn, size_t n, mbstate_t *st)
+size_t wcsnrtombs(char *restrict dst, const wchar_t **restrict wcs, size_t wn, size_t n, mbstate_t *restrict st)
{
size_t l, cnt=0, n2;
char *s, buf[256];
diff --git a/src/multibyte/wcsrtombs.c b/src/multibyte/wcsrtombs.c
index 3c48d65b..2582ac2f 100644
--- a/src/multibyte/wcsrtombs.c
+++ b/src/multibyte/wcsrtombs.c
@@ -11,7 +11,7 @@
#include "internal.h"
-size_t wcsrtombs(char *s, const wchar_t **ws, size_t n, mbstate_t *st)
+size_t wcsrtombs(char *restrict s, const wchar_t **restrict ws, size_t n, mbstate_t *restrict st)
{
const wchar_t *ws2;
char buf[4];
diff --git a/src/multibyte/wcstombs.c b/src/multibyte/wcstombs.c
index b9c1b18a..b6ae4732 100644
--- a/src/multibyte/wcstombs.c
+++ b/src/multibyte/wcstombs.c
@@ -11,7 +11,8 @@
#include "internal.h"
-size_t wcstombs(char *s, const wchar_t *ws, size_t n)
+size_t wcstombs(char *restrict s, const wchar_t *restrict ws, size_t n)
{
- return wcsrtombs(s, &ws, n, 0);
+ const wchar_t * x = ws;
+ return wcsrtombs(s, &x, n, 0);
}
diff --git a/src/network/accept.c b/src/network/accept.c
index f6b75ba4..521e9ef9 100644
--- a/src/network/accept.c
+++ b/src/network/accept.c
@@ -2,7 +2,7 @@
#include "syscall.h"
#include "libc.h"
-int accept(int fd, struct sockaddr *addr, socklen_t *len)
+int accept(int fd, struct sockaddr *restrict addr, socklen_t *restrict len)
{
return socketcall_cp(accept, fd, addr, len, 0, 0, 0);
}
diff --git a/src/network/getaddrinfo.c b/src/network/getaddrinfo.c
index 83862166..b9e562f7 100644
--- a/src/network/getaddrinfo.c
+++ b/src/network/getaddrinfo.c
@@ -47,7 +47,7 @@ struct aibuf {
/* Extra slots needed for storing canonical name */
#define EXTRA ((256+sizeof(struct aibuf)-1)/sizeof(struct aibuf))
-int getaddrinfo(const char *host, const char *serv, const struct addrinfo *hint, struct addrinfo **res)
+int getaddrinfo(const char *restrict host, const char *restrict serv, const struct addrinfo *restrict hint, struct addrinfo **restrict res)
{
int flags = hint ? hint->ai_flags : 0;
int family = hint ? hint->ai_family : AF_UNSPEC;
diff --git a/src/network/getnameinfo.c b/src/network/getnameinfo.c
index 0763ca88..3d115c75 100644
--- a/src/network/getnameinfo.c
+++ b/src/network/getnameinfo.c
@@ -8,9 +8,9 @@
#include <arpa/inet.h>
#include "__dns.h"
-int getnameinfo(const struct sockaddr *sa, socklen_t sl,
- char *node, socklen_t nodelen,
- char *serv, socklen_t servlen,
+int getnameinfo(const struct sockaddr *restrict sa, socklen_t sl,
+ char *restrict node, socklen_t nodelen,
+ char *restrict serv, socklen_t servlen,
int flags)
{
char buf[256];
diff --git a/src/network/getpeername.c b/src/network/getpeername.c
index 22effdae..6567b451 100644
--- a/src/network/getpeername.c
+++ b/src/network/getpeername.c
@@ -1,7 +1,7 @@
#include <sys/socket.h>
#include "syscall.h"
-int getpeername(int fd, struct sockaddr *addr, socklen_t *len)
+int getpeername(int fd, struct sockaddr *restrict addr, socklen_t *restrict len)
{
return socketcall(getpeername, fd, addr, len, 0, 0, 0);
}
diff --git a/src/network/getsockname.c b/src/network/getsockname.c
index 271e3b41..7885fc13 100644
--- a/src/network/getsockname.c
+++ b/src/network/getsockname.c
@@ -1,7 +1,7 @@
#include <sys/socket.h>
#include "syscall.h"
-int getsockname(int fd, struct sockaddr *addr, socklen_t *len)
+int getsockname(int fd, struct sockaddr *restrict addr, socklen_t *restrict len)
{
return socketcall(getsockname, fd, addr, len, 0, 0, 0);
}
diff --git a/src/network/getsockopt.c b/src/network/getsockopt.c
index a9e0a72d..28079d8c 100644
--- a/src/network/getsockopt.c
+++ b/src/network/getsockopt.c
@@ -1,7 +1,7 @@
#include <sys/socket.h>
#include "syscall.h"
-int getsockopt(int fd, int level, int optname, void *optval, socklen_t *optlen)
+int getsockopt(int fd, int level, int optname, void *restrict optval, socklen_t *restrict optlen)
{
return socketcall(getsockopt, fd, level, optname, optval, optlen, 0);
}
diff --git a/src/network/inet_ntop.c b/src/network/inet_ntop.c
index 4817187d..76ae556c 100644
--- a/src/network/inet_ntop.c
+++ b/src/network/inet_ntop.c
@@ -6,7 +6,7 @@
#include <stdio.h>
#include <string.h>
-const char *inet_ntop(int af, const void *a0, char *s, socklen_t l)
+const char *inet_ntop(int af, const void *restrict a0, char *restrict s, socklen_t l)
{
const unsigned char *a = a0;
int i, j, max, best;
diff --git a/src/network/inet_pton.c b/src/network/inet_pton.c
index bb16fb90..5c4850a6 100644
--- a/src/network/inet_pton.c
+++ b/src/network/inet_pton.c
@@ -14,7 +14,7 @@ static int hexval(unsigned c)
return -1;
}
-int inet_pton(int af, const char *s, void *a0)
+int inet_pton(int af, const char *restrict s, void *restrict a0)
{
uint16_t ip[8];
unsigned char *a = a0;
diff --git a/src/network/recvfrom.c b/src/network/recvfrom.c
index 035a15f8..436f3447 100644
--- a/src/network/recvfrom.c
+++ b/src/network/recvfrom.c
@@ -2,7 +2,7 @@
#include "syscall.h"
#include "libc.h"
-ssize_t recvfrom(int fd, void *buf, size_t len, int flags, struct sockaddr *addr, socklen_t *alen)
+ssize_t recvfrom(int fd, void *restrict buf, size_t len, int flags, struct sockaddr *restrict addr, socklen_t *restrict alen)
{
return socketcall_cp(recvfrom, fd, buf, len, flags, addr, alen);
}
diff --git a/src/process/posix_spawn.c b/src/process/posix_spawn.c
index 9f2d7423..1120be08 100644
--- a/src/process/posix_spawn.c
+++ b/src/process/posix_spawn.c
@@ -8,11 +8,11 @@
extern char **environ;
-int __posix_spawnx(pid_t *res, const char *path,
+int __posix_spawnx(pid_t *restrict res, const char *restrict path,
int (*exec)(const char *, char *const *),
const posix_spawn_file_actions_t *fa,
- const posix_spawnattr_t *attr,
- char *const argv[], char *const envp[])
+ const posix_spawnattr_t *restrict attr,
+ char *const argv[restrict], char *const envp[restrict])
{
pid_t pid;
sigset_t oldmask;
@@ -89,10 +89,10 @@ int __posix_spawnx(pid_t *res, const char *path,
return 0;
}
-int posix_spawn(pid_t *res, const char *path,
+int posix_spawn(pid_t *restrict res, const char *restrict path,
const posix_spawn_file_actions_t *fa,
- const posix_spawnattr_t *attr,
- char *const argv[], char *const envp[])
+ const posix_spawnattr_t *restrict attr,
+ char *const argv[restrict], char *const envp[restrict])
{
return __posix_spawnx(res, path, execv, fa, attr, argv, envp);
}
diff --git a/src/process/posix_spawn_file_actions_addopen.c b/src/process/posix_spawn_file_actions_addopen.c
index af3ca604..368922c7 100644
--- a/src/process/posix_spawn_file_actions_addopen.c
+++ b/src/process/posix_spawn_file_actions_addopen.c
@@ -4,7 +4,7 @@
#include <errno.h>
#include "fdop.h"
-int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *fa, int fd, const char *path, int flags, mode_t mode)
+int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *restrict fa, int fd, const char *restrict path, int flags, mode_t mode)
{
struct fdop *op = malloc(sizeof *op + strlen(path) + 1);
if (!op) return ENOMEM;
diff --git a/src/process/posix_spawnattr_getflags.c b/src/process/posix_spawnattr_getflags.c
index 7353d24a..aa635dda 100644
--- a/src/process/posix_spawnattr_getflags.c
+++ b/src/process/posix_spawnattr_getflags.c
@@ -1,6 +1,6 @@
#include <spawn.h>
-int posix_spawnattr_getflags(const posix_spawnattr_t *attr, short *flags)
+int posix_spawnattr_getflags(const posix_spawnattr_t *restrict attr, short *restrict flags)
{
*flags = attr->__flags;
return 0;
diff --git a/src/process/posix_spawnattr_getpgroup.c b/src/process/posix_spawnattr_getpgroup.c
index 2c72e985..0480527d 100644
--- a/src/process/posix_spawnattr_getpgroup.c
+++ b/src/process/posix_spawnattr_getpgroup.c
@@ -1,6 +1,6 @@
#include <spawn.h>
-int posix_spawnattr_getpgroup(const posix_spawnattr_t *attr, pid_t *pgrp)
+int posix_spawnattr_getpgroup(const posix_spawnattr_t *restrict attr, pid_t *restrict pgrp)
{
*pgrp = attr->__pgrp;
return 0;
diff --git a/src/process/posix_spawnattr_getsigdefault.c b/src/process/posix_spawnattr_getsigdefault.c
index 5f0dfb58..a49050aa 100644
--- a/src/process/posix_spawnattr_getsigdefault.c
+++ b/src/process/posix_spawnattr_getsigdefault.c
@@ -1,6 +1,6 @@
#include <spawn.h>
-int posix_spawnattr_getsigdefault(const posix_spawnattr_t *attr, sigset_t *def)
+int posix_spawnattr_getsigdefault(const posix_spawnattr_t *restrict attr, sigset_t *restrict def)
{
*def = attr->__def;
return 0;
diff --git a/src/process/posix_spawnattr_getsigmask.c b/src/process/posix_spawnattr_getsigmask.c
index b4490756..f60ad7f3 100644
--- a/src/process/posix_spawnattr_getsigmask.c
+++ b/src/process/posix_spawnattr_getsigmask.c
@@ -1,6 +1,6 @@
#include <spawn.h>
-int posix_spawnattr_getsigmask(const posix_spawnattr_t *attr, sigset_t *mask)
+int posix_spawnattr_getsigmask(const posix_spawnattr_t *restrict attr, sigset_t *restrict mask)
{
*mask = attr->__mask;
return 0;
diff --git a/src/process/posix_spawnattr_setsigdefault.c b/src/process/posix_spawnattr_setsigdefault.c
index a6ddd4d8..56869726 100644
--- a/src/process/posix_spawnattr_setsigdefault.c
+++ b/src/process/posix_spawnattr_setsigdefault.c
@@ -1,6 +1,6 @@
#include <spawn.h>
-int posix_spawnattr_setsigdefault(posix_spawnattr_t *attr, const sigset_t *def)
+int posix_spawnattr_setsigdefault(posix_spawnattr_t *restrict attr, const sigset_t *restrict def)
{
attr->__def = *def;
return 0;
diff --git a/src/process/posix_spawnattr_setsigmask.c b/src/process/posix_spawnattr_setsigmask.c
index 6afbf876..f2532f8e 100644
--- a/src/process/posix_spawnattr_setsigmask.c
+++ b/src/process/posix_spawnattr_setsigmask.c
@@ -1,6 +1,6 @@
#include <spawn.h>
-int posix_spawnattr_setsigmask(posix_spawnattr_t *attr, const sigset_t *mask)
+int posix_spawnattr_setsigmask(posix_spawnattr_t *restrict attr, const sigset_t *restrict mask)
{
attr->__mask = *mask;
return 0;
diff --git a/src/process/posix_spawnp.c b/src/process/posix_spawnp.c
index 04d768d0..91355fb8 100644
--- a/src/process/posix_spawnp.c
+++ b/src/process/posix_spawnp.c
@@ -1,15 +1,15 @@
#include <spawn.h>
#include <unistd.h>
-int __posix_spawnx(pid_t *, const char *,
+int __posix_spawnx(pid_t *restrict, const char *restrict,
int (*)(const char *, char *const *),
const posix_spawn_file_actions_t *,
- const posix_spawnattr_t *, char *const [], char *const []);
+ const posix_spawnattr_t *restrict, char *const *restrict, char *const *restrict);
-int posix_spawnp(pid_t *res, const char *file,
+int posix_spawnp(pid_t *restrict res, const char *restrict file,
const posix_spawn_file_actions_t *fa,
- const posix_spawnattr_t *attr,
- char *const argv[], char *const envp[])
+ const posix_spawnattr_t *restrict attr,
+ char *const argv[restrict], char *const envp[restrict])
{
return __posix_spawnx(res, file, execvp, fa, attr, argv, envp);
}
diff --git a/src/regex/glob.c b/src/regex/glob.c
index 3476e010..6c07e6b3 100644
--- a/src/regex/glob.c
+++ b/src/regex/glob.c
@@ -156,7 +156,7 @@ static int sort(const void *a, const void *b)
return strcmp(*(const char **)a, *(const char **)b);
}
-int glob(const char *pat, int flags, int (*errfunc)(const char *path, int err), glob_t *g)
+int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, int err), glob_t *restrict g)
{
const char *p=pat, *d;
struct match head = { .next = NULL }, *tail = &head;
diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
index 322a5e67..399989e7 100644
--- a/src/regex/regcomp.c
+++ b/src/regex/regcomp.c
@@ -3091,7 +3091,7 @@ tre_ast_to_tnfa(tre_ast_node_t *node, tre_tnfa_transition_t *transitions,
int
-regcomp(regex_t *preg, const char *regex, int cflags)
+regcomp(regex_t *restrict preg, const char *restrict regex, int cflags)
{
tre_stack_t *stack;
tre_ast_node_t *tree, *tmp_ast_l, *tmp_ast_r;
diff --git a/src/regex/regerror.c b/src/regex/regerror.c
index 0645b8e7..df4afa4f 100644
--- a/src/regex/regerror.c
+++ b/src/regex/regerror.c
@@ -26,7 +26,7 @@ static const char messages[] = {
"\0Unknown error"
};
-size_t regerror(int e, const regex_t *preg, char *buf, size_t size)
+size_t regerror(int e, const regex_t *restrict preg, char *restrict buf, size_t size)
{
const char *s;
for (s=messages; e && *s; e--, s+=strlen(s)+1);
diff --git a/src/regex/regexec.c b/src/regex/regexec.c
index 8107aae7..855cef57 100644
--- a/src/regex/regexec.c
+++ b/src/regex/regexec.c
@@ -977,8 +977,8 @@ tre_fill_pmatch(size_t nmatch, regmatch_t pmatch[], int cflags,
*/
int
-regexec(const regex_t *preg, const char *string,
- size_t nmatch, regmatch_t pmatch[], int eflags)
+regexec(const regex_t *restrict preg, const char *restrict string,
+ size_t nmatch, regmatch_t pmatch[restrict], int eflags)
{
tre_tnfa_t *tnfa = (void *)preg->TRE_REGEX_T_FIELD;
reg_errcode_t status;
diff --git a/src/select/pselect.c b/src/select/pselect.c
index 48fcefed..50343fb7 100644
--- a/src/select/pselect.c
+++ b/src/select/pselect.c
@@ -2,7 +2,7 @@
#include "syscall.h"
#include "libc.h"
-int pselect(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, const struct timespec *ts, const sigset_t *mask)
+int pselect(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, const struct timespec *restrict ts, const sigset_t *restrict mask)
{
long data[2] = { (long)mask, __SYSCALL_SSLEN };
struct timespec ts_tmp;
diff --git a/src/select/select.c b/src/select/select.c
index 696cb288..f93597b5 100644
--- a/src/select/select.c
+++ b/src/select/select.c
@@ -2,7 +2,7 @@
#include "syscall.h"
#include "libc.h"
-int select(int n, fd_set *rfds, fd_set *wfds, fd_set *efds, struct timeval *tv)
+int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, struct timeval *restrict tv)
{
return syscall_cp(SYS_select, n, rfds, wfds, efds, tv);
}
diff --git a/src/signal/setitimer.c b/src/signal/setitimer.c
index 3b237580..21b1f45d 100644
--- a/src/signal/setitimer.c
+++ b/src/signal/setitimer.c
@@ -1,7 +1,7 @@
#include <sys/time.h>
#include "syscall.h"
-int setitimer(int which, const struct itimerval *new, struct itimerval *old)
+int setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old)
{
return syscall(SYS_setitimer, which, new, old);
}
diff --git a/src/signal/sigaction.c b/src/signal/sigaction.c
index e0c58b73..2331dc93 100644
--- a/src/signal/sigaction.c
+++ b/src/signal/sigaction.c
@@ -11,7 +11,7 @@ void __restore(), __restore_rt();
static pthread_t dummy(void) { return 0; }
weak_alias(dummy, __pthread_self_def);
-int __libc_sigaction(int sig, const struct sigaction *sa, struct sigaction *old)
+int __libc_sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
{
struct k_sigaction ksa;
if (sa) {
@@ -31,7 +31,7 @@ int __libc_sigaction(int sig, const struct sigaction *sa, struct sigaction *old)
return 0;
}
-int __sigaction(int sig, const struct sigaction *sa, struct sigaction *old)
+int __sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *restrict old)
{
if (sig-32U < 3) {
errno = EINVAL;
diff --git a/src/signal/sigaltstack.c b/src/signal/sigaltstack.c
index 550f2f9d..62cb81ad 100644
--- a/src/signal/sigaltstack.c
+++ b/src/signal/sigaltstack.c
@@ -2,7 +2,7 @@
#include <errno.h>
#include "syscall.h"
-int sigaltstack(const stack_t *ss, stack_t *old)
+int sigaltstack(const stack_t *restrict ss, stack_t *restrict old)
{
if (ss) {
if (ss->ss_size < MINSIGSTKSZ) {
diff --git a/src/signal/sigprocmask.c b/src/signal/sigprocmask.c
index 67e2b82e..297e20c6 100644
--- a/src/signal/sigprocmask.c
+++ b/src/signal/sigprocmask.c
@@ -1,7 +1,7 @@
#include <signal.h>
#include <errno.h>
-int sigprocmask(int how, const sigset_t *set, sigset_t *old)
+int sigprocmask(int how, const sigset_t *restrict set, sigset_t *restrict old)
{
int r = pthread_sigmask(how, set, old);
if (!r) return r;
diff --git a/src/signal/sigtimedwait.c b/src/signal/sigtimedwait.c
index f62db2f3..4f8589b5 100644
--- a/src/signal/sigtimedwait.c
+++ b/src/signal/sigtimedwait.c
@@ -3,7 +3,7 @@
#include "syscall.h"
#include "libc.h"
-int sigtimedwait(const sigset_t *mask, siginfo_t *si, const struct timespec *timeout)
+int sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict timeout)
{
int ret;
do ret = syscall_cp(SYS_rt_sigtimedwait, mask,
diff --git a/src/signal/sigwait.c b/src/signal/sigwait.c
index 9569d6b0..48a855bb 100644
--- a/src/signal/sigwait.c
+++ b/src/signal/sigwait.c
@@ -1,7 +1,7 @@
#include <signal.h>
#include <stddef.h>
-int sigwait(const sigset_t *mask, int *sig)
+int sigwait(const sigset_t *restrict mask, int *restrict sig)
{
siginfo_t si;
if (sigtimedwait(mask, &si, NULL) < 0)
diff --git a/src/signal/sigwaitinfo.c b/src/signal/sigwaitinfo.c
index e79feb91..c7b164df 100644
--- a/src/signal/sigwaitinfo.c
+++ b/src/signal/sigwaitinfo.c
@@ -1,7 +1,7 @@
#include <signal.h>
#include <stddef.h>
-int sigwaitinfo(const sigset_t *mask, siginfo_t *si)
+int sigwaitinfo(const sigset_t *restrict mask, siginfo_t *restrict si)
{
return sigtimedwait(mask, si, NULL);
}
diff --git a/src/stat/fstatat.c b/src/stat/fstatat.c
index d6b9390c..863d5268 100644
--- a/src/stat/fstatat.c
+++ b/src/stat/fstatat.c
@@ -2,7 +2,7 @@
#include "syscall.h"
#include "libc.h"
-int fstatat(int fd, const char *path, struct stat *buf, int flag)
+int fstatat(int fd, const char *restrict path, struct stat *restrict buf, int flag)
{
return syscall(SYS_fstatat, fd, path, buf, flag);
}
diff --git a/src/stat/lstat.c b/src/stat/lstat.c
index 9053d998..8f60358c 100644
--- a/src/stat/lstat.c
+++ b/src/stat/lstat.c
@@ -2,7 +2,7 @@
#include "syscall.h"
#include "libc.h"
-int lstat(const char *path, struct stat *buf)
+int lstat(const char *restrict path, struct stat *restrict buf)
{
return syscall(SYS_lstat, path, buf);
}
diff --git a/src/stat/stat.c b/src/stat/stat.c
index c5491eb0..c6de7168 100644
--- a/src/stat/stat.c
+++ b/src/stat/stat.c
@@ -2,7 +2,7 @@
#include "syscall.h"
#include "libc.h"
-int stat(const char *path, struct stat *buf)
+int stat(const char *restrict path, struct stat *restrict buf)
{
return syscall(SYS_stat, path, buf);
}
diff --git a/src/stat/statvfs.c b/src/stat/statvfs.c
index 5fadb3b4..637bf82f 100644
--- a/src/stat/statvfs.c
+++ b/src/stat/statvfs.c
@@ -39,7 +39,7 @@ static void fixup(struct statvfs *out, const struct statfs *in)
out->f_namemax = in->f_namelen;
}
-int statvfs(const char *path, struct statvfs *buf)
+int statvfs(const char *restrict path, struct statvfs *restrict buf)
{
struct statfs kbuf;
if (__statfs(path, &kbuf)<0) return -1;
diff --git a/src/stdio/dprintf.c b/src/stdio/dprintf.c
index fa28322f..93082ee7 100644
--- a/src/stdio/dprintf.c
+++ b/src/stdio/dprintf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-int dprintf(int fd, const char *fmt, ...)
+int dprintf(int fd, const char *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/fgetpos.c b/src/stdio/fgetpos.c
index 5b663d1e..c3fa0eb0 100644
--- a/src/stdio/fgetpos.c
+++ b/src/stdio/fgetpos.c
@@ -1,6 +1,6 @@
#include "stdio_impl.h"
-int fgetpos(FILE *f, fpos_t *pos)
+int fgetpos(FILE *restrict f, fpos_t *restrict pos)
{
off_t off = __ftello(f);
if (off < 0) return -1;
diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c
index 3135a69a..ee0ac30e 100644
--- a/src/stdio/fgets.c
+++ b/src/stdio/fgets.c
@@ -2,7 +2,7 @@
#define MIN(a,b) ((a)<(b) ? (a) : (b))
-char *fgets(char *s, int n, FILE *f)
+char *fgets(char *restrict s, int n, FILE *restrict f)
{
char *p = s;
unsigned char *z;
diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c
index 2e76b565..fab9bd0f 100644
--- a/src/stdio/fgetws.c
+++ b/src/stdio/fgetws.c
@@ -2,7 +2,7 @@
wint_t __fgetwc_unlocked(FILE *);
-wchar_t *fgetws(wchar_t *s, int n, FILE *f)
+wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f)
{
wchar_t *p = s;
diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c
index 1b054a97..770fd995 100644
--- a/src/stdio/fmemopen.c
+++ b/src/stdio/fmemopen.c
@@ -67,7 +67,7 @@ static int mclose(FILE *m)
return 0;
}
-FILE *fmemopen(void *buf, size_t size, const char *mode)
+FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode)
{
FILE *f;
struct cookie *c;
diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c
index 0d5b1af2..560b77e4 100644
--- a/src/stdio/fopen.c
+++ b/src/stdio/fopen.c
@@ -1,6 +1,6 @@
#include "stdio_impl.h"
-FILE *fopen(const char *filename, const char *mode)
+FILE *fopen(const char *restrict filename, const char *restrict mode)
{
FILE *f;
int fd;
diff --git a/src/stdio/fprintf.c b/src/stdio/fprintf.c
index a220cc10..948743f7 100644
--- a/src/stdio/fprintf.c
+++ b/src/stdio/fprintf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-int fprintf(FILE *f, const char *fmt, ...)
+int fprintf(FILE *restrict f, const char *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/fputs.c b/src/stdio/fputs.c
index e6bdb204..b41bc8c7 100644
--- a/src/stdio/fputs.c
+++ b/src/stdio/fputs.c
@@ -1,6 +1,6 @@
#include "stdio_impl.h"
-int fputs(const char *s, FILE *f)
+int fputs(const char *restrict s, FILE *restrict f)
{
size_t l = strlen(s);
if (!l) return 0;
diff --git a/src/stdio/fputws.c b/src/stdio/fputws.c
index b75f95bc..0b593c08 100644
--- a/src/stdio/fputws.c
+++ b/src/stdio/fputws.c
@@ -1,6 +1,6 @@
#include "stdio_impl.h"
-int fputws(const wchar_t *ws, FILE *f)
+int fputws(const wchar_t *restrict ws, FILE *restrict f)
{
unsigned char buf[BUFSIZ];
size_t l=0;
diff --git a/src/stdio/fread.c b/src/stdio/fread.c
index 5c235777..3f31af8a 100644
--- a/src/stdio/fread.c
+++ b/src/stdio/fread.c
@@ -2,7 +2,7 @@
#define MIN(a,b) ((a)<(b) ? (a) : (b))
-size_t fread(void *destv, size_t size, size_t nmemb, FILE *f)
+size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f)
{
unsigned char *dest = destv;
size_t len = size*nmemb, l = len, k;
diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c
index b1f8fe71..57c3cd29 100644
--- a/src/stdio/freopen.c
+++ b/src/stdio/freopen.c
@@ -7,7 +7,7 @@
/* Locking is not necessary because, in the event of failure, the stream
* passed to freopen is invalid as soon as freopen is called. */
-FILE *freopen(const char *filename, const char *mode, FILE *f)
+FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *restrict f)
{
int fl;
FILE *f2;
diff --git a/src/stdio/fscanf.c b/src/stdio/fscanf.c
index 51fc9b30..ff6c7767 100644
--- a/src/stdio/fscanf.c
+++ b/src/stdio/fscanf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-int fscanf(FILE *f, const char *fmt, ...)
+int fscanf(FILE *restrict f, const char *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/fwprintf.c b/src/stdio/fwprintf.c
index 26d9729a..9ce4f010 100644
--- a/src/stdio/fwprintf.c
+++ b/src/stdio/fwprintf.c
@@ -2,7 +2,7 @@
#include <stdarg.h>
#include <wchar.h>
-int fwprintf(FILE *f, const wchar_t *fmt, ...)
+int fwprintf(FILE *restrict f, const wchar_t *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c
index 1b8641ac..8027b306 100644
--- a/src/stdio/fwrite.c
+++ b/src/stdio/fwrite.c
@@ -1,6 +1,6 @@
#include "stdio_impl.h"
-size_t __fwritex(const unsigned char *s, size_t l, FILE *f)
+size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f)
{
size_t i=0;
@@ -24,7 +24,7 @@ size_t __fwritex(const unsigned char *s, size_t l, FILE *f)
return l+i;
}
-size_t fwrite(const void *src, size_t size, size_t nmemb, FILE *f)
+size_t fwrite(const void *restrict src, size_t size, size_t nmemb, FILE *restrict f)
{
size_t k, l = size*nmemb;
if (!l) return l;
diff --git a/src/stdio/fwscanf.c b/src/stdio/fwscanf.c
index a6892cf6..2f30dab4 100644
--- a/src/stdio/fwscanf.c
+++ b/src/stdio/fwscanf.c
@@ -2,7 +2,7 @@
#include <stdarg.h>
#include <wchar.h>
-int fwscanf(FILE *f, const wchar_t *fmt, ...)
+int fwscanf(FILE *restrict f, const wchar_t *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/getdelim.c b/src/stdio/getdelim.c
index b7e04acb..5015c3a6 100644
--- a/src/stdio/getdelim.c
+++ b/src/stdio/getdelim.c
@@ -2,7 +2,7 @@
#define MIN(a,b) ((a)<(b) ? (a) : (b))
-ssize_t getdelim(char **s, size_t *n, int delim, FILE *f)
+ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restrict f)
{
char *tmp;
unsigned char *z;
diff --git a/src/stdio/getline.c b/src/stdio/getline.c
index a3a6651b..476d0b09 100644
--- a/src/stdio/getline.c
+++ b/src/stdio/getline.c
@@ -1,6 +1,6 @@
#include <stdio.h>
-ssize_t getline(char **s, size_t *n, FILE *f)
+ssize_t getline(char **restrict s, size_t *restrict n, FILE *restrict f)
{
return getdelim(s, n, '\n', f);
}
diff --git a/src/stdio/printf.c b/src/stdio/printf.c
index 7b7c329f..cebfe404 100644
--- a/src/stdio/printf.c
+++ b/src/stdio/printf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-int printf(const char *fmt, ...)
+int printf(const char *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/scanf.c b/src/stdio/scanf.c
index a04a4402..3b35bdce 100644
--- a/src/stdio/scanf.c
+++ b/src/stdio/scanf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-int scanf(const char *fmt, ...)
+int scanf(const char *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/setbuf.c b/src/stdio/setbuf.c
index 1b98d503..74ad7834 100644
--- a/src/stdio/setbuf.c
+++ b/src/stdio/setbuf.c
@@ -1,6 +1,6 @@
#include <stdio.h>
-void setbuf(FILE *f, char *buf)
+void setbuf(FILE *restrict f, char *restrict buf)
{
setvbuf(f, buf, buf ? _IOFBF : _IONBF, BUFSIZ);
}
diff --git a/src/stdio/setvbuf.c b/src/stdio/setvbuf.c
index 6dea0ebf..541a125f 100644
--- a/src/stdio/setvbuf.c
+++ b/src/stdio/setvbuf.c
@@ -9,7 +9,7 @@
* In the case of stderr where the preexisting buffer is length 1, it
* is not possible to set line buffering or full buffering. */
-int setvbuf(FILE *f, char *buf, int type, size_t size)
+int setvbuf(FILE *restrict f, char *restrict buf, int type, size_t size)
{
f->lbf = EOF;
diff --git a/src/stdio/snprintf.c b/src/stdio/snprintf.c
index 4071c2f6..771503b2 100644
--- a/src/stdio/snprintf.c
+++ b/src/stdio/snprintf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-int snprintf(char *s, size_t n, const char *fmt, ...)
+int snprintf(char *restrict s, size_t n, const char *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/sprintf.c b/src/stdio/sprintf.c
index 6b225409..9dff524c 100644
--- a/src/stdio/sprintf.c
+++ b/src/stdio/sprintf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-int sprintf(char *s, const char *fmt, ...)
+int sprintf(char *restrict s, const char *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/sscanf.c b/src/stdio/sscanf.c
index a1cea699..b575edf7 100644
--- a/src/stdio/sscanf.c
+++ b/src/stdio/sscanf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-int sscanf(const char *s, const char *fmt, ...)
+int sscanf(const char *restrict s, const char *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/swprintf.c b/src/stdio/swprintf.c
index 5ece97c4..cbf83d23 100644
--- a/src/stdio/swprintf.c
+++ b/src/stdio/swprintf.c
@@ -2,7 +2,7 @@
#include <stdarg.h>
#include <wchar.h>
-int swprintf(wchar_t *s, size_t n, const wchar_t *fmt, ...)
+int swprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/swscanf.c b/src/stdio/swscanf.c
index b66ad03e..1fe3c3d8 100644
--- a/src/stdio/swscanf.c
+++ b/src/stdio/swscanf.c
@@ -2,7 +2,7 @@
#include <stdarg.h>
#include <wchar.h>
-int swscanf(const wchar_t *s, const wchar_t *fmt, ...)
+int swscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/vdprintf.c b/src/stdio/vdprintf.c
index b41a3c74..c35d9b4f 100644
--- a/src/stdio/vdprintf.c
+++ b/src/stdio/vdprintf.c
@@ -5,7 +5,7 @@ static size_t wrap_write(FILE *f, const unsigned char *buf, size_t len)
return __stdio_write(f, buf, len);
}
-int vdprintf(int fd, const char *fmt, va_list ap)
+int vdprintf(int fd, const char *restrict fmt, va_list ap)
{
FILE f = {
.fd = fd, .lbf = EOF, .write = wrap_write,
diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
index d186d58b..6525938f 100644
--- a/src/stdio/vfprintf.c
+++ b/src/stdio/vfprintf.c
@@ -636,7 +636,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg,
return 1;
}
-int vfprintf(FILE *f, const char *fmt, va_list ap)
+int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap)
{
va_list ap2;
int nl_type[NL_ARGMAX+1] = {0};
diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c
index 61b0edb1..54d08495 100644
--- a/src/stdio/vfscanf.c
+++ b/src/stdio/vfscanf.c
@@ -71,7 +71,7 @@ static int readwc(int c, wchar_t **wcs, mbstate_t *st)
return 0;
}
-int vfscanf(FILE *f, const char *fmt, va_list ap)
+int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap)
{
int width;
int size;
diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c
index 62829806..a42ba195 100644
--- a/src/stdio/vfwprintf.c
+++ b/src/stdio/vfwprintf.c
@@ -336,7 +336,7 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_
return 1;
}
-int vfwprintf(FILE *f, const wchar_t *fmt, va_list ap)
+int vfwprintf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap)
{
va_list ap2;
int nl_type[NL_ARGMAX] = {0};
diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c
index de74fe0c..b3bc6f3a 100644
--- a/src/stdio/vfwscanf.c
+++ b/src/stdio/vfwscanf.c
@@ -86,7 +86,7 @@ static int in_set(const wchar_t *set, int c)
((f)->rend && (c)<128U ? *--(f)->rpos : ungetwc((c),(f)))
#endif
-int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap)
+int vfwscanf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap)
{
int width;
int size;
diff --git a/src/stdio/vprintf.c b/src/stdio/vprintf.c
index 67b38dac..30d2bffa 100644
--- a/src/stdio/vprintf.c
+++ b/src/stdio/vprintf.c
@@ -1,6 +1,6 @@
#include <stdio.h>
-int vprintf(const char *fmt, va_list ap)
+int vprintf(const char *restrict fmt, va_list ap)
{
return vfprintf(stdout, fmt, ap);
}
diff --git a/src/stdio/vscanf.c b/src/stdio/vscanf.c
index 6f55b1c3..6901958a 100644
--- a/src/stdio/vscanf.c
+++ b/src/stdio/vscanf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdarg.h>
-int vscanf(const char *fmt, va_list ap)
+int vscanf(const char *restrict fmt, va_list ap)
{
return vfscanf(stdin, fmt, ap);
}
diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c
index ba17bd7d..6f19b028 100644
--- a/src/stdio/vsnprintf.c
+++ b/src/stdio/vsnprintf.c
@@ -10,7 +10,7 @@ static size_t sn_write(FILE *f, const unsigned char *s, size_t l)
return l;
}
-int vsnprintf(char *s, size_t n, const char *fmt, va_list ap)
+int vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap)
{
int r;
char b;
diff --git a/src/stdio/vsprintf.c b/src/stdio/vsprintf.c
index 7836ccb2..c57349d4 100644
--- a/src/stdio/vsprintf.c
+++ b/src/stdio/vsprintf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <limits.h>
-int vsprintf(char *s, const char *fmt, va_list ap)
+int vsprintf(char *restrict s, const char *restrict fmt, va_list ap)
{
return vsnprintf(s, INT_MAX, fmt, ap);
}
diff --git a/src/stdio/vsscanf.c b/src/stdio/vsscanf.c
index fbc15e69..049f4dd0 100644
--- a/src/stdio/vsscanf.c
+++ b/src/stdio/vsscanf.c
@@ -5,7 +5,7 @@ static size_t do_read(FILE *f, unsigned char *buf, size_t len)
return __string_read(f, buf, len);
}
-int vsscanf(const char *s, const char *fmt, va_list ap)
+int vsscanf(const char *restrict s, const char *restrict fmt, va_list ap)
{
FILE f = {
.buf = (void *)s, .cookie = (void *)s,
diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c
index 8e8f80ce..f3d4fec1 100644
--- a/src/stdio/vswprintf.c
+++ b/src/stdio/vswprintf.c
@@ -22,7 +22,7 @@ static size_t sw_write(FILE *f, const unsigned char *s, size_t l)
return i<0 ? i : l0;
}
-int vswprintf(wchar_t *s, size_t n, const wchar_t *fmt, va_list ap)
+int vswprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, va_list ap)
{
int r;
FILE f;
diff --git a/src/stdio/vswscanf.c b/src/stdio/vswscanf.c
index 4c39f806..a205200a 100644
--- a/src/stdio/vswscanf.c
+++ b/src/stdio/vswscanf.c
@@ -23,7 +23,7 @@ static size_t wstring_read(FILE *f, unsigned char *buf, size_t len)
return 1;
}
-int vswscanf(const wchar_t *s, const wchar_t *fmt, va_list ap)
+int vswscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, va_list ap)
{
unsigned char buf[256];
FILE f = {
diff --git a/src/stdio/vwprintf.c b/src/stdio/vwprintf.c
index c1923e62..eeeecdc7 100644
--- a/src/stdio/vwprintf.c
+++ b/src/stdio/vwprintf.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <wchar.h>
-int vwprintf(const wchar_t *fmt, va_list ap)
+int vwprintf(const wchar_t *restrict fmt, va_list ap)
{
return vfwprintf(stdout, fmt, ap);
}
diff --git a/src/stdio/vwscanf.c b/src/stdio/vwscanf.c
index 86da0457..9297cf0d 100644
--- a/src/stdio/vwscanf.c
+++ b/src/stdio/vwscanf.c
@@ -2,7 +2,7 @@
#include <stdarg.h>
#include <wchar.h>
-int vwscanf(const wchar_t *fmt, va_list ap)
+int vwscanf(const wchar_t *restrict fmt, va_list ap)
{
return vfwscanf(stdin, fmt, ap);
}
diff --git a/src/stdio/wprintf.c b/src/stdio/wprintf.c
index 20ca61a0..342cd979 100644
--- a/src/stdio/wprintf.c
+++ b/src/stdio/wprintf.c
@@ -2,7 +2,7 @@
#include <stdarg.h>
#include <wchar.h>
-int wprintf(const wchar_t *fmt, ...)
+int wprintf(const wchar_t *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdio/wscanf.c b/src/stdio/wscanf.c
index 34b58846..a207cc1b 100644
--- a/src/stdio/wscanf.c
+++ b/src/stdio/wscanf.c
@@ -2,7 +2,7 @@
#include <stdarg.h>
#include <wchar.h>
-int wscanf(const wchar_t *fmt, ...)
+int wscanf(const wchar_t *restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/src/stdlib/strtod.c b/src/stdlib/strtod.c
index 1886efa5..c6f89e79 100644
--- a/src/stdlib/strtod.c
+++ b/src/stdlib/strtod.c
@@ -16,17 +16,17 @@ static long double strtox(const char *s, char **p, int prec)
return y;
}
-float strtof(const char *s, char **p)
+float strtof(const char *restrict s, char **restrict p)
{
return strtox(s, p, 0);
}
-double strtod(const char *s, char **p)
+double strtod(const char *restrict s, char **restrict p)
{
return strtox(s, p, 1);
}
-long double strtold(const char *s, char **p)
+long double strtold(const char *restrict s, char **restrict p)
{
return strtox(s, p, 2);
}
diff --git a/src/stdlib/strtol.c b/src/stdlib/strtol.c
index 4a949cb0..23a2f3b6 100644
--- a/src/stdlib/strtol.c
+++ b/src/stdlib/strtol.c
@@ -22,32 +22,32 @@ static unsigned long long strtox(const char *s, char **p, int base, unsigned lon
return y;
}
-unsigned long long strtoull(const char *s, char **p, int base)
+unsigned long long strtoull(const char *restrict s, char **restrict p, int base)
{
return strtox(s, p, base, ULLONG_MAX);
}
-long long strtoll(const char *s, char **p, int base)
+long long strtoll(const char *restrict s, char **restrict p, int base)
{
return strtox(s, p, base, LLONG_MIN);
}
-unsigned long strtoul(const char *s, char **p, int base)
+unsigned long strtoul(const char *restrict s, char **restrict p, int base)
{
return strtox(s, p, base, ULONG_MAX);
}
-long strtol(const char *s, char **p, int base)
+long strtol(const char *restrict s, char **restrict p, int base)
{
return strtox(s, p, base, 0UL+LONG_MIN);
}
-intmax_t strtoimax(const char *s, char **p, int base)
+intmax_t strtoimax(const char *restrict s, char **restrict p, int base)
{
return strtoll(s, p, base);
}
-uintmax_t strtoumax(const char *s, char **p, int base)
+uintmax_t strtoumax(const char *restrict s, char **restrict p, int base)
{
return strtoull(s, p, base);
}
diff --git a/src/stdlib/wcstod.c b/src/stdlib/wcstod.c
index 5ec45dd7..03670b0b 100644
--- a/src/stdlib/wcstod.c
+++ b/src/stdlib/wcstod.c
@@ -47,17 +47,17 @@ static long double wcstox(const wchar_t *s, wchar_t **p, int prec)
return y;
}
-float wcstof(const wchar_t *s, wchar_t **p)
+float wcstof(const wchar_t *restrict s, wchar_t **restrict p)
{
return wcstox(s, p, 0);
}
-double wcstod(const wchar_t *s, wchar_t **p)
+double wcstod(const wchar_t *restrict s, wchar_t **restrict p)
{
return wcstox(s, p, 1);
}
-long double wcstold(const wchar_t *s, wchar_t **p)
+long double wcstold(const wchar_t *restrict s, wchar_t **restrict p)
{
return wcstox(s, p, 2);
}
diff --git a/src/stdlib/wcstol.c b/src/stdlib/wcstol.c
index 840bb0a6..3d7c97da 100644
--- a/src/stdlib/wcstol.c
+++ b/src/stdlib/wcstol.c
@@ -47,32 +47,32 @@ static unsigned long long wcstox(const wchar_t *s, wchar_t **p, int base, unsign
return y;
}
-unsigned long long wcstoull(const wchar_t *s, wchar_t **p, int base)
+unsigned long long wcstoull(const wchar_t *restrict s, wchar_t **restrict p, int base)
{
return wcstox(s, p, base, ULLONG_MAX);
}
-long long wcstoll(const wchar_t *s, wchar_t **p, int base)
+long long wcstoll(const wchar_t *restrict s, wchar_t **restrict p, int base)
{
return wcstox(s, p, base, LLONG_MIN);
}
-unsigned long wcstoul(const wchar_t *s, wchar_t **p, int base)
+unsigned long wcstoul(const wchar_t *restrict s, wchar_t **restrict p, int base)
{
return wcstox(s, p, base, ULONG_MAX);
}
-long wcstol(const wchar_t *s, wchar_t **p, int base)
+long wcstol(const wchar_t *restrict s, wchar_t **restrict p, int base)
{
return wcstox(s, p, base, 0UL+LONG_MIN);
}
-intmax_t wcstoimax(const wchar_t *s, wchar_t **p, int base)
+intmax_t wcstoimax(const wchar_t *restrict s, wchar_t **restrict p, int base)
{
return wcstoll(s, p, base);
}
-uintmax_t wcstoumax(const wchar_t *s, wchar_t **p, int base)
+uintmax_t wcstoumax(const wchar_t *restrict s, wchar_t **restrict p, int base)
{
return wcstoull(s, p, base);
}
diff --git a/src/string/memccpy.c b/src/string/memccpy.c
index 2ccb31bb..b85009c8 100644
--- a/src/string/memccpy.c
+++ b/src/string/memccpy.c
@@ -8,7 +8,7 @@
#define HIGHS (ONES * (UCHAR_MAX/2+1))
#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
-void *memccpy(void *dest, const void *src, int c, size_t n)
+void *memccpy(void *restrict dest, const void *restrict src, int c, size_t n)
{
unsigned char *d = dest;
const unsigned char *s = src;
diff --git a/src/string/memcpy.c b/src/string/memcpy.c
index 02cb4694..8e98302f 100644
--- a/src/string/memcpy.c
+++ b/src/string/memcpy.c
@@ -6,7 +6,7 @@
#define ALIGN (sizeof(size_t)-1)
#define ONES ((size_t)-1/UCHAR_MAX)
-void *memcpy(void *dest, const void *src, size_t n)
+void *memcpy(void *restrict dest, const void *restrict src, size_t n)
{
unsigned char *d = dest;
const unsigned char *s = src;
diff --git a/src/string/stpcpy.c b/src/string/stpcpy.c
index 10ca4933..da96f215 100644
--- a/src/string/stpcpy.c
+++ b/src/string/stpcpy.c
@@ -9,7 +9,7 @@
#define HIGHS (ONES * (UCHAR_MAX/2+1))
#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
-char *__stpcpy(char *d, const char *s)
+char *__stpcpy(char *restrict d, const char *restrict s)
{
size_t *wd;
const size_t *ws;
diff --git a/src/string/stpncpy.c b/src/string/stpncpy.c
index a04cdce8..0a2c2a9d 100644
--- a/src/string/stpncpy.c
+++ b/src/string/stpncpy.c
@@ -9,7 +9,7 @@
#define HIGHS (ONES * (UCHAR_MAX/2+1))
#define HASZERO(x) ((x)-ONES & ~(x) & HIGHS)
-char *__stpncpy(char *d, const char *s, size_t n)
+char *__stpncpy(char *restrict d, const char *restrict s, size_t n)
{
size_t *wd;
const size_t *ws;
diff --git a/src/string/strcat.c b/src/string/strcat.c
index 29fdb611..33f749b1 100644
--- a/src/string/strcat.c
+++ b/src/string/strcat.c
@@ -1,6 +1,6 @@
#include <string.h>
-char *strcat(char *dest, const char *src)
+char *strcat(char *restrict dest, const char *restrict src)
{
strcpy(dest + strlen(dest), src);
return dest;
diff --git a/src/string/strcpy.c b/src/string/strcpy.c
index 7675e9ce..f7e3ba38 100644
--- a/src/string/strcpy.c
+++ b/src/string/strcpy.c
@@ -2,7 +2,7 @@
char *__stpcpy(char *, const char *);
-char *strcpy(char *dest, const char *src)
+char *strcpy(char *restrict dest, const char *restrict src)
{
#if 1
__stpcpy(dest, src);
diff --git a/src/string/strncat.c b/src/string/strncat.c
index 08685ad6..01ca2a23 100644
--- a/src/string/strncat.c
+++ b/src/string/strncat.c
@@ -1,6 +1,6 @@
#include <string.h>
-char *strncat(char *d, const char *s, size_t n)
+char *strncat(char *restrict d, const char *restrict s, size_t n)
{
char *a = d;
d += strlen(d);
diff --git a/src/string/strncpy.c b/src/string/strncpy.c
index c0cd7974..441ba033 100644
--- a/src/string/strncpy.c
+++ b/src/string/strncpy.c
@@ -2,7 +2,7 @@
char *__stpncpy(char *, const char *, size_t);
-char *strncpy(char *d, const char *s, size_t n)
+char *strncpy(char *restrict d, const char *restrict s, size_t n)
{
__stpncpy(d, s, n);
return d;
diff --git a/src/string/strtok.c b/src/string/strtok.c
index 1ba221cb..35087902 100644
--- a/src/string/strtok.c
+++ b/src/string/strtok.c
@@ -1,6 +1,6 @@
#include <string.h>
-char *strtok(char *s, const char *sep)
+char *strtok(char *restrict s, const char *restrict sep)
{
static char *p;
if (!s && !(s = p)) return NULL;
diff --git a/src/string/strtok_r.c b/src/string/strtok_r.c
index c763897a..862d4fe4 100644
--- a/src/string/strtok_r.c
+++ b/src/string/strtok_r.c
@@ -1,6 +1,6 @@
#include <string.h>
-char *strtok_r(char *s, const char *sep, char **p)
+char *strtok_r(char *restrict s, const char *restrict sep, char **restrict p)
{
if (!s && !(s = *p)) return NULL;
s += strspn(s, sep);
diff --git a/src/string/swab.c b/src/string/swab.c
index b2132884..9ed6fcda 100644
--- a/src/string/swab.c
+++ b/src/string/swab.c
@@ -1,6 +1,6 @@
#include <unistd.h>
-void swab(const void *_src, void *_dest, ssize_t n)
+void swab(const void *restrict _src, void *restrict _dest, ssize_t n)
{
const char *src = _src;
char *dest = _dest;
diff --git a/src/string/wcpcpy.c b/src/string/wcpcpy.c
index fdf878f6..ef401343 100644
--- a/src/string/wcpcpy.c
+++ b/src/string/wcpcpy.c
@@ -1,6 +1,6 @@
#include <wchar.h>
-wchar_t *wcpcpy(wchar_t *d, const wchar_t *s)
+wchar_t *wcpcpy(wchar_t *restrict d, const wchar_t *restrict s)
{
return wcscpy(d, s) + wcslen(s);
}
diff --git a/src/string/wcpncpy.c b/src/string/wcpncpy.c
index aef80962..b667f6d6 100644
--- a/src/string/wcpncpy.c
+++ b/src/string/wcpncpy.c
@@ -1,6 +1,6 @@
#include <wchar.h>
-wchar_t *wcpncpy(wchar_t *d, const wchar_t *s, size_t n)
+wchar_t *wcpncpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n)
{
return wcsncpy(d, s, n) + wcsnlen(s, n);
}
diff --git a/src/string/wcscat.c b/src/string/wcscat.c
index 946f16e2..d4f00ebd 100644
--- a/src/string/wcscat.c
+++ b/src/string/wcscat.c
@@ -1,6 +1,6 @@
#include <wchar.h>
-wchar_t *wcscat(wchar_t *dest, const wchar_t *src)
+wchar_t *wcscat(wchar_t *restrict dest, const wchar_t *restrict src)
{
wcscpy(dest + wcslen(dest), src);
return dest;
diff --git a/src/string/wcscpy.c b/src/string/wcscpy.c
index e0ac194f..625bf53d 100644
--- a/src/string/wcscpy.c
+++ b/src/string/wcscpy.c
@@ -1,6 +1,6 @@
#include <wchar.h>
-wchar_t *wcscpy(wchar_t *d, const wchar_t *s)
+wchar_t *wcscpy(wchar_t *restrict d, const wchar_t *restrict s)
{
wchar_t *a = d;
while ((*d++ = *s++));
diff --git a/src/string/wcsncat.c b/src/string/wcsncat.c
index 9d61bbbd..8563f1a2 100644
--- a/src/string/wcsncat.c
+++ b/src/string/wcsncat.c
@@ -1,6 +1,6 @@
#include <wchar.h>
-wchar_t *wcsncat(wchar_t *d, const wchar_t *s, size_t n)
+wchar_t *wcsncat(wchar_t *restrict d, const wchar_t *restrict s, size_t n)
{
wchar_t *a = d;
d += wcslen(d);
diff --git a/src/string/wcsncpy.c b/src/string/wcsncpy.c
index 714eeb64..4bede04d 100644
--- a/src/string/wcsncpy.c
+++ b/src/string/wcsncpy.c
@@ -1,6 +1,6 @@
#include <wchar.h>
-wchar_t *wcsncpy(wchar_t *d, const wchar_t *s, size_t n)
+wchar_t *wcsncpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n)
{
wchar_t *a = d;
while (n && *s) n--, *d++ = *s++;
diff --git a/src/string/wcsstr.c b/src/string/wcsstr.c
index fc4bacec..037d0965 100644
--- a/src/string/wcsstr.c
+++ b/src/string/wcsstr.c
@@ -93,7 +93,7 @@ static wchar_t *twoway_wcsstr(const wchar_t *h, const wchar_t *n)
}
}
-wchar_t *wcsstr(const wchar_t *h, const wchar_t *n)
+wchar_t *wcsstr(const wchar_t *restrict h, const wchar_t *restrict n)
{
/* Return immediately on empty needle or haystack */
if (!n[0]) return (wchar_t *)h;
diff --git a/src/string/wcstok.c b/src/string/wcstok.c
index c932d0a0..ecc80331 100644
--- a/src/string/wcstok.c
+++ b/src/string/wcstok.c
@@ -1,6 +1,6 @@
#include <wchar.h>
-wchar_t *wcstok(wchar_t *s, const wchar_t *sep, wchar_t **p)
+wchar_t *wcstok(wchar_t *restrict s, const wchar_t *restrict sep, wchar_t **restrict p)
{
if (!s && !(s = *p)) return NULL;
s += wcsspn(s, sep);
diff --git a/src/string/wmemcpy.c b/src/string/wmemcpy.c
index 330e37c7..55a8e1d8 100644
--- a/src/string/wmemcpy.c
+++ b/src/string/wmemcpy.c
@@ -1,7 +1,7 @@
#include <string.h>
#include <wchar.h>
-wchar_t *wmemcpy(wchar_t *d, const wchar_t *s, size_t n)
+wchar_t *wmemcpy(wchar_t *restrict d, const wchar_t *restrict s, size_t n)
{
wchar_t *a = d;
while (n--) *d++ = *s++;
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 <pthread.h>
#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 <semaphore.h>
-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;
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)
{
__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 <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];
diff --git a/src/unistd/readlink.c b/src/unistd/readlink.c
index 0c6d3861..ec291e3d 100644
--- a/src/unistd/readlink.c
+++ b/src/unistd/readlink.c
@@ -1,7 +1,7 @@
#include <unistd.h>
#include "syscall.h"
-ssize_t readlink(const char *path, char *buf, size_t bufsize)
+ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize)
{
return syscall(SYS_readlink, path, buf, bufsize);
}
diff --git a/src/unistd/readlinkat.c b/src/unistd/readlinkat.c
index e9498650..9af45cd5 100644
--- a/src/unistd/readlinkat.c
+++ b/src/unistd/readlinkat.c
@@ -1,7 +1,7 @@
#include <unistd.h>
#include "syscall.h"
-ssize_t readlinkat(int fd, const char *path, char *buf, size_t bufsize)
+ssize_t readlinkat(int fd, const char *restrict path, char *restrict buf, size_t bufsize)
{
return syscall(SYS_readlinkat, fd, path, buf, bufsize);
}