summaryrefslogtreecommitdiff
path: root/src/user/lib/stdlib.c
diff options
context:
space:
mode:
authordzwdz2022-07-11 22:21:57 +0200
committerdzwdz2022-07-11 22:21:57 +0200
commit93af95b3419edfc127c6ea4245753540190c520e (patch)
treeafacc32ba93239f2cde81efd35aacb015647cf99 /src/user/lib/stdlib.c
parent2e79a2e5af3affa7a6a3becdffb1c91d89af90af (diff)
user: add shorthand close() and fork() wrappers for those syscalls
Diffstat (limited to 'src/user/lib/stdlib.c')
-rw-r--r--src/user/lib/stdlib.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/user/lib/stdlib.c b/src/user/lib/stdlib.c
index c055d04..32b4f06 100644
--- a/src/user/lib/stdlib.c
+++ b/src/user/lib/stdlib.c
@@ -62,7 +62,7 @@ libc_file *file_open(const char *path, int flags) {
f = malloc(sizeof *f);
if (!f) {
- _syscall_close(h);
+ close(h);
return NULL;
}
f->pos = 0;
@@ -114,7 +114,16 @@ int file_write(libc_file *f, const char *buf, size_t len) {
}
void file_close(libc_file *f) {
- if (f->fd > 0) _syscall_close(f->fd);
+ if (f->fd > 0) close(f->fd);
if (f != &_stdin_null && f != &_stdout_null)
free(f);
}
+
+
+int fork(void) {
+ return _syscall_fork(0, NULL);
+}
+
+int close(handle_t h) {
+ return _syscall_close(h);
+}