From 400c5e5c8307a2ebe44ef1f203f5a15669f20347 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 6 Sep 2012 22:44:55 -0400 Subject: 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. --- include/stdlib.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'include/stdlib.h') diff --git a/include/stdlib.h b/include/stdlib.h index 1749cb3b..14cc71bb 100644 --- a/include/stdlib.h +++ b/include/stdlib.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 @@ -22,14 +28,14 @@ long atol (const char *); long long atoll (const char *); double atof (const char *); -float strtof (const char *, char **); -double strtod (const char *, char **); -long double strtold (const char *, char **); +float strtof (const char *__restrict, char **__restrict); +double strtod (const char *__restrict, char **__restrict); +long double strtold (const char *__restrict, char **__restrict); -long strtol (const char *, char **, int); -unsigned long strtoul (const char *, char **, int); -long long strtoll (const char *, char **, int); -unsigned long long strtoull (const char *, char **, int); +long strtol (const char *__restrict, char **__restrict, int); +unsigned long strtoul (const char *__restrict, char **__restrict, int); +long long strtoll (const char *__restrict, char **__restrict, int); +unsigned long long strtoull (const char *__restrict, char **__restrict, int); int rand (void); void srand (unsigned); @@ -67,10 +73,10 @@ ldiv_t ldiv (long, long); lldiv_t lldiv (long long, long long); int mblen (const char *, size_t); -int mbtowc (wchar_t *, const char *, size_t); +int mbtowc (wchar_t *__restrict, const char *__restrict, size_t); int wctomb (char *, wchar_t); -size_t mbstowcs (wchar_t *, const char *, size_t); -size_t wcstombs (char *, const wchar_t *, size_t); +size_t mbstowcs (wchar_t *__restrict, const char *__restrict, size_t); +size_t wcstombs (char *__restrict, const wchar_t *__restrict, size_t); #define EXIT_FAILURE 1 #define EXIT_SUCCESS 0 @@ -108,7 +114,7 @@ int rand_r (unsigned *); #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ || defined(_BSD_SOURCE) -char *realpath (const char *, char *); +char *realpath (const char *__restrict, char *__restrict); long int random (void); void srandom (unsigned int); char *initstate (unsigned int, char *, size_t); -- cgit v1.2.1