summaryrefslogtreecommitdiff
path: root/include/string.h
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 /include/string.h
parentbac03cdde1137c16b4c194e137310e2748661dcc (diff)
downloadmusl-400c5e5c8307a2ebe44ef1f203f5a15669f20347.tar.gz
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 'include/string.h')
-rw-r--r--include/string.h30
1 files changed, 18 insertions, 12 deletions
diff --git a/include/string.h b/include/string.h
index 24cb1ca3..f96f71ee 100644
--- a/include/string.h
+++ b/include/string.h
@@ -5,6 +5,12 @@
extern "C" {
#endif
+#if __STDC_VERSION__ >= 199901L
+#define __restrict restrict
+#elif !defined(__GNUC__)
+#define __restrict
+#endif
+
#undef NULL
#ifdef __cplusplus
#define NULL 0
@@ -21,23 +27,23 @@ extern "C" {
#include <bits/alltypes.h>
-void *memcpy (void *, const void *, size_t);
+void *memcpy (void *__restrict, const void *__restrict, size_t);
void *memmove (void *, const void *, size_t);
void *memset (void *, int, size_t);
int memcmp (const void *, const void *, size_t);
void *memchr (const void *, int, size_t);
-char *strcpy (char *, const char *);
-char *strncpy (char *, const char *, size_t);
+char *strcpy (char *__restrict, const char *__restrict);
+char *strncpy (char *__restrict, const char *__restrict, size_t);
-char *strcat (char *, const char *);
-char *strncat (char *, const char *, size_t);
+char *strcat (char *__restrict, const char *__restrict);
+char *strncat (char *__restrict, const char *__restrict, size_t);
int strcmp (const char *, const char *);
int strncmp (const char *, const char *, size_t);
int strcoll (const char *, const char *);
-size_t strxfrm (char *, const char *, size_t);
+size_t strxfrm (char *__restrict, const char *__restrict, size_t);
char *strchr (const char *, int);
char *strrchr (const char *, int);
@@ -46,7 +52,7 @@ size_t strcspn (const char *, const char *);
size_t strspn (const char *, const char *);
char *strpbrk (const char *, const char *);
char *strstr (const char *, const char *);
-char *strtok (char *, const char *);
+char *strtok (char *__restrict, const char *__restrict);
size_t strlen (const char *);
@@ -59,22 +65,22 @@ char *strerror (int);
#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
|| defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|| defined(_BSD_SOURCE)
-char *strtok_r (char *, const char *, char **);
+char *strtok_r (char *__restrict, const char *__restrict, char **__restrict);
int strerror_r (int, char *, size_t);
-char *stpcpy(char *, const char *);
-char *stpncpy(char *, const char *, size_t);
+char *stpcpy(char *__restrict, const char *__restrict);
+char *stpncpy(char *__restrict, const char *__restrict, size_t);
size_t strnlen (const char *, size_t);
char *strdup (const char *);
char *strndup (const char *, size_t);
char *strsignal(int);
char *strerror_l (int, locale_t);
int strcoll_l (const char *, const char *, locale_t);
-size_t strxfrm_l (char *, const char *, size_t, locale_t);
+size_t strxfrm_l (char *__restrict, const char *__restrict, size_t, locale_t);
#endif
#if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
|| defined(_BSD_SOURCE)
-void *memccpy (void *, const void *, int, size_t);
+void *memccpy (void *__restrict, const void *__restrict, int, size_t);
#endif
#ifdef _BSD_SOURCE