path: root/src/network
diff options
authorRich Felker <>2012-09-06 22:44:55 -0400
committerRich Felker <>2012-09-06 22:44:55 -0400
commit400c5e5c8307a2ebe44ef1f203f5a15669f20347 (patch)
tree087a48dc8251fa05f6866af8ebf96b69450b15ab /src/network
parentbac03cdde1137c16b4c194e137310e2748661dcc (diff)
use restrict everywhere it's required by c99 and/or posix 2008
to deal with the fact that the public headers may be used with pre-c99 compilers, __restrict is used in place of restrict, and defined appropriately for any supported compiler. we also avoid the form [restrict] since older versions of gcc rejected it due to a bug in the original c99 standard, and instead use the form *restrict.
Diffstat (limited to 'src/network')
9 files changed, 11 insertions, 11 deletions
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);