mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
fix fcntl binding on darwin
This commit is contained in:
@@ -440,7 +440,7 @@ foreign libc {
|
|||||||
@(link_name="closedir") _unix_closedir :: proc(dirp: Dir) -> c.int ---
|
@(link_name="closedir") _unix_closedir :: proc(dirp: Dir) -> c.int ---
|
||||||
@(link_name="rewinddir") _unix_rewinddir :: proc(dirp: Dir) ---
|
@(link_name="rewinddir") _unix_rewinddir :: proc(dirp: Dir) ---
|
||||||
|
|
||||||
@(link_name="__fcntl") _unix__fcntl :: proc(fd: Handle, cmd: c.int, #c_vararg args: ..any) -> c.int ---
|
@(link_name="__fcntl") _unix__fcntl :: proc(fd: Handle, cmd: c.int, arg: uintptr) -> c.int ---
|
||||||
|
|
||||||
@(link_name="rename") _unix_rename :: proc(old: cstring, new: cstring) -> c.int ---
|
@(link_name="rename") _unix_rename :: proc(old: cstring, new: cstring) -> c.int ---
|
||||||
@(link_name="remove") _unix_remove :: proc(path: cstring) -> c.int ---
|
@(link_name="remove") _unix_remove :: proc(path: cstring) -> c.int ---
|
||||||
@@ -794,14 +794,14 @@ _readlink :: proc(path: string) -> (string, Errno) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
absolute_path_from_handle :: proc(fd: Handle) -> (string, Errno) {
|
absolute_path_from_handle :: proc(fd: Handle) -> (string, Errno) {
|
||||||
buf : [256]byte
|
buf: [DARWIN_MAXPATHLEN]byte
|
||||||
res := _unix__fcntl(fd, F_GETPATH, &buf[0])
|
_, err := fcntl(int(fd), F_GETPATH, int(uintptr(&buf[0])))
|
||||||
if res != 0 {
|
if err != ERROR_NONE {
|
||||||
return "", Errno(get_last_error())
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
path := strings.clone_from_cstring(cstring(&buf[0]))
|
path := strings.clone_from_cstring(cstring(&buf[0]))
|
||||||
return path, ERROR_NONE
|
return path, err
|
||||||
}
|
}
|
||||||
|
|
||||||
absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) {
|
absolute_path_from_relative :: proc(rel: string) -> (path: string, err: Errno) {
|
||||||
@@ -1068,7 +1068,7 @@ shutdown :: proc(sd: Socket, how: int) -> (Errno) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Errno) {
|
fcntl :: proc(fd: int, cmd: int, arg: int) -> (int, Errno) {
|
||||||
result := _unix__fcntl(Handle(fd), c.int(cmd), c.int(arg))
|
result := _unix__fcntl(Handle(fd), c.int(cmd), uintptr(arg))
|
||||||
if result < 0 {
|
if result < 0 {
|
||||||
return 0, Errno(get_last_error())
|
return 0, Errno(get_last_error())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user