aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@linux.intel.com>2012-05-12 13:15:21 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2012-05-12 13:15:21 -0700
commit36ee43a0ead72d8224aa1b66b07cac3b04329798 (patch)
treef407c17474c64c52b738a94f637faab300e98d3e
parent737de596bd1fa882e7bfeda5ef007bfaecd34cb1 (diff)
downloadklibc-36ee43a0ead72d8224aa1b66b07cac3b04329798.tar.gz
[klibc] Add rewind() function
Add rewind() function - basically fseek + clearerr. Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r--usr/include/stdio.h1
-rw-r--r--usr/klibc/Kbuild2
-rw-r--r--usr/klibc/stdio/rewind.c7
3 files changed, 9 insertions, 1 deletions
diff --git a/usr/include/stdio.h b/usr/include/stdio.h
index 44f38a798a0eea..d6aec6221094ed 100644
--- a/usr/include/stdio.h
+++ b/usr/include/stdio.h
@@ -49,6 +49,7 @@ __extern FILE *fopen(const char *, const char *);
__extern FILE *fdopen(int, const char *);
__extern int fclose(FILE *);
__extern int fseek(FILE *, off_t, int);
+__extern void rewind(FILE *);
__extern int fputs(const char *, FILE *);
__extern int puts(const char *);
__extern int fputc(int, FILE *);
diff --git a/usr/klibc/Kbuild b/usr/klibc/Kbuild
index 96ff76aefa1873..d7335c22d973df 100644
--- a/usr/klibc/Kbuild
+++ b/usr/klibc/Kbuild
@@ -61,7 +61,7 @@ klib-y := vsnprintf.o snprintf.o vsprintf.o sprintf.o \
stdio/fclose.o stdio/fopen.o stdio/fdopen.o \
stdio/openmode.o stdio/fxopen.o \
stdio/fread.o stdio/fwrite.o stdio/fflush.o \
- stdio/fseek.o stdio/ftell.o stdio/fileno.o \
+ stdio/fseek.o stdio/ftell.o stdio/rewind.o stdio/fileno.o \
stdio/ungetc.o stdio/feof.o stdio/ferror.o
klib-$(CONFIG_KLIBC_ERRLIST) += errlist.o
diff --git a/usr/klibc/stdio/rewind.c b/usr/klibc/stdio/rewind.c
new file mode 100644
index 00000000000000..f5d39fb4f8d9e5
--- /dev/null
+++ b/usr/klibc/stdio/rewind.c
@@ -0,0 +1,7 @@
+#include <stdio.h>
+
+void rewind(FILE *f)
+{
+ if (!fseek(f, 0, SEEK_SET))
+ clearerr(f);
+}