From 33832e1f8e62d97db5207eec0180413df876fe86 Mon Sep 17 00:00:00 2001 From: RaphGL Date: Wed, 8 Apr 2026 13:06:53 -0100 Subject: [PATCH] added ioctl and stdio FILENO constants to core:sys/freebsd --- core/sys/freebsd/constants.odin | 14 ++++++++++++++ core/sys/freebsd/syscalls.odin | 11 +++++++++++ 2 files changed, 25 insertions(+) diff --git a/core/sys/freebsd/constants.odin b/core/sys/freebsd/constants.odin index 3188b32d6..f6d6de2e6 100644 --- a/core/sys/freebsd/constants.odin +++ b/core/sys/freebsd/constants.odin @@ -3,3 +3,17 @@ package sys_freebsd /* Get window size */ TIOCGWINSZ :: 0x40087468 +/* + Standard input file descriptor +*/ +STDIN_FILENO :: Fd(0) + +/* + Standard output file descriptor +*/ +STDOUT_FILENO :: Fd(1) + +/* + Standard error file descriptor +*/ +STDERR_FILENO :: Fd(3) diff --git a/core/sys/freebsd/syscalls.odin b/core/sys/freebsd/syscalls.odin index 3d62a975e..ad10a9d62 100644 --- a/core/sys/freebsd/syscalls.odin +++ b/core/sys/freebsd/syscalls.odin @@ -23,6 +23,7 @@ SYS_recvfrom : uintptr : 29 SYS_accept : uintptr : 30 SYS_getpeername: uintptr : 31 SYS_getsockname: uintptr : 32 +SYS_ioctl : uintptr : 54 SYS_fcntl : uintptr : 92 SYS_fsync : uintptr : 95 SYS_socket : uintptr : 97 @@ -634,3 +635,13 @@ accept4_nil :: proc "contextless" (s: Fd, flags: Socket_Flags = {}) -> (Fd, Errn } accept4 :: proc { accept4_nil, accept4_T } + +ioctl :: proc "contextless" (fd: Fd, request: c.ulong, arg: uintptr) -> (int, Errno) { + result, ok := intrinsics.syscall_bsd(SYS_ioctl, cast(uintptr)fd, arg) + + if !ok { + return -1, cast(Errno)result + } + + return cast(int)result, nil +}