summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormike <mike@FreeBSD.org>2002-10-12 16:13:41 +0000
committermike <mike@FreeBSD.org>2002-10-12 16:13:41 +0000
commit4d6bf1c3fb0816347ba09c47c02f040d71c13679 (patch)
tree8937b8185655025519cc44865535915faec9b620
parentca8c4bef3b2e3511a5dcd4e09b5f4e41a1cb8386 (diff)
downloadFreeBSD-src-4d6bf1c3fb0816347ba09c47c02f040d71c13679.zip
FreeBSD-src-4d6bf1c3fb0816347ba09c47c02f040d71c13679.tar.gz
Add restrict type-qualifier.
-rw-r--r--include/signal.h3
-rw-r--r--include/stdio.h28
-rw-r--r--lib/libc/gen/pselect.32
-rw-r--r--lib/libc/gen/pselect.c5
-rw-r--r--lib/libc/stdio/fgetpos.c2
-rw-r--r--lib/libc/stdio/fgets.34
-rw-r--r--lib/libc/stdio/fopen.32
-rw-r--r--lib/libc/stdio/fopen.c4
-rw-r--r--lib/libc/stdio/fputs.c4
-rw-r--r--lib/libc/stdio/fread.34
-rw-r--r--lib/libc/stdio/fread.c4
-rw-r--r--lib/libc/stdio/freopen.c3
-rw-r--r--lib/libc/stdio/fscanf.c2
-rw-r--r--lib/libc/stdio/fseek.32
-rw-r--r--lib/libc/stdio/fwrite.c4
-rw-r--r--lib/libc/stdio/scanf.312
-rw-r--r--lib/libc/stdio/scanf.c2
-rw-r--r--lib/libc/stdio/sscanf.c2
-rw-r--r--lib/libc/stdio/vscanf.c2
-rw-r--r--lib/libc/stdio/vsscanf.c4
20 files changed, 46 insertions, 49 deletions
diff --git a/include/signal.h b/include/signal.h
index d7f4887..efcdf03 100644
--- a/include/signal.h
+++ b/include/signal.h
@@ -72,8 +72,7 @@ int sigismember(const sigset_t *, int);
int sigpending(sigset_t *);
int sigprocmask(int, const sigset_t * __restrict, sigset_t * __restrict);
int sigsuspend(const sigset_t *);
-/* XXX missing restrict qualifier. */
-int sigwait(const sigset_t *, int *);
+int sigwait(const sigset_t * __restrict, int * __restrict);
#endif
#if __BSD_VISIBLE || __POSIX_VISIBLE >= 199506 || __XSI_VISIBLE >= 600
diff --git a/include/stdio.h b/include/stdio.h
index 3c1d639..468a3c3 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -210,10 +210,6 @@ __END_DECLS
__BEGIN_DECLS
/*
* Functions defined in ANSI C standard.
- *
- * XXX fgetpos(), fgets(), fopen(), fputs(), fread(), freopen(), fscanf(),
- * fwrite(), scanf(), sscanf(), vscanf(), and vsscanf() are missing the
- * restrict type-qualifier.
*/
void clearerr(FILE *);
int fclose(FILE *);
@@ -221,19 +217,19 @@ int feof(FILE *);
int ferror(FILE *);
int fflush(FILE *);
int fgetc(FILE *);
-int fgetpos(FILE *, fpos_t *);
-char *fgets(char *, int, FILE *);
-FILE *fopen(const char *, const char *);
+int fgetpos(FILE * __restrict, fpos_t * __restrict);
+char *fgets(char * __restrict, int, FILE * __restrict);
+FILE *fopen(const char * __restrict, const char * __restrict);
int fprintf(FILE * __restrict, const char * __restrict, ...);
int fputc(int, FILE *);
-int fputs(const char *, FILE *);
-size_t fread(void *, size_t, size_t, FILE *);
-FILE *freopen(const char *, const char *, FILE *);
-int fscanf(FILE *, const char *, ...);
+int fputs(const char * __restrict, FILE * __restrict);
+size_t fread(void * __restrict, size_t, size_t, FILE * __restrict);
+FILE *freopen(const char * __restrict, const char * __restrict, FILE * __restrict);
+int fscanf(FILE * __restrict, const char * __restrict, ...);
int fseek(FILE *, long, int);
int fsetpos(FILE *, const fpos_t *);
long ftell(FILE *);
-size_t fwrite(const void *, size_t, size_t, FILE *);
+size_t fwrite(const void * __restrict, size_t, size_t, FILE * __restrict);
int getc(FILE *);
int getchar(void);
char *gets(char *);
@@ -245,11 +241,11 @@ int puts(const char *);
int remove(const char *);
int rename(const char *, const char *);
void rewind(FILE *);
-int scanf(const char *, ...);
+int scanf(const char * __restrict, ...);
void setbuf(FILE * __restrict, char * __restrict);
int setvbuf(FILE * __restrict, char * __restrict, int, size_t);
int sprintf(char * __restrict, const char * __restrict, ...);
-int sscanf(const char *, const char *, ...);
+int sscanf(const char * __restrict, const char * __restrict, ...);
FILE *tmpfile(void);
char *tmpnam(char *);
int ungetc(int, FILE *);
@@ -262,10 +258,10 @@ int vsprintf(char * __restrict, const char * __restrict,
#if __ISO_C_VISIBLE >= 1999
int snprintf(char * __restrict, size_t, const char * __restrict,
...) __printflike(3, 4);
-int vscanf(const char *, __va_list) __scanflike(1, 0);
+int vscanf(const char * __restrict, __va_list) __scanflike(1, 0);
int vsnprintf(char * __restrict, size_t, const char * __restrict,
__va_list) __printflike(3, 0);
-int vsscanf(const char *, const char *, __va_list)
+int vsscanf(const char * __restrict, const char * __restrict, __va_list)
__scanflike(2, 0);
/*
diff --git a/lib/libc/gen/pselect.3 b/lib/libc/gen/pselect.3
index 6abb952..d09524c 100644
--- a/lib/libc/gen/pselect.3
+++ b/lib/libc/gen/pselect.3
@@ -39,7 +39,7 @@
.Sh SYNOPSIS
.In sys/select.h
.Ft int
-.Fn pselect "int nfds" "fd_set *readfds" "fd_set *writefds" "fd_set *exceptfds" "const struct timespec *timeout" "const sigset_t *newsigmask"
+.Fn pselect "int nfds" "fd_set * restrict readfds" "fd_set * restrict writefds" "fd_set * restrict exceptfds" "const struct timespec * restrict timeout" "const sigset_t * restrict newsigmask"
.Sh DESCRIPTION
The
.Fn pselect
diff --git a/lib/libc/gen/pselect.c b/lib/libc/gen/pselect.c
index c2ec108..28066a2 100644
--- a/lib/libc/gen/pselect.c
+++ b/lib/libc/gen/pselect.c
@@ -47,8 +47,9 @@ __weak_reference(__pselect, pselect);
* and allows the user to specify a signal mask to apply during the select.
*/
int
-__pselect(int count, fd_set *rfds, fd_set *wfds, fd_set *efds,
- const struct timespec *timo, const sigset_t *mask)
+__pselect(int count, fd_set * __restrict rfds, fd_set * __restrict wfds,
+ fd_set * __restrict efds, const struct timespec * __restrict timo,
+ const sigset_t * __restrict mask)
{
sigset_t omask;
struct timeval tvtimo, *tvp;
diff --git a/lib/libc/stdio/fgetpos.c b/lib/libc/stdio/fgetpos.c
index f5e3aae..295b20a 100644
--- a/lib/libc/stdio/fgetpos.c
+++ b/lib/libc/stdio/fgetpos.c
@@ -43,7 +43,7 @@ __FBSDID("$FreeBSD$");
#include <stdio.h>
int
-fgetpos(FILE *fp, fpos_t *pos)
+fgetpos(FILE * __restrict fp, fpos_t * __restrict pos)
{
/*
* ftello is thread-safe; no need to lock fp.
diff --git a/lib/libc/stdio/fgets.3 b/lib/libc/stdio/fgets.3
index e536b21..7a63039 100644
--- a/lib/libc/stdio/fgets.3
+++ b/lib/libc/stdio/fgets.3
@@ -48,7 +48,7 @@
.Sh SYNOPSIS
.In stdio.h
.Ft char *
-.Fn fgets "char *str" "int size" "FILE *stream"
+.Fn fgets "char * restrict str" "int size" "FILE * restrict stream"
.Ft char *
.Fn gets "char *str"
.Sh DESCRIPTION
@@ -163,4 +163,4 @@ The functions
and
.Fn gets
conform to
-.St -isoC .
+.St -isoC-99 .
diff --git a/lib/libc/stdio/fopen.3 b/lib/libc/stdio/fopen.3
index f4c1f34..a4614d7 100644
--- a/lib/libc/stdio/fopen.3
+++ b/lib/libc/stdio/fopen.3
@@ -49,7 +49,7 @@
.Sh SYNOPSIS
.In stdio.h
.Ft FILE *
-.Fn fopen "const char *path" "const char *mode"
+.Fn fopen "const char * restrict path" "const char * restrict mode"
.Ft FILE *
.Fn fdopen "int fildes" "const char *mode"
.Ft FILE *
diff --git a/lib/libc/stdio/fopen.c b/lib/libc/stdio/fopen.c
index 7af0636..b7c84a7 100644
--- a/lib/libc/stdio/fopen.c
+++ b/lib/libc/stdio/fopen.c
@@ -52,8 +52,8 @@ __FBSDID("$FreeBSD$");
FILE *
fopen(file, mode)
- const char *file;
- const char *mode;
+ const char * __restrict file;
+ const char * __restrict mode;
{
FILE *fp;
int f;
diff --git a/lib/libc/stdio/fputs.c b/lib/libc/stdio/fputs.c
index e209659..812c37d 100644
--- a/lib/libc/stdio/fputs.c
+++ b/lib/libc/stdio/fputs.c
@@ -53,8 +53,8 @@ __FBSDID("$FreeBSD$");
*/
int
fputs(s, fp)
- const char *s;
- FILE *fp;
+ const char * __restrict s;
+ FILE * __restrict fp;
{
int retval;
struct __suio uio;
diff --git a/lib/libc/stdio/fread.3 b/lib/libc/stdio/fread.3
index 6d4a79c..925ef61 100644
--- a/lib/libc/stdio/fread.3
+++ b/lib/libc/stdio/fread.3
@@ -48,9 +48,9 @@
.Sh SYNOPSIS
.In stdio.h
.Ft size_t
-.Fn fread "void *ptr" "size_t size" "size_t nmemb" "FILE *stream"
+.Fn fread "void * restrict ptr" "size_t size" "size_t nmemb" "FILE * restrict stream"
.Ft size_t
-.Fn fwrite "const void *ptr" "size_t size" "size_t nmemb" "FILE *stream"
+.Fn fwrite "const void * restrict ptr" "size_t size" "size_t nmemb" "FILE * restrict stream"
.Sh DESCRIPTION
The function
.Fn fread
diff --git a/lib/libc/stdio/fread.c b/lib/libc/stdio/fread.c
index 39c1a8c..73c7c19 100644
--- a/lib/libc/stdio/fread.c
+++ b/lib/libc/stdio/fread.c
@@ -49,9 +49,9 @@ __FBSDID("$FreeBSD$");
size_t
fread(buf, size, count, fp)
- void *buf;
+ void * __restrict buf;
size_t size, count;
- FILE *fp;
+ FILE * __restrict fp;
{
size_t resid;
char *p;
diff --git a/lib/libc/stdio/freopen.c b/lib/libc/stdio/freopen.c
index c885673..b445b15 100644
--- a/lib/libc/stdio/freopen.c
+++ b/lib/libc/stdio/freopen.c
@@ -59,7 +59,8 @@ __FBSDID("$FreeBSD$");
*/
FILE *
freopen(file, mode, fp)
- const char *file, *mode;
+ const char * __restrict file;
+ const char * __restrict mode;
FILE *fp;
{
int f;
diff --git a/lib/libc/stdio/fscanf.c b/lib/libc/stdio/fscanf.c
index 1c376a8..ea76af2 100644
--- a/lib/libc/stdio/fscanf.c
+++ b/lib/libc/stdio/fscanf.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
int
-fscanf(FILE *fp, char const *fmt, ...)
+fscanf(FILE * __restrict fp, char const * __restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/lib/libc/stdio/fseek.3 b/lib/libc/stdio/fseek.3
index 6326751..f2ca10f 100644
--- a/lib/libc/stdio/fseek.3
+++ b/lib/libc/stdio/fseek.3
@@ -59,7 +59,7 @@
.Ft void
.Fn rewind "FILE *stream"
.Ft int
-.Fn fgetpos "FILE *stream" "fpos_t *pos"
+.Fn fgetpos "FILE * restrict stream" "fpos_t * restrict pos"
.Ft int
.Fn fsetpos "FILE *stream" "const fpos_t *pos"
.In sys/types.h
diff --git a/lib/libc/stdio/fwrite.c b/lib/libc/stdio/fwrite.c
index 445baec..0a74d81 100644
--- a/lib/libc/stdio/fwrite.c
+++ b/lib/libc/stdio/fwrite.c
@@ -53,9 +53,9 @@ __FBSDID("$FreeBSD$");
*/
size_t
fwrite(buf, size, count, fp)
- const void *buf;
+ const void * __restrict buf;
size_t size, count;
- FILE *fp;
+ FILE * __restrict fp;
{
size_t n;
struct __suio uio;
diff --git a/lib/libc/stdio/scanf.3 b/lib/libc/stdio/scanf.3
index af7cc18..ea99c0e 100644
--- a/lib/libc/stdio/scanf.3
+++ b/lib/libc/stdio/scanf.3
@@ -52,18 +52,18 @@
.Sh SYNOPSIS
.In stdio.h
.Ft int
-.Fn scanf "const char *format" ...
+.Fn scanf "const char * restrict format" ...
.Ft int
-.Fn fscanf "FILE *stream" "const char *format" ...
+.Fn fscanf "FILE * restrict stream" "const char * restrict format" ...
.Ft int
-.Fn sscanf "const char *str" "const char *format" ...
+.Fn sscanf "const char * restrict str" "const char * restrict format" ...
.In stdarg.h
.Ft int
-.Fn vscanf "const char *format" "va_list ap"
+.Fn vscanf "const char * restrict format" "va_list ap"
.Ft int
-.Fn vsscanf "const char *str" "const char *format" "va_list ap"
+.Fn vsscanf "const char * restrict str" "const char * restrict format" "va_list ap"
.Ft int
-.Fn vfscanf "FILE *stream" "const char *format" "va_list ap"
+.Fn vfscanf "FILE * restrict stream" "const char * restrict format" "va_list ap"
.Sh DESCRIPTION
The
.Fn scanf
diff --git a/lib/libc/stdio/scanf.c b/lib/libc/stdio/scanf.c
index 990c9b0..929c20b 100644
--- a/lib/libc/stdio/scanf.c
+++ b/lib/libc/stdio/scanf.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
#include "libc_private.h"
int
-scanf(char const *fmt, ...)
+scanf(char const * __restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/lib/libc/stdio/sscanf.c b/lib/libc/stdio/sscanf.c
index d988326..4db0d29 100644
--- a/lib/libc/stdio/sscanf.c
+++ b/lib/libc/stdio/sscanf.c
@@ -59,7 +59,7 @@ eofread(cookie, buf, len)
}
int
-sscanf(const char *str, char const *fmt, ...)
+sscanf(const char * __restrict str, char const * __restrict fmt, ...)
{
int ret;
va_list ap;
diff --git a/lib/libc/stdio/vscanf.c b/lib/libc/stdio/vscanf.c
index 92f55fc..c3a4266 100644
--- a/lib/libc/stdio/vscanf.c
+++ b/lib/libc/stdio/vscanf.c
@@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$");
int
vscanf(fmt, ap)
- const char *fmt;
+ const char * __restrict fmt;
__va_list ap;
{
int retval;
diff --git a/lib/libc/stdio/vsscanf.c b/lib/libc/stdio/vsscanf.c
index 81a241c..40d4947 100644
--- a/lib/libc/stdio/vsscanf.c
+++ b/lib/libc/stdio/vsscanf.c
@@ -60,8 +60,8 @@ eofread(cookie, buf, len)
int
vsscanf(str, fmt, ap)
- const char *str;
- const char *fmt;
+ const char * __restrict str;
+ const char * __restrict fmt;
__va_list ap;
{
FILE f;
OpenPOWER on IntegriCloud