diff options
Diffstat (limited to 'src/user/lib')
-rw-r--r-- | src/user/lib/elfload.c | 1 | ||||
-rw-r--r-- | src/user/lib/file.h | 9 | ||||
-rw-r--r-- | src/user/lib/include/bits/file.h | 10 | ||||
-rw-r--r-- | src/user/lib/include/stdio.h | 6 | ||||
-rw-r--r-- | src/user/lib/stdlib.c | 9 |
5 files changed, 25 insertions, 10 deletions
diff --git a/src/user/lib/elfload.c b/src/user/lib/elfload.c index b73dfe5..a471513 100644 --- a/src/user/lib/elfload.c +++ b/src/user/lib/elfload.c @@ -1,6 +1,7 @@ #include <camellia/execbuf.h> #include <camellia/flags.h> #include <camellia/syscalls.h> +#include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <string.h> diff --git a/src/user/lib/file.h b/src/user/lib/file.h new file mode 100644 index 0000000..9630b6d --- /dev/null +++ b/src/user/lib/file.h @@ -0,0 +1,9 @@ +#pragma once +#include <stdbool.h> + +struct _LIBC_FILE { + int fd; + int pos; + bool eof; + bool error; +}; diff --git a/src/user/lib/include/bits/file.h b/src/user/lib/include/bits/file.h index e50d402..63a31c4 100644 --- a/src/user/lib/include/bits/file.h +++ b/src/user/lib/include/bits/file.h @@ -1,10 +1,2 @@ #pragma once -#include <stdbool.h> -// TODO make opaque -struct FILE { - int fd; - int pos; - bool eof; - bool error; -}; -typedef struct FILE FILE; +typedef struct _LIBC_FILE FILE; diff --git a/src/user/lib/include/stdio.h b/src/user/lib/include/stdio.h index 2f0746f..b8de85d 100644 --- a/src/user/lib/include/stdio.h +++ b/src/user/lib/include/stdio.h @@ -16,6 +16,10 @@ FILE *fopen(const char *path, const char *mode); FILE *freopen(const char *path, const char *mode, FILE *); FILE *fdopen(int fd, const char *mode); FILE *file_clone(const FILE *); +int fclose(FILE *); + size_t fread(void *restrict ptr, size_t size, size_t nitems, FILE *restrict); size_t fwrite(const void *restrict ptr, size_t size, size_t nitems, FILE *restrict); -int fclose(FILE *); + +int feof(FILE *); +int ferror(FILE *); diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c index cd2ec90..0f49ccb 100644 --- a/src/user/lib/stdlib.c +++ b/src/user/lib/stdlib.c @@ -1,3 +1,4 @@ +#include "file.h" #include <camellia/syscalls.h> #include <errno.h> #include <shared/printf.h> @@ -200,6 +201,14 @@ int fclose(FILE *f) { return 0; } +int feof(FILE *f) { + return f->eof; +} + +int ferror(FILE *f) { + return f->error; +} + int fork(void) { return _syscall_fork(0, NULL); |