mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 15:48:51 +00:00
Add missing flush functionality to os platforms
Platforms: - FreeBSD - Haiku - Linux - NetBSD - OpenBSD
This commit is contained in:
@@ -447,8 +447,7 @@ close :: proc(fd: Handle) -> Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flush :: proc(fd: Handle) -> Error {
|
flush :: proc(fd: Handle) -> Error {
|
||||||
// do nothing
|
return cast(_Platform_Error)freebsd.fsync(cast(freebsd.Fd)fd)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you read or write more than `INT_MAX` bytes, FreeBSD returns `EINVAL`.
|
// If you read or write more than `INT_MAX` bytes, FreeBSD returns `EINVAL`.
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ foreign libc {
|
|||||||
@(link_name="unlink") _unix_unlink :: proc(path: cstring) -> c.int ---
|
@(link_name="unlink") _unix_unlink :: proc(path: cstring) -> c.int ---
|
||||||
@(link_name="rmdir") _unix_rmdir :: proc(path: cstring) -> c.int ---
|
@(link_name="rmdir") _unix_rmdir :: proc(path: cstring) -> c.int ---
|
||||||
@(link_name="mkdir") _unix_mkdir :: proc(path: cstring, mode: mode_t) -> c.int ---
|
@(link_name="mkdir") _unix_mkdir :: proc(path: cstring, mode: mode_t) -> c.int ---
|
||||||
|
@(link_name="fsync") _unix_fsync :: proc(fd: Handle) -> c.int ---
|
||||||
|
|
||||||
@(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int ---
|
@(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int ---
|
||||||
@(link_name="sysconf") _sysconf :: proc(name: c.int) -> c.long ---
|
@(link_name="sysconf") _sysconf :: proc(name: c.int) -> c.long ---
|
||||||
@@ -218,7 +219,10 @@ close :: proc(fd: Handle) -> Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flush :: proc(fd: Handle) -> Error {
|
flush :: proc(fd: Handle) -> Error {
|
||||||
// do nothing
|
result := _unix_fsync(fd)
|
||||||
|
if result == -1 {
|
||||||
|
return get_last_error()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -584,8 +584,7 @@ close :: proc(fd: Handle) -> Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flush :: proc(fd: Handle) -> Error {
|
flush :: proc(fd: Handle) -> Error {
|
||||||
// do nothing
|
return _get_errno(unix.sys_fsync(int(fd)))
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If you read or write more than `SSIZE_MAX` bytes, result is implementation defined (probably an error).
|
// If you read or write more than `SSIZE_MAX` bytes, result is implementation defined (probably an error).
|
||||||
|
|||||||
@@ -443,6 +443,7 @@ foreign libc {
|
|||||||
@(link_name="rmdir") _unix_rmdir :: proc(path: cstring) -> c.int ---
|
@(link_name="rmdir") _unix_rmdir :: proc(path: cstring) -> c.int ---
|
||||||
@(link_name="mkdir") _unix_mkdir :: proc(path: cstring, mode: mode_t) -> c.int ---
|
@(link_name="mkdir") _unix_mkdir :: proc(path: cstring, mode: mode_t) -> c.int ---
|
||||||
@(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, #c_vararg args: ..any) -> c.int ---
|
||||||
|
@(link_name="fsync") _unix_fsync :: proc(fd: Handle) -> c.int ---
|
||||||
@(link_name="dup") _unix_dup :: proc(fd: Handle) -> Handle ---
|
@(link_name="dup") _unix_dup :: proc(fd: Handle) -> Handle ---
|
||||||
|
|
||||||
@(link_name="fdopendir") _unix_fdopendir :: proc(fd: Handle) -> Dir ---
|
@(link_name="fdopendir") _unix_fdopendir :: proc(fd: Handle) -> Dir ---
|
||||||
@@ -506,7 +507,10 @@ close :: proc(fd: Handle) -> Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flush :: proc(fd: Handle) -> Error {
|
flush :: proc(fd: Handle) -> Error {
|
||||||
// do nothing
|
result := _unix_fsync(fd)
|
||||||
|
if result == -1 {
|
||||||
|
return get_last_error()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -366,6 +366,7 @@ foreign libc {
|
|||||||
@(link_name="unlink") _unix_unlink :: proc(path: cstring) -> c.int ---
|
@(link_name="unlink") _unix_unlink :: proc(path: cstring) -> c.int ---
|
||||||
@(link_name="rmdir") _unix_rmdir :: proc(path: cstring) -> c.int ---
|
@(link_name="rmdir") _unix_rmdir :: proc(path: cstring) -> c.int ---
|
||||||
@(link_name="mkdir") _unix_mkdir :: proc(path: cstring, mode: mode_t) -> c.int ---
|
@(link_name="mkdir") _unix_mkdir :: proc(path: cstring, mode: mode_t) -> c.int ---
|
||||||
|
@(link_name="fsync") _unix_fsync :: proc(fd: Handle) -> c.int ---
|
||||||
@(link_name="dup") _unix_dup :: proc(fd: Handle) -> Handle ---
|
@(link_name="dup") _unix_dup :: proc(fd: Handle) -> Handle ---
|
||||||
|
|
||||||
@(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int ---
|
@(link_name="getpagesize") _unix_getpagesize :: proc() -> c.int ---
|
||||||
@@ -430,7 +431,10 @@ close :: proc(fd: Handle) -> Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
flush :: proc(fd: Handle) -> Error {
|
flush :: proc(fd: Handle) -> Error {
|
||||||
// do nothing
|
result := _unix_fsync(fd)
|
||||||
|
if result == -1 {
|
||||||
|
return get_last_error()
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ SYS_getpid : uintptr : 20
|
|||||||
SYS_recvfrom : uintptr : 29
|
SYS_recvfrom : uintptr : 29
|
||||||
SYS_accept : uintptr : 30
|
SYS_accept : uintptr : 30
|
||||||
SYS_fcntl : uintptr : 92
|
SYS_fcntl : uintptr : 92
|
||||||
|
SYS_fsync : uintptr : 95
|
||||||
SYS_socket : uintptr : 97
|
SYS_socket : uintptr : 97
|
||||||
SYS_connect : uintptr : 98
|
SYS_connect : uintptr : 98
|
||||||
SYS_bind : uintptr : 104
|
SYS_bind : uintptr : 104
|
||||||
@@ -200,6 +201,16 @@ accept_nil :: proc "contextless" (s: Fd) -> (Fd, Errno) {
|
|||||||
|
|
||||||
accept :: proc { accept_T, accept_nil }
|
accept :: proc { accept_T, accept_nil }
|
||||||
|
|
||||||
|
// Synchronize changes to a file.
|
||||||
|
//
|
||||||
|
// The fsync() system call appeared in 4.2BSD.
|
||||||
|
fsync :: proc "contextless" (fd: Fd) -> Errno {
|
||||||
|
result, _ := intrinsics.syscall_bsd(SYS_fsync,
|
||||||
|
cast(uintptr)fd)
|
||||||
|
|
||||||
|
return cast(Errno)result
|
||||||
|
}
|
||||||
|
|
||||||
// File control.
|
// File control.
|
||||||
//
|
//
|
||||||
// The fcntl() system call appeared in 4.2BSD.
|
// The fcntl() system call appeared in 4.2BSD.
|
||||||
|
|||||||
Reference in New Issue
Block a user