diff --git a/newlib/ChangeLog b/newlib/ChangeLog index d706f45e6..2cdb28871 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,19 @@ +2013-07-23 Sahil Patnayakuni + + * libc/sys/linux/include/netdb.h, libc/sys/linux/net/getaddrinfo.c, + libc/sys/linux/net/getnameinfo.c: Add restrict keyword to getnameinfo() + and getaddrinfo() to increase standards compliance and match glibc. + +2013-07-23 Sahil Patnayakuni + + * libc/include/string.h, libc/string/memccpy.c, libc/string/memcpy.c, + libc/string/stpcpy.c, libc/string/stpncpy.c, libc/string/strcat.c, + libc/string/strncat.c, libc/string/strncpy.c, libc/string/strtok.c, + libc/string/strtok_r.c, libc/string/strxfrm.c + libc/machine/microblaze/strcpy.c, libc/machine/xscale/memcpy.c, + libc/machine/cris/memcpy.c: Add __restrict to prototype to + increase standards compliance. + 2013-07-18 Ramana Radhakrishnan * libc/sys/arm/syscalls.c (do_AngelSWI): Delete. diff --git a/newlib/libc/include/string.h b/newlib/libc/include/string.h index 5f1329ee0..6325b46bf 100644 --- a/newlib/libc/include/string.h +++ b/newlib/libc/include/string.h @@ -20,47 +20,47 @@ _BEGIN_STD_C _PTR _EXFUN(memchr,(const _PTR, int, size_t)); int _EXFUN(memcmp,(const _PTR, const _PTR, size_t)); -_PTR _EXFUN(memcpy,(_PTR, const _PTR, size_t)); +_PTR _EXFUN(memcpy,(_PTR __restrict, const _PTR __restrict, size_t)); _PTR _EXFUN(memmove,(_PTR, const _PTR, size_t)); _PTR _EXFUN(memset,(_PTR, int, size_t)); -char *_EXFUN(strcat,(char *, const char *)); +char *_EXFUN(strcat,(char *__restrict, const char *__restrict)); char *_EXFUN(strchr,(const char *, int)); int _EXFUN(strcmp,(const char *, const char *)); int _EXFUN(strcoll,(const char *, const char *)); -char *_EXFUN(strcpy,(char *, const char *)); +char *_EXFUN(strcpy,(char *__restrict, const char *__restrict)); size_t _EXFUN(strcspn,(const char *, const char *)); char *_EXFUN(strerror,(int)); size_t _EXFUN(strlen,(const char *)); -char *_EXFUN(strncat,(char *, const char *, size_t)); +char *_EXFUN(strncat,(char *__restrict, const char *__restrict, size_t)); int _EXFUN(strncmp,(const char *, const char *, size_t)); -char *_EXFUN(strncpy,(char *, const char *, size_t)); +char *_EXFUN(strncpy,(char *__restrict, const char *__restrict, size_t)); char *_EXFUN(strpbrk,(const char *, const char *)); char *_EXFUN(strrchr,(const char *, int)); size_t _EXFUN(strspn,(const char *, const char *)); char *_EXFUN(strstr,(const char *, const char *)); #ifndef _REENT_ONLY -char *_EXFUN(strtok,(char *, const char *)); +char *_EXFUN(strtok,(char *__restrict, const char *__restrict)); #endif -size_t _EXFUN(strxfrm,(char *, const char *, size_t)); +size_t _EXFUN(strxfrm,(char *__restrict, const char *__restrict, size_t)); #ifndef __STRICT_ANSI__ -char *_EXFUN(strtok_r,(char *, const char *, char **)); +char *_EXFUN(strtok_r,(char *__restrict, const char *__restrict, char **__restrict)); int _EXFUN(bcmp,(const void *, const void *, size_t)); void _EXFUN(bcopy,(const void *, void *, size_t)); void _EXFUN(bzero,(void *, size_t)); int _EXFUN(ffs,(int)); char *_EXFUN(index,(const char *, int)); -_PTR _EXFUN(memccpy,(_PTR, const _PTR, int, size_t)); +_PTR _EXFUN(memccpy,(_PTR __restrict, const _PTR __restrict, int, size_t)); _PTR _EXFUN(mempcpy,(_PTR, const _PTR, size_t)); _PTR _EXFUN(memmem, (const _PTR, size_t, const _PTR, size_t)); _PTR _EXFUN(memrchr,(const _PTR, int, size_t)); _PTR _EXFUN(rawmemchr,(const _PTR, int)); char *_EXFUN(rindex,(const char *, int)); -char *_EXFUN(stpcpy,(char *, const char *)); -char *_EXFUN(stpncpy,(char *, const char *, size_t)); +char *_EXFUN(stpcpy,(char *__restrict, const char *__restrict)); +char *_EXFUN(stpncpy,(char *__restrict, const char *__restrict, size_t)); int _EXFUN(strcasecmp,(const char *, const char *)); char *_EXFUN(strcasestr,(const char *, const char *)); char *_EXFUN(strchrnul,(const char *, int)); diff --git a/newlib/libc/machine/cris/memcpy.c b/newlib/libc/machine/cris/memcpy.c index c7bd6ebdc..c7a1af957 100644 --- a/newlib/libc/machine/cris/memcpy.c +++ b/newlib/libc/machine/cris/memcpy.c @@ -40,7 +40,7 @@ __asm__ (".syntax no_register_prefix"); void * -memcpy(void *pdst, const void *psrc, size_t pn) +memcpy(void *__restrict pdst, const void *__restrict psrc, size_t pn) { /* Now we want the parameters put in special registers. Make sure the compiler is able to make something useful of this. diff --git a/newlib/libc/machine/microblaze/strcpy.c b/newlib/libc/machine/microblaze/strcpy.c index d5430a305..0819ee511 100644 --- a/newlib/libc/machine/microblaze/strcpy.c +++ b/newlib/libc/machine/microblaze/strcpy.c @@ -36,7 +36,7 @@ INDEX ANSI_SYNOPSIS #include - char *strcpy(char *<[dst]>, const char *<[src]>); + char *strcpy(char *restrict <[dst]>, const char *restrict <[src]>); TRAD_SYNOPSIS #include @@ -88,8 +88,8 @@ QUICKREF char* _DEFUN (strcpy, (dst0, src0), - char *dst0 _AND - _CONST char *src0) + char *__restrict dst0 _AND + _CONST char *__restrict src0) { #ifndef HAVE_HW_PCMP diff --git a/newlib/libc/machine/xscale/memcpy.c b/newlib/libc/machine/xscale/memcpy.c index 1a3297778..7de967fb9 100644 --- a/newlib/libc/machine/xscale/memcpy.c +++ b/newlib/libc/machine/xscale/memcpy.c @@ -8,7 +8,7 @@ #include "xscale.h" void * -memcpy (void *dst0, const void *src0, size_t len) +memcpy (void *__restrict dst0, const void *__restrict src0, size_t len) { int dummy; asm volatile ( diff --git a/newlib/libc/string/memccpy.c b/newlib/libc/string/memccpy.c index a6f45e8b3..dded85781 100644 --- a/newlib/libc/string/memccpy.c +++ b/newlib/libc/string/memccpy.c @@ -4,7 +4,7 @@ FUNCTION ANSI_SYNOPSIS #include - void* memccpy(void *<[out]>, const void *<[in]>, + void* memccpy(void *restrict <[out]>, const void *restrict <[in]>, int <[endchar]>, size_t <[n]>); TRAD_SYNOPSIS @@ -64,8 +64,8 @@ PORTABILITY _PTR _DEFUN (memccpy, (dst0, src0, endchar, len0), - _PTR dst0 _AND - _CONST _PTR src0 _AND + _PTR __restrict dst0 _AND + _CONST _PTR __restrict src0 _AND int endchar0 _AND size_t len0) { diff --git a/newlib/libc/string/memcpy.c b/newlib/libc/string/memcpy.c index c1c726dab..5f27bca72 100644 --- a/newlib/libc/string/memcpy.c +++ b/newlib/libc/string/memcpy.c @@ -4,7 +4,8 @@ FUNCTION ANSI_SYNOPSIS #include - void* memcpy(void *<[out]>, const void *<[in]>, size_t <[n]>); + void* memcpy(void *restrict <[out]>, const void *restrict <[in]>, + size_t <[n]>); TRAD_SYNOPSIS #include @@ -51,8 +52,8 @@ QUICKREF _PTR _DEFUN (memcpy, (dst0, src0, len0), - _PTR dst0 _AND - _CONST _PTR src0 _AND + _PTR __restrict dst0 _AND + _CONST _PTR __restrict src0 _AND size_t len0) { #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) diff --git a/newlib/libc/string/stpcpy.c b/newlib/libc/string/stpcpy.c index 62fe79997..bc58f4771 100644 --- a/newlib/libc/string/stpcpy.c +++ b/newlib/libc/string/stpcpy.c @@ -7,7 +7,7 @@ INDEX ANSI_SYNOPSIS #include - char *stpcpy(char *<[dst]>, const char *<[src]>); + char *stpcpy(char *restrict <[dst]>, const char *restrict <[src]>); TRAD_SYNOPSIS #include @@ -60,8 +60,8 @@ QUICKREF char* _DEFUN (stpcpy, (dst, src), - char *dst _AND - _CONST char *src) + char *__restrict dst _AND + _CONST char *__restrict src) { #if !defined(PREFER_SIZE_OVER_SPEED) && !defined(__OPTIMIZE_SIZE__) long *aligned_dst; diff --git a/newlib/libc/string/stpncpy.c b/newlib/libc/string/stpncpy.c index fca10d398..abd9bbdbf 100644 --- a/newlib/libc/string/stpncpy.c +++ b/newlib/libc/string/stpncpy.c @@ -7,7 +7,8 @@ INDEX ANSI_SYNOPSIS #include - char *stpncpy(char *<[dst]>, const char *<[src]>, size_t <[length]>); + char *stpncpy(char *restrict <[dst]>, const char *restrict <[src]>, + size_t <[length]>); TRAD_SYNOPSIS #include @@ -68,8 +69,8 @@ QUICKREF char * _DEFUN (stpncpy, (dst, src), - char *dst _AND - _CONST char *src _AND + char *__restrict dst _AND + _CONST char *__restrict src _AND size_t count) { char *ret = NULL; diff --git a/newlib/libc/string/strcat.c b/newlib/libc/string/strcat.c index 411eadb85..1e4614991 100644 --- a/newlib/libc/string/strcat.c +++ b/newlib/libc/string/strcat.c @@ -7,7 +7,7 @@ INDEX ANSI_SYNOPSIS #include - char *strcat(char *<[dst]>, const char *<[src]>); + char *strcat(char *restrict <[dst]>, const char *restrict <[src]>); TRAD_SYNOPSIS #include @@ -61,8 +61,8 @@ QUICKREF char * _DEFUN (strcat, (s1, s2), - char *s1 _AND - _CONST char *s2) + char *__restrict s1 _AND + _CONST char *__restrict s2) { #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) char *s = s1; diff --git a/newlib/libc/string/strncat.c b/newlib/libc/string/strncat.c index 0f29247a8..d31a0302c 100644 --- a/newlib/libc/string/strncat.c +++ b/newlib/libc/string/strncat.c @@ -7,7 +7,8 @@ INDEX ANSI_SYNOPSIS #include - char *strncat(char *<[dst]>, const char *<[src]>, size_t <[length]>); + char *strncat(char *, const char *, + size_t <[length]>); TRAD_SYNOPSIS #include @@ -65,8 +66,8 @@ QUICKREF char * _DEFUN (strncat, (s1, s2, n), - char *s1 _AND - _CONST char *s2 _AND + char *__restrict s1 _AND + _CONST char *__restrict s2 _AND size_t n) { #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) diff --git a/newlib/libc/string/strncpy.c b/newlib/libc/string/strncpy.c index 7c1973ba6..ff5d0d409 100644 --- a/newlib/libc/string/strncpy.c +++ b/newlib/libc/string/strncpy.c @@ -7,7 +7,8 @@ INDEX ANSI_SYNOPSIS #include - char *strncpy(char *<[dst]>, const char *<[src]>, size_t <[length]>); + char *strncpy(char *restrict <[dst]>, const char *restrict <[src]>, + size_t <[length]>); TRAD_SYNOPSIS #include @@ -66,8 +67,8 @@ QUICKREF char * _DEFUN (strncpy, (dst0, src0), - char *dst0 _AND - _CONST char *src0 _AND + char *__restrict dst0 _AND + _CONST char *__restrict src0 _AND size_t count) { #if defined(PREFER_SIZE_OVER_SPEED) || defined(__OPTIMIZE_SIZE__) diff --git a/newlib/libc/string/strtok.c b/newlib/libc/string/strtok.c index 01bb09046..35460ba04 100644 --- a/newlib/libc/string/strtok.c +++ b/newlib/libc/string/strtok.c @@ -13,9 +13,11 @@ INDEX ANSI_SYNOPSIS #include - char *strtok(char *<[source]>, const char *<[delimiters]>) - char *strtok_r(char *<[source]>, const char *<[delimiters]>, - char **<[lasts]>) + char *strtok(char *restrict <[source]>, + const char *restrict <[delimiters]>) + char *strtok_r(char *restrict <[source]>, + const char *restrict <[delimiters]>, + char **<[lasts]>) char *strsep(char **<[source_ptr]>, const char *<[delimiters]>) TRAD_SYNOPSIS @@ -92,8 +94,8 @@ extern char *__strtok_r (char *, const char *, char **, int); char * _DEFUN (strtok, (s, delim), - register char *s _AND - register const char *delim) + register char *__restrict s _AND + register const char *__restrict delim) { struct _reent *reent = _REENT; diff --git a/newlib/libc/string/strtok_r.c b/newlib/libc/string/strtok_r.c index 02ad80b9b..6ace7008b 100644 --- a/newlib/libc/string/strtok_r.c +++ b/newlib/libc/string/strtok_r.c @@ -91,9 +91,9 @@ cont: char * _DEFUN (strtok_r, (s, delim, lasts), - register char *s _AND - register const char *delim _AND - char **lasts) + register char *__restrict s _AND + register const char *__restrict delim _AND + char **__restrict lasts) { return __strtok_r (s, delim, lasts, 1); } diff --git a/newlib/libc/string/strxfrm.c b/newlib/libc/string/strxfrm.c index 65ed4f1b1..9d0ab882b 100644 --- a/newlib/libc/string/strxfrm.c +++ b/newlib/libc/string/strxfrm.c @@ -7,7 +7,8 @@ INDEX ANSI_SYNOPSIS #include - size_t strxfrm(char *<[s1]>, const char *<[s2]>, size_t <[n]>); + size_t strxfrm(char *restrict <[s1]>, const char *restrict <[s2]>, + size_t <[n]>); TRAD_SYNOPSIS #include @@ -52,8 +53,8 @@ QUICKREF size_t _DEFUN (strxfrm, (s1, s2, n), - char *s1 _AND - _CONST char *s2 _AND + char *__restrict s1 _AND + _CONST char *__restrict s2 _AND size_t n) { size_t res; diff --git a/newlib/libc/sys/linux/include/netdb.h b/newlib/libc/sys/linux/include/netdb.h index 9e57ffe9c..7950298c5 100644 --- a/newlib/libc/sys/linux/include/netdb.h +++ b/newlib/libc/sys/linux/include/netdb.h @@ -256,10 +256,12 @@ void sethostent_r(int, FILE **, int *); /* void sethostfile(const char *); */ void setnetent(int); void setprotoent(int); -int getaddrinfo(const char *, const char *, - const struct addrinfo *, struct addrinfo **); -int getnameinfo(const struct sockaddr *, socklen_t, char *, - socklen_t, char *, socklen_t, unsigned int); +int getaddrinfo(const char *__restrict, const char *__restrict, + const struct addrinfo *__restrict, + struct addrinfo **__restrict); +int getnameinfo(const struct sockaddr *__restrict, socklen_t, + char *__restrict, socklen_t, char *__restrict, + socklen_t, unsigned int); void freeaddrinfo(struct addrinfo *); char *gai_strerror(int); int setnetgrent(const char *); diff --git a/newlib/libc/sys/linux/net/getaddrinfo.c b/newlib/libc/sys/linux/net/getaddrinfo.c index 7019260b4..4ad178986 100644 --- a/newlib/libc/sys/linux/net/getaddrinfo.c +++ b/newlib/libc/sys/linux/net/getaddrinfo.c @@ -1473,8 +1473,9 @@ rfc3484_sort (const void *p1, const void *p2) int -getaddrinfo (const char *name, const char *service, - const struct addrinfo *hints, struct addrinfo **pai) +getaddrinfo (const char *__restrict name, const char *__restrict service, + const struct addrinfo *__restrict hints, + struct addrinfo **__restrict pai) { int i = 0, j = 0, last_i = 0; int nresults = 0; diff --git a/newlib/libc/sys/linux/net/getnameinfo.c b/newlib/libc/sys/linux/net/getnameinfo.c index f79bc317f..838a2d2be 100644 --- a/newlib/libc/sys/linux/net/getnameinfo.c +++ b/newlib/libc/sys/linux/net/getnameinfo.c @@ -160,9 +160,9 @@ nrl_domainname (void) int -getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host, - socklen_t hostlen, char *serv, socklen_t servlen, - unsigned int flags) +getnameinfo (const struct sockaddr *__restrict sa, socklen_t addrlen, + char *__restrict host, socklen_t hostlen, char *__restrict serv, + socklen_t servlen, unsigned int flags) { int serrno = errno; int tmpbuflen = 1024;