aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libc')
-rw-r--r--src/lib/libc/debug.c1
-rw-r--r--src/lib/libc/stdio.c7
2 files changed, 6 insertions, 2 deletions
diff --git a/src/lib/libc/debug.c b/src/lib/libc/debug.c
index f862fe6..d88b204 100644
--- a/src/lib/libc/debug.c
+++ b/src/lib/libc/debug.c
@@ -4,6 +4,7 @@
#include <kogata/syscall.h>
#include <kogata/debug.h>
#include <kogata/printf.h>
+#include <kogata/mutex.h>
void sys_panic(const char* msg, const char* file, int line) {
dbg_printf("PANIC in user process\n %s\n at %s:%d\n", msg, file, line);
diff --git a/src/lib/libc/stdio.c b/src/lib/libc/stdio.c
index dcbcf83..864fb34 100644
--- a/src/lib/libc/stdio.c
+++ b/src/lib/libc/stdio.c
@@ -322,15 +322,18 @@ int fflush(FILE* stream) {
dbg_printf("FFLUSH %p\n", stream);
if (!(stream->file_mode & FM_WRITE)) return 0;
- if (stream == NULL || stream->fd == 0) return EOF;
+ if (stream == NULL || stream->fd == 0) {
+ return EOF;
+ }
if (stream->buf_mode != 0 && stream->out_buf_used > 0) {
size_t ret = sc_write(stream->fd, stream->pos, stream->out_buf_used, stream->out_buf);
- stream->out_buf_used = 0;
if (ret != stream->out_buf_used) {
return EOF;
}
+
+ stream->out_buf_used = 0;
if (!(stream->st.type & (FT_CHARDEV | FT_CHANNEL | FT_DIR))) {
stream->pos += ret;
}