diff options
Diffstat (limited to 'src/user/lib')
-rw-r--r-- | src/user/lib/elfload.c | 3 | ||||
-rw-r--r-- | src/user/lib/elfload.h | 2 | ||||
-rw-r--r-- | src/user/lib/elfreloc.c | 2 | ||||
-rw-r--r-- | src/user/lib/esemaphore.c | 3 | ||||
-rw-r--r-- | src/user/lib/fs/misc.c | 5 | ||||
-rw-r--r-- | src/user/lib/fs/misc.h | 2 | ||||
-rw-r--r-- | src/user/lib/include/bits/file.h | 9 | ||||
-rw-r--r-- | src/user/lib/include/stdio.h (renamed from src/user/lib/stdlib.h) | 18 | ||||
-rw-r--r-- | src/user/lib/include/stdlib.h (renamed from src/user/lib/malloc.h) | 0 | ||||
-rw-r--r-- | src/user/lib/include/string.h | 1 | ||||
-rw-r--r-- | src/user/lib/include/unistd.h | 5 | ||||
-rw-r--r-- | src/user/lib/malloc.c | 5 | ||||
-rw-r--r-- | src/user/lib/stdlib.c | 7 |
13 files changed, 38 insertions, 24 deletions
diff --git a/src/user/lib/elfload.c b/src/user/lib/elfload.c index 45ce2a0..a30fd7c 100644 --- a/src/user/lib/elfload.c +++ b/src/user/lib/elfload.c @@ -1,6 +1,9 @@ #include <camellia/execbuf.h> #include <camellia/flags.h> #include <camellia/syscalls.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> #include <user/lib/elf.h> #include <user/lib/elfload.h> diff --git a/src/user/lib/elfload.h b/src/user/lib/elfload.h index 40c4874..8310b3f 100644 --- a/src/user/lib/elfload.h +++ b/src/user/lib/elfload.h @@ -1,5 +1,5 @@ #pragma once -#include <user/lib/stdlib.h> +#include <bits/file.h> void elf_execf(libc_file *f); void elf_exec(void *elf); diff --git a/src/user/lib/elfreloc.c b/src/user/lib/elfreloc.c index 550fe97..b6e3844 100644 --- a/src/user/lib/elfreloc.c +++ b/src/user/lib/elfreloc.c @@ -1,5 +1,5 @@ +#include <stdio.h> #include <user/lib/elf.h> -#include <user/lib/stdlib.h> __attribute__((visibility("hidden"))) extern struct Elf64_Dyn _DYNAMIC[]; diff --git a/src/user/lib/esemaphore.c b/src/user/lib/esemaphore.c index 1da418e..3a4a836 100644 --- a/src/user/lib/esemaphore.c +++ b/src/user/lib/esemaphore.c @@ -1,7 +1,8 @@ #include <camellia/flags.h> #include <camellia/syscalls.h> +#include <stdlib.h> +#include <unistd.h> #include <user/lib/esemaphore.h> -#include <user/lib/stdlib.h> void esem_signal(struct evil_sem *sem) { _syscall_write(sem->signal, NULL, 0, 0); diff --git a/src/user/lib/fs/misc.c b/src/user/lib/fs/misc.c index 99993ed..3a248ec 100644 --- a/src/user/lib/fs/misc.c +++ b/src/user/lib/fs/misc.c @@ -2,8 +2,11 @@ #include <camellia/syscalls.h> #include <shared/mem.h> #include <stdbool.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> #include <user/lib/fs/misc.h> -#include <user/lib/stdlib.h> bool fork2_n_mount(const char *path) { handle_t h; diff --git a/src/user/lib/fs/misc.h b/src/user/lib/fs/misc.h index 1e41956..0d9eb20 100644 --- a/src/user/lib/fs/misc.h +++ b/src/user/lib/fs/misc.h @@ -1,6 +1,6 @@ #pragma once #include <stdbool.h> -#include <user/lib/stdlib.h> +#include <stdio.h> bool fork2_n_mount(const char *path); diff --git a/src/user/lib/include/bits/file.h b/src/user/lib/include/bits/file.h new file mode 100644 index 0000000..d37b7de --- /dev/null +++ b/src/user/lib/include/bits/file.h @@ -0,0 +1,9 @@ +#pragma once +#include <stdbool.h> +// TODO make opaque +struct libc_file { + int fd; + int pos; + bool eof; +}; +typedef struct libc_file libc_file; diff --git a/src/user/lib/stdlib.h b/src/user/lib/include/stdio.h index 64fbbe6..291a194 100644 --- a/src/user/lib/stdlib.h +++ b/src/user/lib/include/stdio.h @@ -1,28 +1,18 @@ #pragma once -#include <camellia/types.h> -#include <shared/mem.h> -#include <stdbool.h> +#include <bits/file.h> #include <stddef.h> -#include <user/lib/malloc.h> int printf(const char *fmt, ...); int snprintf(char *str, size_t len, const char *fmt, ...); int _klogf(const char *fmt, ...); // for kernel debugging only -typedef struct { - int fd; - int pos; - bool eof; -} libc_file; + +extern libc_file *const stdin, *const stdout; + libc_file *file_open(const char *path, int flags); libc_file *file_reopen(libc_file*, const char *path, int flags); libc_file *file_clone(const libc_file*); int file_read(libc_file*, char *buf, size_t len); int file_write(libc_file*, const char *buf, size_t len); void file_close(libc_file*); - -extern libc_file *stdin, *stdout; - -int fork(void); -int close(handle_t h); diff --git a/src/user/lib/malloc.h b/src/user/lib/include/stdlib.h index 5916ebc..5916ebc 100644 --- a/src/user/lib/malloc.h +++ b/src/user/lib/include/stdlib.h diff --git a/src/user/lib/include/string.h b/src/user/lib/include/string.h new file mode 100644 index 0000000..e5c0255 --- /dev/null +++ b/src/user/lib/include/string.h @@ -0,0 +1 @@ +#include <shared/mem.h> diff --git a/src/user/lib/include/unistd.h b/src/user/lib/include/unistd.h new file mode 100644 index 0000000..4a30298 --- /dev/null +++ b/src/user/lib/include/unistd.h @@ -0,0 +1,5 @@ +#pragma once +#include <camellia/types.h> // TODO only needed because of handle_t + +int fork(void); +int close(handle_t h); diff --git a/src/user/lib/malloc.c b/src/user/lib/malloc.c index bb6b653..ea65d74 100644 --- a/src/user/lib/malloc.c +++ b/src/user/lib/malloc.c @@ -1,9 +1,8 @@ #include <camellia/flags.h> #include <camellia/syscalls.h> #include <stdbool.h> -#include <user/lib/malloc.h> - -#include <user/lib/stdlib.h> +#include <stdio.h> +#include <stdlib.h> #define MBLOCK_MAGIC 0x1337BABE diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c index 943af01..c998de7 100644 --- a/src/user/lib/stdlib.c +++ b/src/user/lib/stdlib.c @@ -1,12 +1,15 @@ #include <camellia/syscalls.h> #include <shared/printf.h> -#include <user/lib/stdlib.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> // TODO oh god this garbage - malloc, actually open, [...] static libc_file _stdin_null = { .fd = 0 }; static libc_file _stdout_null = { .fd = 1 }; -libc_file *stdin = &_stdin_null, *stdout = &_stdout_null; +libc_file *const stdin = &_stdin_null, *const stdout = &_stdout_null; static void backend_file(void *arg, const char *buf, size_t len) { file_write((libc_file*)arg, buf, len); |