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:
Rich Felker 2012-09-06 22:44:55 -04:00
commit 400c5e5c83
192 changed files with 552 additions and 382 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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];

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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);
}

View file

@ -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;

View file

@ -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;

View file

@ -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);
}