diff options
author | Rich Felker <dalias@aerifal.cx> | 2012-09-06 22:44:55 -0400 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2012-09-06 22:44:55 -0400 |
commit | 400c5e5c8307a2ebe44ef1f203f5a15669f20347 (patch) | |
tree | 087a48dc8251fa05f6866af8ebf96b69450b15ab /src/stdio | |
parent | bac03cdde1137c16b4c194e137310e2748661dcc (diff) | |
download | musl-400c5e5c8307a2ebe44ef1f203f5a15669f20347.tar.gz musl-400c5e5c8307a2ebe44ef1f203f5a15669f20347.tar.bz2 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/stdio')
42 files changed, 43 insertions, 43 deletions
diff --git a/src/stdio/dprintf.c b/src/stdio/dprintf.c index fa28322f..93082ee7 100644 --- a/src/stdio/dprintf.c +++ b/src/stdio/dprintf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdarg.h> -int dprintf(int fd, const char *fmt, ...) +int dprintf(int fd, const char *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/fgetpos.c b/src/stdio/fgetpos.c index 5b663d1e..c3fa0eb0 100644 --- a/src/stdio/fgetpos.c +++ b/src/stdio/fgetpos.c @@ -1,6 +1,6 @@ #include "stdio_impl.h" -int fgetpos(FILE *f, fpos_t *pos) +int fgetpos(FILE *restrict f, fpos_t *restrict pos) { off_t off = __ftello(f); if (off < 0) return -1; diff --git a/src/stdio/fgets.c b/src/stdio/fgets.c index 3135a69a..ee0ac30e 100644 --- a/src/stdio/fgets.c +++ b/src/stdio/fgets.c @@ -2,7 +2,7 @@ #define MIN(a,b) ((a)<(b) ? (a) : (b)) -char *fgets(char *s, int n, FILE *f) +char *fgets(char *restrict s, int n, FILE *restrict f) { char *p = s; unsigned char *z; diff --git a/src/stdio/fgetws.c b/src/stdio/fgetws.c index 2e76b565..fab9bd0f 100644 --- a/src/stdio/fgetws.c +++ b/src/stdio/fgetws.c @@ -2,7 +2,7 @@ wint_t __fgetwc_unlocked(FILE *); -wchar_t *fgetws(wchar_t *s, int n, FILE *f) +wchar_t *fgetws(wchar_t *restrict s, int n, FILE *restrict f) { wchar_t *p = s; diff --git a/src/stdio/fmemopen.c b/src/stdio/fmemopen.c index 1b054a97..770fd995 100644 --- a/src/stdio/fmemopen.c +++ b/src/stdio/fmemopen.c @@ -67,7 +67,7 @@ static int mclose(FILE *m) return 0; } -FILE *fmemopen(void *buf, size_t size, const char *mode) +FILE *fmemopen(void *restrict buf, size_t size, const char *restrict mode) { FILE *f; struct cookie *c; diff --git a/src/stdio/fopen.c b/src/stdio/fopen.c index 0d5b1af2..560b77e4 100644 --- a/src/stdio/fopen.c +++ b/src/stdio/fopen.c @@ -1,6 +1,6 @@ #include "stdio_impl.h" -FILE *fopen(const char *filename, const char *mode) +FILE *fopen(const char *restrict filename, const char *restrict mode) { FILE *f; int fd; diff --git a/src/stdio/fprintf.c b/src/stdio/fprintf.c index a220cc10..948743f7 100644 --- a/src/stdio/fprintf.c +++ b/src/stdio/fprintf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdarg.h> -int fprintf(FILE *f, const char *fmt, ...) +int fprintf(FILE *restrict f, const char *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/fputs.c b/src/stdio/fputs.c index e6bdb204..b41bc8c7 100644 --- a/src/stdio/fputs.c +++ b/src/stdio/fputs.c @@ -1,6 +1,6 @@ #include "stdio_impl.h" -int fputs(const char *s, FILE *f) +int fputs(const char *restrict s, FILE *restrict f) { size_t l = strlen(s); if (!l) return 0; diff --git a/src/stdio/fputws.c b/src/stdio/fputws.c index b75f95bc..0b593c08 100644 --- a/src/stdio/fputws.c +++ b/src/stdio/fputws.c @@ -1,6 +1,6 @@ #include "stdio_impl.h" -int fputws(const wchar_t *ws, FILE *f) +int fputws(const wchar_t *restrict ws, FILE *restrict f) { unsigned char buf[BUFSIZ]; size_t l=0; diff --git a/src/stdio/fread.c b/src/stdio/fread.c index 5c235777..3f31af8a 100644 --- a/src/stdio/fread.c +++ b/src/stdio/fread.c @@ -2,7 +2,7 @@ #define MIN(a,b) ((a)<(b) ? (a) : (b)) -size_t fread(void *destv, size_t size, size_t nmemb, FILE *f) +size_t fread(void *restrict destv, size_t size, size_t nmemb, FILE *restrict f) { unsigned char *dest = destv; size_t len = size*nmemb, l = len, k; diff --git a/src/stdio/freopen.c b/src/stdio/freopen.c index b1f8fe71..57c3cd29 100644 --- a/src/stdio/freopen.c +++ b/src/stdio/freopen.c @@ -7,7 +7,7 @@ /* Locking is not necessary because, in the event of failure, the stream * passed to freopen is invalid as soon as freopen is called. */ -FILE *freopen(const char *filename, const char *mode, FILE *f) +FILE *freopen(const char *restrict filename, const char *restrict mode, FILE *restrict f) { int fl; FILE *f2; diff --git a/src/stdio/fscanf.c b/src/stdio/fscanf.c index 51fc9b30..ff6c7767 100644 --- a/src/stdio/fscanf.c +++ b/src/stdio/fscanf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdarg.h> -int fscanf(FILE *f, const char *fmt, ...) +int fscanf(FILE *restrict f, const char *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/fwprintf.c b/src/stdio/fwprintf.c index 26d9729a..9ce4f010 100644 --- a/src/stdio/fwprintf.c +++ b/src/stdio/fwprintf.c @@ -2,7 +2,7 @@ #include <stdarg.h> #include <wchar.h> -int fwprintf(FILE *f, const wchar_t *fmt, ...) +int fwprintf(FILE *restrict f, const wchar_t *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/fwrite.c b/src/stdio/fwrite.c index 1b8641ac..8027b306 100644 --- a/src/stdio/fwrite.c +++ b/src/stdio/fwrite.c @@ -1,6 +1,6 @@ #include "stdio_impl.h" -size_t __fwritex(const unsigned char *s, size_t l, FILE *f) +size_t __fwritex(const unsigned char *restrict s, size_t l, FILE *restrict f) { size_t i=0; @@ -24,7 +24,7 @@ size_t __fwritex(const unsigned char *s, size_t l, FILE *f) return l+i; } -size_t fwrite(const void *src, size_t size, size_t nmemb, FILE *f) +size_t fwrite(const void *restrict src, size_t size, size_t nmemb, FILE *restrict f) { size_t k, l = size*nmemb; if (!l) return l; diff --git a/src/stdio/fwscanf.c b/src/stdio/fwscanf.c index a6892cf6..2f30dab4 100644 --- a/src/stdio/fwscanf.c +++ b/src/stdio/fwscanf.c @@ -2,7 +2,7 @@ #include <stdarg.h> #include <wchar.h> -int fwscanf(FILE *f, const wchar_t *fmt, ...) +int fwscanf(FILE *restrict f, const wchar_t *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/getdelim.c b/src/stdio/getdelim.c index b7e04acb..5015c3a6 100644 --- a/src/stdio/getdelim.c +++ b/src/stdio/getdelim.c @@ -2,7 +2,7 @@ #define MIN(a,b) ((a)<(b) ? (a) : (b)) -ssize_t getdelim(char **s, size_t *n, int delim, FILE *f) +ssize_t getdelim(char **restrict s, size_t *restrict n, int delim, FILE *restrict f) { char *tmp; unsigned char *z; diff --git a/src/stdio/getline.c b/src/stdio/getline.c index a3a6651b..476d0b09 100644 --- a/src/stdio/getline.c +++ b/src/stdio/getline.c @@ -1,6 +1,6 @@ #include <stdio.h> -ssize_t getline(char **s, size_t *n, FILE *f) +ssize_t getline(char **restrict s, size_t *restrict n, FILE *restrict f) { return getdelim(s, n, '\n', f); } diff --git a/src/stdio/printf.c b/src/stdio/printf.c index 7b7c329f..cebfe404 100644 --- a/src/stdio/printf.c +++ b/src/stdio/printf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdarg.h> -int printf(const char *fmt, ...) +int printf(const char *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/scanf.c b/src/stdio/scanf.c index a04a4402..3b35bdce 100644 --- a/src/stdio/scanf.c +++ b/src/stdio/scanf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdarg.h> -int scanf(const char *fmt, ...) +int scanf(const char *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/setbuf.c b/src/stdio/setbuf.c index 1b98d503..74ad7834 100644 --- a/src/stdio/setbuf.c +++ b/src/stdio/setbuf.c @@ -1,6 +1,6 @@ #include <stdio.h> -void setbuf(FILE *f, char *buf) +void setbuf(FILE *restrict f, char *restrict buf) { setvbuf(f, buf, buf ? _IOFBF : _IONBF, BUFSIZ); } diff --git a/src/stdio/setvbuf.c b/src/stdio/setvbuf.c index 6dea0ebf..541a125f 100644 --- a/src/stdio/setvbuf.c +++ b/src/stdio/setvbuf.c @@ -9,7 +9,7 @@ * In the case of stderr where the preexisting buffer is length 1, it * is not possible to set line buffering or full buffering. */ -int setvbuf(FILE *f, char *buf, int type, size_t size) +int setvbuf(FILE *restrict f, char *restrict buf, int type, size_t size) { f->lbf = EOF; diff --git a/src/stdio/snprintf.c b/src/stdio/snprintf.c index 4071c2f6..771503b2 100644 --- a/src/stdio/snprintf.c +++ b/src/stdio/snprintf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdarg.h> -int snprintf(char *s, size_t n, const char *fmt, ...) +int snprintf(char *restrict s, size_t n, const char *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/sprintf.c b/src/stdio/sprintf.c index 6b225409..9dff524c 100644 --- a/src/stdio/sprintf.c +++ b/src/stdio/sprintf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdarg.h> -int sprintf(char *s, const char *fmt, ...) +int sprintf(char *restrict s, const char *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/sscanf.c b/src/stdio/sscanf.c index a1cea699..b575edf7 100644 --- a/src/stdio/sscanf.c +++ b/src/stdio/sscanf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdarg.h> -int sscanf(const char *s, const char *fmt, ...) +int sscanf(const char *restrict s, const char *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/swprintf.c b/src/stdio/swprintf.c index 5ece97c4..cbf83d23 100644 --- a/src/stdio/swprintf.c +++ b/src/stdio/swprintf.c @@ -2,7 +2,7 @@ #include <stdarg.h> #include <wchar.h> -int swprintf(wchar_t *s, size_t n, const wchar_t *fmt, ...) +int swprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/swscanf.c b/src/stdio/swscanf.c index b66ad03e..1fe3c3d8 100644 --- a/src/stdio/swscanf.c +++ b/src/stdio/swscanf.c @@ -2,7 +2,7 @@ #include <stdarg.h> #include <wchar.h> -int swscanf(const wchar_t *s, const wchar_t *fmt, ...) +int swscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/vdprintf.c b/src/stdio/vdprintf.c index b41a3c74..c35d9b4f 100644 --- a/src/stdio/vdprintf.c +++ b/src/stdio/vdprintf.c @@ -5,7 +5,7 @@ static size_t wrap_write(FILE *f, const unsigned char *buf, size_t len) return __stdio_write(f, buf, len); } -int vdprintf(int fd, const char *fmt, va_list ap) +int vdprintf(int fd, const char *restrict fmt, va_list ap) { FILE f = { .fd = fd, .lbf = EOF, .write = wrap_write, diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c index d186d58b..6525938f 100644 --- a/src/stdio/vfprintf.c +++ b/src/stdio/vfprintf.c @@ -636,7 +636,7 @@ static int printf_core(FILE *f, const char *fmt, va_list *ap, union arg *nl_arg, return 1; } -int vfprintf(FILE *f, const char *fmt, va_list ap) +int vfprintf(FILE *restrict f, const char *restrict fmt, va_list ap) { va_list ap2; int nl_type[NL_ARGMAX+1] = {0}; diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c index 61b0edb1..54d08495 100644 --- a/src/stdio/vfscanf.c +++ b/src/stdio/vfscanf.c @@ -71,7 +71,7 @@ static int readwc(int c, wchar_t **wcs, mbstate_t *st) return 0; } -int vfscanf(FILE *f, const char *fmt, va_list ap) +int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap) { int width; int size; diff --git a/src/stdio/vfwprintf.c b/src/stdio/vfwprintf.c index 62829806..a42ba195 100644 --- a/src/stdio/vfwprintf.c +++ b/src/stdio/vfwprintf.c @@ -336,7 +336,7 @@ static int wprintf_core(FILE *f, const wchar_t *fmt, va_list *ap, union arg *nl_ return 1; } -int vfwprintf(FILE *f, const wchar_t *fmt, va_list ap) +int vfwprintf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap) { va_list ap2; int nl_type[NL_ARGMAX] = {0}; diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c index de74fe0c..b3bc6f3a 100644 --- a/src/stdio/vfwscanf.c +++ b/src/stdio/vfwscanf.c @@ -86,7 +86,7 @@ static int in_set(const wchar_t *set, int c) ((f)->rend && (c)<128U ? *--(f)->rpos : ungetwc((c),(f))) #endif -int vfwscanf(FILE *f, const wchar_t *fmt, va_list ap) +int vfwscanf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap) { int width; int size; diff --git a/src/stdio/vprintf.c b/src/stdio/vprintf.c index 67b38dac..30d2bffa 100644 --- a/src/stdio/vprintf.c +++ b/src/stdio/vprintf.c @@ -1,6 +1,6 @@ #include <stdio.h> -int vprintf(const char *fmt, va_list ap) +int vprintf(const char *restrict fmt, va_list ap) { return vfprintf(stdout, fmt, ap); } diff --git a/src/stdio/vscanf.c b/src/stdio/vscanf.c index 6f55b1c3..6901958a 100644 --- a/src/stdio/vscanf.c +++ b/src/stdio/vscanf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <stdarg.h> -int vscanf(const char *fmt, va_list ap) +int vscanf(const char *restrict fmt, va_list ap) { return vfscanf(stdin, fmt, ap); } diff --git a/src/stdio/vsnprintf.c b/src/stdio/vsnprintf.c index ba17bd7d..6f19b028 100644 --- a/src/stdio/vsnprintf.c +++ b/src/stdio/vsnprintf.c @@ -10,7 +10,7 @@ static size_t sn_write(FILE *f, const unsigned char *s, size_t l) return l; } -int vsnprintf(char *s, size_t n, const char *fmt, va_list ap) +int vsnprintf(char *restrict s, size_t n, const char *restrict fmt, va_list ap) { int r; char b; diff --git a/src/stdio/vsprintf.c b/src/stdio/vsprintf.c index 7836ccb2..c57349d4 100644 --- a/src/stdio/vsprintf.c +++ b/src/stdio/vsprintf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <limits.h> -int vsprintf(char *s, const char *fmt, va_list ap) +int vsprintf(char *restrict s, const char *restrict fmt, va_list ap) { return vsnprintf(s, INT_MAX, fmt, ap); } diff --git a/src/stdio/vsscanf.c b/src/stdio/vsscanf.c index fbc15e69..049f4dd0 100644 --- a/src/stdio/vsscanf.c +++ b/src/stdio/vsscanf.c @@ -5,7 +5,7 @@ static size_t do_read(FILE *f, unsigned char *buf, size_t len) return __string_read(f, buf, len); } -int vsscanf(const char *s, const char *fmt, va_list ap) +int vsscanf(const char *restrict s, const char *restrict fmt, va_list ap) { FILE f = { .buf = (void *)s, .cookie = (void *)s, diff --git a/src/stdio/vswprintf.c b/src/stdio/vswprintf.c index 8e8f80ce..f3d4fec1 100644 --- a/src/stdio/vswprintf.c +++ b/src/stdio/vswprintf.c @@ -22,7 +22,7 @@ static size_t sw_write(FILE *f, const unsigned char *s, size_t l) return i<0 ? i : l0; } -int vswprintf(wchar_t *s, size_t n, const wchar_t *fmt, va_list ap) +int vswprintf(wchar_t *restrict s, size_t n, const wchar_t *restrict fmt, va_list ap) { int r; FILE f; diff --git a/src/stdio/vswscanf.c b/src/stdio/vswscanf.c index 4c39f806..a205200a 100644 --- a/src/stdio/vswscanf.c +++ b/src/stdio/vswscanf.c @@ -23,7 +23,7 @@ static size_t wstring_read(FILE *f, unsigned char *buf, size_t len) return 1; } -int vswscanf(const wchar_t *s, const wchar_t *fmt, va_list ap) +int vswscanf(const wchar_t *restrict s, const wchar_t *restrict fmt, va_list ap) { unsigned char buf[256]; FILE f = { diff --git a/src/stdio/vwprintf.c b/src/stdio/vwprintf.c index c1923e62..eeeecdc7 100644 --- a/src/stdio/vwprintf.c +++ b/src/stdio/vwprintf.c @@ -1,7 +1,7 @@ #include <stdio.h> #include <wchar.h> -int vwprintf(const wchar_t *fmt, va_list ap) +int vwprintf(const wchar_t *restrict fmt, va_list ap) { return vfwprintf(stdout, fmt, ap); } diff --git a/src/stdio/vwscanf.c b/src/stdio/vwscanf.c index 86da0457..9297cf0d 100644 --- a/src/stdio/vwscanf.c +++ b/src/stdio/vwscanf.c @@ -2,7 +2,7 @@ #include <stdarg.h> #include <wchar.h> -int vwscanf(const wchar_t *fmt, va_list ap) +int vwscanf(const wchar_t *restrict fmt, va_list ap) { return vfwscanf(stdin, fmt, ap); } diff --git a/src/stdio/wprintf.c b/src/stdio/wprintf.c index 20ca61a0..342cd979 100644 --- a/src/stdio/wprintf.c +++ b/src/stdio/wprintf.c @@ -2,7 +2,7 @@ #include <stdarg.h> #include <wchar.h> -int wprintf(const wchar_t *fmt, ...) +int wprintf(const wchar_t *restrict fmt, ...) { int ret; va_list ap; diff --git a/src/stdio/wscanf.c b/src/stdio/wscanf.c index 34b58846..a207cc1b 100644 --- a/src/stdio/wscanf.c +++ b/src/stdio/wscanf.c @@ -2,7 +2,7 @@ #include <stdarg.h> #include <wchar.h> -int wscanf(const wchar_t *fmt, ...) +int wscanf(const wchar_t *restrict fmt, ...) { int ret; va_list ap; |