Merge branch 'odin-lang:master' into master

This commit is contained in:
ftphikari
2023-07-25 15:32:18 +03:00
committed by GitHub
170 changed files with 11751 additions and 5071 deletions
+34
View File
@@ -1567,6 +1567,23 @@ MADV_HWPOISON :: 100
// pipe2 flags
O_CLOEXEC :: 0o2000000
// poll events
POLLIN :: 0x0001
POLLPRI :: 0x0002
POLLOUT :: 0x0004
POLLERR :: 0x0008
POLLHUP :: 0x0010
POLLNVAL :: 0x0020
POLLRDNORM :: 0x0040
POLLRDBAND :: 0x0080
POLLWRNORM :: 0x0100
POLLWRBAND :: 0x0200
POLLMSG :: 0x0400
POLLREMOVE :: 0x1000
POLLRDHUP :: 0x2000
POLLFREE :: 0x4000
POLL_BUSY_LOOP :: 0x8000
// perf event data
Perf_Sample :: struct #raw_union {
period: u64,
@@ -2057,6 +2074,23 @@ sys_fcntl :: proc "contextless" (fd: int, cmd: int, arg: int) -> int {
return int(intrinsics.syscall(SYS_fcntl, uintptr(fd), uintptr(cmd), uintptr(arg)))
}
sys_poll :: proc "contextless" (fds: rawptr, nfds: uint, timeout: int) -> int {
// NOTE: specialcased here because `arm64` does not have `poll`
when ODIN_ARCH == .arm64 {
seconds := i64(timeout / 1_000)
nanoseconds := i64((timeout % 1000) * 1_000_000)
timeout_spec := timespec{seconds, nanoseconds}
return int(intrinsics.syscall(SYS_ppoll, uintptr(fds), uintptr(nfds), uintptr(&timeout_spec), uintptr(0), uintptr(8)))
} else {
return int(intrinsics.syscall(SYS_poll, uintptr(fds), uintptr(nfds), uintptr(timeout)))
}
}
sys_ppoll :: proc "contextless" (fds: rawptr, nfds: uint, timeout: rawptr, sigmask: rawptr, sigsetsize: uint) -> int {
return int(intrinsics.syscall(SYS_ppoll, uintptr(fds), uintptr(nfds), uintptr(timeout), uintptr(sigmask), uintptr(sigsetsize)))
}
get_errno :: proc "contextless" (res: int) -> i32 {
if res < 0 && res > -4096 {
return i32(-res)
+5
View File
@@ -159,6 +159,11 @@ foreign kernel32 {
WaitForSingleObject :: proc(hHandle: HANDLE, dwMilliseconds: DWORD) -> DWORD ---
Sleep :: proc(dwMilliseconds: DWORD) ---
GetProcessId :: proc(handle: HANDLE) -> DWORD ---
CopyFileW :: proc(
lpExistingFileName: LPCWSTR,
lpNewFileName: LPCWSTR,
bFailIfExists: BOOL,
) -> BOOL ---
CopyFileExW :: proc(
lpExistingFileName: LPCWSTR,
lpNewFileName: LPCWSTR,
+10
View File
@@ -206,4 +206,14 @@ foreign ws2_32 {
optval: ^c_char,
optlen: ^c_int,
) -> c_int ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-ntohl)
ntohl :: proc(netlong: c_ulong) -> c_ulong ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-ntohs)
ntohs :: proc(netshort: c_ushort) -> c_ushort ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-htonl)
@(deprecated="Use endian specific integers instead, https://odin-lang.org/docs/overview/#basic-types")
htonl :: proc(hostlong: c_ulong) -> c_ulong ---
// [MS-Docs](https://learn.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-htons)
@(deprecated="Use endian specific integers instead, https://odin-lang.org/docs/overview/#basic-types")
htons :: proc(hostshort: c_ushort) -> c_ushort ---
}