diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2024-08-17 00:22:46 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-17 00:22:46 +0100 |
| commit | 536a34287311ee8a6e9c69c0b8d93b1ba5779b4e (patch) | |
| tree | c11b489b30146391e5574ffbaf5ff1bb4359cac7 /core | |
| parent | e8933e43ecffe1a0cec81e102f077970687a43a2 (diff) | |
| parent | f7d7d65bc0f7da6993e117e67e771c7e1741ea06 (diff) | |
Merge pull request #4092 from laytan/fix-open-bindings
fix `open` bindings
Diffstat (limited to 'core')
| -rw-r--r-- | core/os/os_darwin.odin | 14 | ||||
| -rw-r--r-- | core/os/os_freebsd.odin | 2 | ||||
| -rw-r--r-- | core/os/os_haiku.odin | 4 | ||||
| -rw-r--r-- | core/os/os_netbsd.odin | 4 | ||||
| -rw-r--r-- | core/os/os_openbsd.odin | 4 | ||||
| -rw-r--r-- | core/sys/posix/fcntl.odin | 2 |
6 files changed, 9 insertions, 21 deletions
diff --git a/core/os/os_darwin.odin b/core/os/os_darwin.odin index 602257314..1253e9ae6 100644 --- a/core/os/os_darwin.odin +++ b/core/os/os_darwin.odin @@ -584,7 +584,7 @@ F_GETPATH :: 50 // return the full path of the fd foreign libc { @(link_name="__error") __error :: proc() -> ^c.int --- - @(link_name="open") _unix_open :: proc(path: cstring, flags: i32, mode: u16) -> Handle --- + @(link_name="open") _unix_open :: proc(path: cstring, flags: i32, #c_vararg mode: ..u16) -> Handle --- @(link_name="close") _unix_close :: proc(handle: Handle) -> c.int --- @(link_name="read") _unix_read :: proc(handle: Handle, buffer: rawptr, count: c.size_t) -> int --- @(link_name="write") _unix_write :: proc(handle: Handle, buffer: rawptr, count: c.size_t) -> int --- @@ -698,18 +698,6 @@ open :: proc(path: string, flags: int = O_RDWR, mode: int = 0) -> (handle: Handl return } - /* - @INFO(Platin): this is only done because O_CREATE for some reason fails to apply mode - should not happen if the handle is a directory - */ - if flags & O_CREATE != 0 && mode != 0 && !isDir { - err = fchmod(handle, cast(u16)mode) - if err != nil { - _unix_close(handle) - handle = INVALID_HANDLE - } - } - return } diff --git a/core/os/os_freebsd.odin b/core/os/os_freebsd.odin index c2d747a60..41c487b2b 100644 --- a/core/os/os_freebsd.odin +++ b/core/os/os_freebsd.odin @@ -371,7 +371,7 @@ F_KINFO :: 22 foreign libc { @(link_name="__error") __Error_location :: proc() -> ^c.int --- - @(link_name="open") _unix_open :: proc(path: cstring, flags: c.int, mode: c.uint16_t) -> Handle --- + @(link_name="open") _unix_open :: proc(path: cstring, flags: c.int, #c_vararg mode: ..u16) -> Handle --- @(link_name="close") _unix_close :: proc(fd: Handle) -> c.int --- @(link_name="read") _unix_read :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t --- @(link_name="write") _unix_write :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t --- diff --git a/core/os/os_haiku.odin b/core/os/os_haiku.odin index 7f1ec7089..2d87c07a6 100644 --- a/core/os/os_haiku.odin +++ b/core/os/os_haiku.odin @@ -124,7 +124,7 @@ foreign libc { @(link_name="fork") _unix_fork :: proc() -> pid_t --- @(link_name="getthrid") _unix_getthrid :: proc() -> int --- - @(link_name="open") _unix_open :: proc(path: cstring, flags: c.int, mode: c.int) -> Handle --- + @(link_name="open") _unix_open :: proc(path: cstring, flags: c.int, #c_vararg mode: ..u16) -> Handle --- @(link_name="close") _unix_close :: proc(fd: Handle) -> c.int --- @(link_name="read") _unix_read :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t --- @(link_name="write") _unix_write :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t --- @@ -200,7 +200,7 @@ fork :: proc() -> (Pid, Error) { open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Error) { runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) - handle := _unix_open(cstr, c.int(flags), c.int(mode)) + handle := _unix_open(cstr, c.int(flags), u16(mode)) if handle == -1 { return INVALID_HANDLE, get_last_error() } diff --git a/core/os/os_netbsd.odin b/core/os/os_netbsd.odin index 931b38f12..82a8dc1eb 100644 --- a/core/os/os_netbsd.odin +++ b/core/os/os_netbsd.odin @@ -423,7 +423,7 @@ R_OK :: 4 // Test for read permission foreign libc { @(link_name="__errno") __errno_location :: proc() -> ^c.int --- - @(link_name="open") _unix_open :: proc(path: cstring, flags: c.int, mode: c.int) -> Handle --- + @(link_name="open") _unix_open :: proc(path: cstring, flags: c.int, #c_vararg mode: ..u32) -> Handle --- @(link_name="close") _unix_close :: proc(fd: Handle) -> c.int --- @(link_name="read") _unix_read :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t --- @(link_name="write") _unix_write :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t --- @@ -488,7 +488,7 @@ get_last_error :: proc "contextless" () -> Error { open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Error) { runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) - handle := _unix_open(cstr, c.int(flags), c.int(mode)) + handle := _unix_open(cstr, c.int(flags), c.uint(mode)) if handle == -1 { return INVALID_HANDLE, get_last_error() } diff --git a/core/os/os_openbsd.odin b/core/os/os_openbsd.odin index caae19e6e..44eac8564 100644 --- a/core/os/os_openbsd.odin +++ b/core/os/os_openbsd.odin @@ -348,7 +348,7 @@ foreign libc { @(link_name="fork") _unix_fork :: proc() -> pid_t --- @(link_name="getthrid") _unix_getthrid :: proc() -> int --- - @(link_name="open") _unix_open :: proc(path: cstring, flags: c.int, mode: c.int) -> Handle --- + @(link_name="open") _unix_open :: proc(path: cstring, flags: c.int, #c_vararg mode: ..u32) -> Handle --- @(link_name="close") _unix_close :: proc(fd: Handle) -> c.int --- @(link_name="read") _unix_read :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t --- @(link_name="write") _unix_write :: proc(fd: Handle, buf: rawptr, size: c.size_t) -> c.ssize_t --- @@ -412,7 +412,7 @@ fork :: proc() -> (Pid, Error) { open :: proc(path: string, flags: int = O_RDONLY, mode: int = 0) -> (Handle, Error) { runtime.DEFAULT_TEMP_ALLOCATOR_TEMP_GUARD() cstr := strings.clone_to_cstring(path, context.temp_allocator) - handle := _unix_open(cstr, c.int(flags), c.int(mode)) + handle := _unix_open(cstr, c.int(flags), c.uint(mode)) if handle == -1 { return INVALID_HANDLE, get_last_error() } diff --git a/core/sys/posix/fcntl.odin b/core/sys/posix/fcntl.odin index 8f1b1a511..ca030a9a5 100644 --- a/core/sys/posix/fcntl.odin +++ b/core/sys/posix/fcntl.odin @@ -58,7 +58,7 @@ foreign lib { [[ More; https://pubs.opengroup.org/onlinepubs/9699919799/functions/open.html ]] */ - open :: proc(path: cstring, flags: O_Flags, mode: mode_t = {}) -> FD --- + open :: proc(path: cstring, flags: O_Flags, #c_vararg mode: ..mode_t) -> FD --- /* Equivalent to the open() function except in the case where path specifies a relative path. |