summaryrefslogtreecommitdiffstats
path: root/libc-top-half/musl/src/stdio/__toread.c
diff options
context:
space:
mode:
Diffstat (limited to 'libc-top-half/musl/src/stdio/__toread.c')
-rw-r--r--libc-top-half/musl/src/stdio/__toread.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/libc-top-half/musl/src/stdio/__toread.c b/libc-top-half/musl/src/stdio/__toread.c
new file mode 100644
index 0000000..f142ff0
--- /dev/null
+++ b/libc-top-half/musl/src/stdio/__toread.c
@@ -0,0 +1,19 @@
+#include <stdio_impl.h>
+
+int __toread(FILE *f)
+{
+ f->mode |= f->mode-1;
+ if (f->wpos != f->wbase) f->write(f, 0, 0);
+ f->wpos = f->wbase = f->wend = 0;
+ if (f->flags & F_NORD) {
+ f->flags |= F_ERR;
+ return EOF;
+ }
+ f->rpos = f->rend = f->buf + f->buf_size;
+ return (f->flags & F_EOF) ? EOF : 0;
+}
+
+hidden void __toread_needs_stdio_exit()
+{
+ __stdio_exit_needed();
+}