diff --git a/core/sys/freebsd/constants.odin b/core/sys/freebsd/constants.odin index 3188b32d6..692cfc0fe 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(2) 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 +}