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.
This commit is contained in:
Rich Felker 2012-09-06 22:44:55 -04:00
commit 400c5e5c83
192 changed files with 552 additions and 382 deletions

View file

@ -139,7 +139,7 @@ static void put_32(unsigned char *s, unsigned c, int e)
#define mbrtowc_utf8 mbrtowc
#define wctomb_utf8 wctomb
size_t iconv(iconv_t cd0, char **in, size_t *inb, char **out, size_t *outb)
size_t iconv(iconv_t cd0, char **restrict in, size_t *restrict inb, char **restrict out, size_t *restrict outb)
{
size_t x=0;
unsigned long cd = (unsigned long)cd0;

View file

@ -75,7 +75,7 @@ static ssize_t vstrfmon_l(char *s, size_t n, locale_t loc, const char *fmt, va_l
return s-s0;
}
ssize_t strfmon_l(char *s, size_t n, locale_t loc, const char *fmt, ...)
ssize_t strfmon_l(char *restrict s, size_t n, locale_t loc, const char *restrict fmt, ...)
{
va_list ap;
ssize_t ret;
@ -88,7 +88,7 @@ ssize_t strfmon_l(char *s, size_t n, locale_t loc, const char *fmt, ...)
}
ssize_t strfmon(char *s, size_t n, const char *fmt, ...)
ssize_t strfmon(char *restrict s, size_t n, const char *restrict fmt, ...)
{
va_list ap;
ssize_t ret;

View file

@ -1,7 +1,7 @@
#include <locale.h>
#include <time.h>
size_t strftime_l(char *s, size_t n, const char *f, const struct tm *tm, locale_t l)
size_t strftime_l(char *restrict s, size_t n, const char *restrict f, const struct tm *restrict tm, locale_t l)
{
return strftime(s, n, f, tm);
}

View file

@ -1,7 +1,7 @@
#include <string.h>
/* collate only by code points */
size_t strxfrm(char *dest, const char *src, size_t n)
size_t strxfrm(char *restrict dest, const char *restrict src, size_t n)
{
size_t l = strlen(src);
if (n > l) strcpy(dest, src);

View file

@ -1,6 +1,6 @@
#include <string.h>
size_t strxfrm_l(char *dest, const char *src, size_t n, locale_t l)
size_t strxfrm_l(char *restrict dest, const char *restrict src, size_t n, locale_t l)
{
return strxfrm(dest, src, n);
}

View file

@ -1,7 +1,7 @@
#include <wchar.h>
/* collate only by code points */
size_t wcsxfrm(wchar_t *dest, const wchar_t *src, size_t n)
size_t wcsxfrm(wchar_t *restrict dest, const wchar_t *restrict src, size_t n)
{
size_t l = wcslen(src);
if (l >= n) {

View file

@ -1,6 +1,6 @@
#include <wchar.h>
size_t wcsxfrm_l(wchar_t *dest, const wchar_t *src, size_t n, locale_t locale)
size_t wcsxfrm_l(wchar_t *restrict dest, const wchar_t *restrict src, size_t n, locale_t locale)
{
return wcsxfrm(dest, src, n);
}