git.cappig.dev / apheleiaOS.git master

1
#include <apheleia/syscall.h>
2
#include <arch/sys.h>
3
#include <errno.h>
4
#include <fcntl.h>
5
#include <stdarg.h>
6
#include <stdint.h>
7
8
int fcntl(int fd, int cmd, ...) {
9
    uintptr_t arg = 0;
10
11
    if (cmd == F_DUPFD || cmd == F_DUPFD_CLOEXEC || cmd == F_SETFD || cmd == F_SETFL) {
12
        va_list ap;
13
        va_start(ap, cmd);
14
        arg = (uintptr_t)va_arg(ap, int);
15
        va_end(ap);
16
    }
17
18
    return (int)__SYSCALL_ERRNO(syscall3(SYS_FCNTL, (uintptr_t)fd, (uintptr_t)cmd, arg));
19
}