about summary refs log tree commit diff
path: root/src/string
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/string
parentbac03cdde1137c16b4c194e137310e2748661dcc (diff)
downloadmusl-400c5e5c8307a2ebe44ef1f203f5a15669f20347.tar.gz
musl-400c5e5c8307a2ebe44ef1f203f5a15669f20347.tar.xz
musl-400c5e5c8307a2ebe44ef1f203f5a15669f20347.zip
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/string')
-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
20 files changed, 20 insertions, 20 deletions
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++;