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.
This commit is contained in:
@@ -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++) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
|
||||
+2
-2
@@ -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;
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+2
-2
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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};
|
||||
|
||||
+1
-1
@@ -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;
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
+1
-1
@@ -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);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user