mirror of
https://github.com/Ed94/Odin.git
synced 2026-07-28 18:30:06 +00:00
Merge branch 'odin-lang:master' into master
This commit is contained in:
+58
-36
@@ -152,43 +152,65 @@ Errno :: enum i32 {
|
||||
RDONLY flag is not present, because it has the value of 0, i.e. it is the
|
||||
default, unless WRONLY or RDWR is specified.
|
||||
*/
|
||||
Open_Flags_Bits :: enum {
|
||||
WRONLY = 0,
|
||||
RDWR = 1,
|
||||
CREAT = 6,
|
||||
EXCL = 7,
|
||||
NOCTTY = 8,
|
||||
TRUNC = 9,
|
||||
APPEND = 10,
|
||||
NONBLOCK = 11,
|
||||
DSYNC = 12,
|
||||
ASYNC = 13,
|
||||
DIRECT = 14,
|
||||
LARGEFILE = 15,
|
||||
DIRECTORY = 16,
|
||||
NOFOLLOW = 17,
|
||||
NOATIME = 18,
|
||||
CLOEXEC = 19,
|
||||
PATH = 21,
|
||||
when ODIN_ARCH != .arm64 && ODIN_ARCH != .arm32 {
|
||||
Open_Flags_Bits :: enum {
|
||||
WRONLY = 0,
|
||||
RDWR = 1,
|
||||
CREAT = 6,
|
||||
EXCL = 7,
|
||||
NOCTTY = 8,
|
||||
TRUNC = 9,
|
||||
APPEND = 10,
|
||||
NONBLOCK = 11,
|
||||
DSYNC = 12,
|
||||
ASYNC = 13,
|
||||
DIRECT = 14,
|
||||
LARGEFILE = 15,
|
||||
DIRECTORY = 16,
|
||||
NOFOLLOW = 17,
|
||||
NOATIME = 18,
|
||||
CLOEXEC = 19,
|
||||
PATH = 21,
|
||||
}
|
||||
// https://github.com/torvalds/linux/blob/7367539ad4b0f8f9b396baf02110962333719a48/include/uapi/asm-generic/fcntl.h#L19
|
||||
#assert(1 << uint(Open_Flags_Bits.WRONLY) == 0o0000000_1)
|
||||
#assert(1 << uint(Open_Flags_Bits.RDWR) == 0o0000000_2)
|
||||
#assert(1 << uint(Open_Flags_Bits.CREAT) == 0o00000_100)
|
||||
#assert(1 << uint(Open_Flags_Bits.EXCL) == 0o00000_200)
|
||||
#assert(1 << uint(Open_Flags_Bits.NOCTTY) == 0o00000_400)
|
||||
#assert(1 << uint(Open_Flags_Bits.TRUNC) == 0o0000_1000)
|
||||
#assert(1 << uint(Open_Flags_Bits.APPEND) == 0o0000_2000)
|
||||
#assert(1 << uint(Open_Flags_Bits.NONBLOCK) == 0o0000_4000)
|
||||
#assert(1 << uint(Open_Flags_Bits.DSYNC) == 0o000_10000)
|
||||
#assert(1 << uint(Open_Flags_Bits.ASYNC) == 0o000_20000)
|
||||
#assert(1 << uint(Open_Flags_Bits.DIRECT) == 0o000_40000)
|
||||
#assert(1 << uint(Open_Flags_Bits.LARGEFILE) == 0o00_100000)
|
||||
#assert(1 << uint(Open_Flags_Bits.DIRECTORY) == 0o00_200000)
|
||||
#assert(1 << uint(Open_Flags_Bits.NOFOLLOW) == 0o00_400000)
|
||||
#assert(1 << uint(Open_Flags_Bits.NOATIME) == 0o0_1000000)
|
||||
#assert(1 << uint(Open_Flags_Bits.CLOEXEC) == 0o0_2000000)
|
||||
#assert(1 << uint(Open_Flags_Bits.PATH) == 0o_10000000)
|
||||
} else {
|
||||
Open_Flags_Bits :: enum {
|
||||
WRONLY = 0,
|
||||
RDWR = 1,
|
||||
CREAT = 6,
|
||||
EXCL = 7,
|
||||
NOCTTY = 8,
|
||||
TRUNC = 9,
|
||||
APPEND = 10,
|
||||
NONBLOCK = 11,
|
||||
DSYNC = 12,
|
||||
ASYNC = 13,
|
||||
DIRECTORY = 14,
|
||||
NOFOLLOW = 15,
|
||||
DIRECT = 16,
|
||||
LARGEFILE = 17,
|
||||
NOATIME = 18,
|
||||
CLOEXEC = 19,
|
||||
PATH = 21,
|
||||
}
|
||||
}
|
||||
// https://github.com/torvalds/linux/blob/7367539ad4b0f8f9b396baf02110962333719a48/include/uapi/asm-generic/fcntl.h#L19
|
||||
#assert(1 << uint(Open_Flags_Bits.WRONLY) == 0o0000000_1)
|
||||
#assert(1 << uint(Open_Flags_Bits.RDWR) == 0o0000000_2)
|
||||
#assert(1 << uint(Open_Flags_Bits.CREAT) == 0o00000_100)
|
||||
#assert(1 << uint(Open_Flags_Bits.EXCL) == 0o00000_200)
|
||||
#assert(1 << uint(Open_Flags_Bits.NOCTTY) == 0o00000_400)
|
||||
#assert(1 << uint(Open_Flags_Bits.TRUNC) == 0o0000_1000)
|
||||
#assert(1 << uint(Open_Flags_Bits.APPEND) == 0o0000_2000)
|
||||
#assert(1 << uint(Open_Flags_Bits.NONBLOCK) == 0o0000_4000)
|
||||
#assert(1 << uint(Open_Flags_Bits.DSYNC) == 0o000_10000)
|
||||
#assert(1 << uint(Open_Flags_Bits.ASYNC) == 0o000_20000)
|
||||
#assert(1 << uint(Open_Flags_Bits.DIRECT) == 0o000_40000)
|
||||
#assert(1 << uint(Open_Flags_Bits.LARGEFILE) == 0o00_100000)
|
||||
#assert(1 << uint(Open_Flags_Bits.DIRECTORY) == 0o00_200000)
|
||||
#assert(1 << uint(Open_Flags_Bits.NOFOLLOW) == 0o00_400000)
|
||||
#assert(1 << uint(Open_Flags_Bits.NOATIME) == 0o0_1000000)
|
||||
#assert(1 << uint(Open_Flags_Bits.CLOEXEC) == 0o0_2000000)
|
||||
#assert(1 << uint(Open_Flags_Bits.PATH) == 0o_10000000)
|
||||
|
||||
/*
|
||||
Bits for FD_Flags bitset
|
||||
|
||||
@@ -138,8 +138,8 @@ errno_unwrap :: proc {errno_unwrap2, errno_unwrap3}
|
||||
when size_of(int) == 4 {
|
||||
// xxx64 system calls take some parameters as pairs of ulongs rather than a single pointer
|
||||
@(private)
|
||||
compat64_arg_pair :: #force_inline proc "contextless" (a: i64) -> (hi: uint, lo: uint) {
|
||||
no_sign := uint(a)
|
||||
compat64_arg_pair :: #force_inline proc "contextless" (a: i64) -> (lo: uint, hi: uint) {
|
||||
no_sign := u64(a)
|
||||
hi = uint(no_sign >> 32)
|
||||
lo = uint(no_sign & 0xffff_ffff)
|
||||
return
|
||||
|
||||
+25
-15
@@ -151,7 +151,8 @@ lseek :: proc "contextless" (fd: Fd, off: i64, whence: Seek_Whence) -> (i64, Err
|
||||
return errno_unwrap(ret, i64)
|
||||
} else {
|
||||
result: i64 = ---
|
||||
ret := syscall(SYS__llseek, fd, compat64_arg_pair(off), &result, whence)
|
||||
lo, hi := compat64_arg_pair(off)
|
||||
ret := syscall(SYS__llseek, fd, hi, lo, &result, whence)
|
||||
return result, Errno(-ret)
|
||||
}
|
||||
}
|
||||
@@ -251,7 +252,11 @@ ioctl :: proc "contextless" (fd: Fd, request: u32, arg: uintptr) -> (uintptr) {
|
||||
Available since Linux 2.2.
|
||||
*/
|
||||
pread :: proc "contextless" (fd: Fd, buf: []u8, offset: i64) -> (int, Errno) {
|
||||
ret := syscall(SYS_pread64, fd, raw_data(buf), len(buf), compat64_arg_pair(offset))
|
||||
when ODIN_ARCH == .arm32 {
|
||||
ret := syscall(SYS_pread64, fd, raw_data(buf), len(buf), 0, compat64_arg_pair(offset))
|
||||
} else {
|
||||
ret := syscall(SYS_pread64, fd, raw_data(buf), len(buf), compat64_arg_pair(offset))
|
||||
}
|
||||
return errno_unwrap(ret, int)
|
||||
}
|
||||
|
||||
@@ -261,7 +266,11 @@ pread :: proc "contextless" (fd: Fd, buf: []u8, offset: i64) -> (int, Errno) {
|
||||
Available since Linux 2.2.
|
||||
*/
|
||||
pwrite :: proc "contextless" (fd: Fd, buf: []u8, offset: i64) -> (int, Errno) {
|
||||
ret := syscall(SYS_pwrite64, fd, raw_data(buf), len(buf), compat64_arg_pair(offset))
|
||||
when ODIN_ARCH == .arm32 {
|
||||
ret := syscall(SYS_pwrite64, fd, raw_data(buf), len(buf), 0, compat64_arg_pair(offset))
|
||||
} else {
|
||||
ret := syscall(SYS_pwrite64, fd, raw_data(buf), len(buf), compat64_arg_pair(offset))
|
||||
}
|
||||
return errno_unwrap(ret, int)
|
||||
}
|
||||
|
||||
@@ -1127,7 +1136,10 @@ fdatasync :: proc "contextless" (fd: Fd) -> (Errno) {
|
||||
On 32-bit architectures available since Linux 2.4.
|
||||
*/
|
||||
truncate :: proc "contextless" (name: cstring, length: i64) -> (Errno) {
|
||||
when size_of(int) == 4 {
|
||||
when ODIN_ARCH == .arm32 {
|
||||
ret := syscall(SYS_truncate64, cast(rawptr) name, 0, compat64_arg_pair(length))
|
||||
return Errno(-ret)
|
||||
} else when size_of(int) == 4 {
|
||||
ret := syscall(SYS_truncate64, cast(rawptr) name, compat64_arg_pair(length))
|
||||
return Errno(-ret)
|
||||
} else {
|
||||
@@ -1141,7 +1153,10 @@ truncate :: proc "contextless" (name: cstring, length: i64) -> (Errno) {
|
||||
On 32-bit architectures available since 2.4.
|
||||
*/
|
||||
ftruncate :: proc "contextless" (fd: Fd, length: i64) -> (Errno) {
|
||||
when size_of(int) == 4 {
|
||||
when ODIN_ARCH == .arm32 {
|
||||
ret := syscall(SYS_ftruncate64, fd, 0, compat64_arg_pair(length))
|
||||
return Errno(-ret)
|
||||
} else when size_of(int) == 4 {
|
||||
ret := syscall(SYS_ftruncate64, fd, compat64_arg_pair(length))
|
||||
return Errno(-ret)
|
||||
} else {
|
||||
@@ -1952,10 +1967,10 @@ sigaltstack :: proc "contextless" (stack: ^Sig_Stack, old_stack: ^Sig_Stack) ->
|
||||
*/
|
||||
mknod :: proc "contextless" (name: cstring, mode: Mode, dev: Dev) -> (Errno) {
|
||||
when ODIN_ARCH == .arm64 || ODIN_ARCH == .riscv64 {
|
||||
ret := syscall(SYS_mknodat, AT_FDCWD, cast(rawptr) name, transmute(u32) mode, dev)
|
||||
ret := syscall(SYS_mknodat, AT_FDCWD, cast(rawptr) name, transmute(u32) mode, cast(uint) dev)
|
||||
return Errno(-ret)
|
||||
} else {
|
||||
ret := syscall(SYS_mknod, cast(rawptr) name, transmute(u32) mode, dev)
|
||||
ret := syscall(SYS_mknod, cast(rawptr) name, transmute(u32) mode, cast(uint) dev)
|
||||
return Errno(-ret)
|
||||
}
|
||||
}
|
||||
@@ -2586,7 +2601,7 @@ mkdirat :: proc "contextless" (dirfd: Fd, name: cstring, mode: Mode) -> (Errno)
|
||||
Available since Linux 2.6.16.
|
||||
*/
|
||||
mknodat :: proc "contextless" (dirfd: Fd, name: cstring, mode: Mode, dev: Dev) -> (Errno) {
|
||||
ret := syscall(SYS_mknodat, dirfd, cast(rawptr) name, transmute(u32) mode, dev)
|
||||
ret := syscall(SYS_mknodat, dirfd, cast(rawptr) name, transmute(u32) mode, cast(uint) dev)
|
||||
return Errno(-ret)
|
||||
}
|
||||
|
||||
@@ -2684,13 +2699,8 @@ faccessat :: proc "contextless" (dirfd: Fd, name: cstring, mode: Mode = F_OK) ->
|
||||
Available since Linux 2.6.16.
|
||||
*/
|
||||
ppoll :: proc "contextless" (fds: []Poll_Fd, timeout: ^Time_Spec, sigmask: ^Sig_Set) -> (i32, Errno) {
|
||||
when size_of(int) == 8 {
|
||||
ret := syscall(SYS_ppoll, raw_data(fds), len(fds), timeout, sigmask, size_of(Sig_Set))
|
||||
return errno_unwrap(ret, i32)
|
||||
} else {
|
||||
ret := syscall(SYS_ppoll_time64, raw_data(fds), len(fds), timeout, sigmask, size_of(Sig_Set))
|
||||
return errno_unwrap(ret, i32)
|
||||
}
|
||||
ret := syscall(SYS_ppoll, raw_data(fds), len(fds), timeout, sigmask, size_of(Sig_Set))
|
||||
return errno_unwrap(ret, i32)
|
||||
}
|
||||
|
||||
// TODO(flysand): unshare
|
||||
|
||||
+166
-66
@@ -3,7 +3,7 @@ package linux
|
||||
/*
|
||||
Type for storage device handle.
|
||||
*/
|
||||
Dev :: distinct int
|
||||
Dev :: distinct u64
|
||||
|
||||
/*
|
||||
Type for 32-bit User IDs.
|
||||
@@ -153,6 +153,7 @@ when ODIN_ARCH == .amd64 {
|
||||
uid: Uid,
|
||||
gid: Gid,
|
||||
rdev: Dev,
|
||||
_: [4]u8,
|
||||
size: i64,
|
||||
blksize: uint,
|
||||
blocks: u64,
|
||||
@@ -516,79 +517,79 @@ Pid_FD_Flags :: bit_set[Pid_FD_Flags_Bits; i32]
|
||||
Sig_Set :: [_SIGSET_NWORDS]uint
|
||||
|
||||
@private SI_MAX_SIZE :: 128
|
||||
@private SI_ARCH_PREAMBLE :: 4 * size_of(i32)
|
||||
@private SI_ARCH_PREAMBLE :: 4 * size_of(i32) when size_of(rawptr) == 8 else 3 * size_of(i32)
|
||||
@private SI_PAD_SIZE :: SI_MAX_SIZE - SI_ARCH_PREAMBLE
|
||||
|
||||
Sig_Handler_Fn :: #type proc "c" (sig: Signal)
|
||||
Sig_Restore_Fn :: #type proc "c" () -> !
|
||||
|
||||
Sig_Info :: struct #packed {
|
||||
signo: Signal,
|
||||
errno: Errno,
|
||||
code: i32,
|
||||
_pad0: i32,
|
||||
using _union: struct #raw_union {
|
||||
_pad1: [SI_PAD_SIZE]u8,
|
||||
using _kill: struct {
|
||||
pid: Pid, /* sender's pid */
|
||||
uid: Uid, /* sender's uid */
|
||||
},
|
||||
using _timer: struct {
|
||||
timerid: i32, /* timer id */
|
||||
overrun: i32, /* overrun count */
|
||||
value: Sig_Val, /* timer value */
|
||||
},
|
||||
/* POSIX.1b signals */
|
||||
using _rt: struct {
|
||||
_pid0: Pid, /* sender's pid */
|
||||
_uid0: Uid, /* sender's uid */
|
||||
},
|
||||
/* SIGCHLD */
|
||||
using _sigchld: struct {
|
||||
_pid1: Pid, /* which child */
|
||||
_uid1: Uid, /* sender's uid */
|
||||
status: i32, /* exit code */
|
||||
utime: uint,
|
||||
stime: uint, //clock_t
|
||||
},
|
||||
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
|
||||
using _sigfault: struct {
|
||||
addr: rawptr, /* faulting insn/memory ref. */
|
||||
using _: struct #raw_union {
|
||||
trapno: i32, /* Trap number that caused signal */
|
||||
addr_lsb: i16, /* LSB of the reported address */
|
||||
using _addr_bnd: struct {
|
||||
_pad2: u64,
|
||||
lower: rawptr, /* lower bound during fault */
|
||||
upper: rawptr, /* upper bound during fault */
|
||||
},
|
||||
using _addr_pkey: struct {
|
||||
_pad3: u64,
|
||||
pkey: u32, /* protection key on PTE that faulted */
|
||||
},
|
||||
using _perf: struct {
|
||||
perf_data: u64,
|
||||
perf_type: u32,
|
||||
perf_flags: u32,
|
||||
when size_of(rawptr) == 8 {
|
||||
Sig_Info :: struct #packed {
|
||||
signo: Signal,
|
||||
errno: Errno,
|
||||
code: i32,
|
||||
_pad0: i32,
|
||||
using _union: struct #raw_union {
|
||||
_pad1: [SI_PAD_SIZE]u8,
|
||||
using _kill: struct {
|
||||
pid: Pid, /* sender's pid */
|
||||
uid: Uid, /* sender's uid */
|
||||
},
|
||||
using _timer: struct {
|
||||
timerid: i32, /* timer id */
|
||||
overrun: i32, /* overrun count */
|
||||
value: Sig_Val, /* timer value */
|
||||
},
|
||||
/* POSIX.1b signals */
|
||||
using _rt: struct {
|
||||
_pid0: Pid, /* sender's pid */
|
||||
_uid0: Uid, /* sender's uid */
|
||||
},
|
||||
/* SIGCHLD */
|
||||
using _sigchld: struct {
|
||||
_pid1: Pid, /* which child */
|
||||
_uid1: Uid, /* sender's uid */
|
||||
status: i32, /* exit code */
|
||||
utime: uint,
|
||||
stime: uint, //clock_t
|
||||
},
|
||||
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
|
||||
using _sigfault: struct {
|
||||
addr: rawptr, /* faulting insn/memory ref. */
|
||||
using _: struct #raw_union {
|
||||
trapno: i32, /* Trap number that caused signal */
|
||||
addr_lsb: i16, /* LSB of the reported address */
|
||||
using _addr_bnd: struct {
|
||||
_pad2: u64,
|
||||
lower: rawptr, /* lower bound during fault */
|
||||
upper: rawptr, /* upper bound during fault */
|
||||
},
|
||||
using _addr_pkey: struct {
|
||||
_pad3: u64,
|
||||
pkey: u32, /* protection key on PTE that faulted */
|
||||
},
|
||||
using _perf: struct {
|
||||
perf_data: u64,
|
||||
perf_type: u32,
|
||||
perf_flags: u32,
|
||||
},
|
||||
},
|
||||
},
|
||||
/* SIGPOLL */
|
||||
using _sigpoll: struct {
|
||||
band: int, /* POLL_IN, POLL_OUT, POLL_MSG */
|
||||
fd: Fd,
|
||||
},
|
||||
/* SIGSYS */
|
||||
using _sigsys: struct {
|
||||
call_addr: rawptr, /* calling user insn */
|
||||
syscall: i32, /* triggering system call number */
|
||||
arch: u32, /* AUDIT_ARCH_* of syscall */
|
||||
},
|
||||
},
|
||||
/* SIGPOLL */
|
||||
using _sigpoll: struct {
|
||||
band: int, /* POLL_IN, POLL_OUT, POLL_MSG */
|
||||
fd: Fd,
|
||||
},
|
||||
/* SIGSYS */
|
||||
using _sigsys: struct {
|
||||
call_addr: rawptr, /* calling user insn */
|
||||
syscall: i32, /* triggering system call number */
|
||||
arch: u32, /* AUDIT_ARCH_* of syscall */
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#assert(size_of(Sig_Info) == 128)
|
||||
when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
|
||||
#assert(size_of(Sig_Info) == 128)
|
||||
#assert(offset_of(Sig_Info, signo) == 0x00)
|
||||
#assert(offset_of(Sig_Info, errno) == 0x04)
|
||||
#assert(offset_of(Sig_Info, code) == 0x08)
|
||||
@@ -615,7 +616,96 @@ when ODIN_ARCH == .amd64 || ODIN_ARCH == .arm64 {
|
||||
#assert(offset_of(Sig_Info, syscall) == 0x18)
|
||||
#assert(offset_of(Sig_Info, arch) == 0x1C)
|
||||
} else {
|
||||
// TODO
|
||||
Sig_Info :: struct {
|
||||
signo: Signal,
|
||||
errno: Errno,
|
||||
code: i32,
|
||||
using _union: struct #raw_union {
|
||||
_pad1: [SI_PAD_SIZE]u8,
|
||||
using _kill: struct {
|
||||
pid: Pid, /* sender's pid */
|
||||
uid: Uid, /* sender's uid */
|
||||
},
|
||||
using _timer: struct {
|
||||
timerid: i32, /* timer id */
|
||||
overrun: i32, /* overrun count */
|
||||
value: Sig_Val, /* timer value */
|
||||
},
|
||||
/* POSIX.1b signals */
|
||||
using _rt: struct {
|
||||
_pid0: Pid, /* sender's pid */
|
||||
_uid0: Uid, /* sender's uid */
|
||||
},
|
||||
/* SIGCHLD */
|
||||
using _sigchld: struct {
|
||||
_pid1: Pid, /* which child */
|
||||
_uid1: Uid, /* sender's uid */
|
||||
status: i32, /* exit code */
|
||||
utime: uint,
|
||||
stime: uint, //clock_t
|
||||
},
|
||||
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
|
||||
using _sigfault: struct {
|
||||
addr: rawptr, /* faulting insn/memory ref. */
|
||||
using _: struct #raw_union {
|
||||
trapno: i32, /* Trap number that caused signal */
|
||||
addr_lsb: i16, /* LSB of the reported address */
|
||||
using _addr_bnd: struct {
|
||||
_pad2: u32,
|
||||
lower: rawptr, /* lower bound during fault */
|
||||
upper: rawptr, /* upper bound during fault */
|
||||
},
|
||||
using _addr_pkey: struct {
|
||||
_pad3: u32,
|
||||
pkey: u32, /* protection key on PTE that faulted */
|
||||
},
|
||||
using _perf: struct {
|
||||
perf_data: u32,
|
||||
perf_type: u32,
|
||||
perf_flags: u32,
|
||||
},
|
||||
},
|
||||
},
|
||||
/* SIGPOLL */
|
||||
using _sigpoll: struct {
|
||||
band: int, /* POLL_IN, POLL_OUT, POLL_MSG */
|
||||
fd: Fd,
|
||||
},
|
||||
/* SIGSYS */
|
||||
using _sigsys: struct {
|
||||
call_addr: rawptr, /* calling user insn */
|
||||
syscall: i32, /* triggering system call number */
|
||||
arch: u32, /* AUDIT_ARCH_* of syscall */
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
#assert(size_of(Sig_Info) == 128)
|
||||
#assert(offset_of(Sig_Info, signo) == 0x00)
|
||||
#assert(offset_of(Sig_Info, errno) == 0x04)
|
||||
#assert(offset_of(Sig_Info, code) == 0x08)
|
||||
#assert(offset_of(Sig_Info, pid) == 0x0c)
|
||||
#assert(offset_of(Sig_Info, uid) == 0x10)
|
||||
#assert(offset_of(Sig_Info, timerid) == 0x0c)
|
||||
#assert(offset_of(Sig_Info, overrun) == 0x10)
|
||||
#assert(offset_of(Sig_Info, value) == 0x14)
|
||||
#assert(offset_of(Sig_Info, status) == 0x14)
|
||||
#assert(offset_of(Sig_Info, utime) == 0x18)
|
||||
#assert(offset_of(Sig_Info, stime) == 0x1c)
|
||||
#assert(offset_of(Sig_Info, addr) == 0x0c)
|
||||
#assert(offset_of(Sig_Info, addr_lsb) == 0x10)
|
||||
#assert(offset_of(Sig_Info, trapno) == 0x10)
|
||||
#assert(offset_of(Sig_Info, lower) == 0x14)
|
||||
#assert(offset_of(Sig_Info, upper) == 0x18)
|
||||
#assert(offset_of(Sig_Info, pkey) == 0x14)
|
||||
#assert(offset_of(Sig_Info, perf_data) == 0x10)
|
||||
#assert(offset_of(Sig_Info, perf_type) == 0x14)
|
||||
#assert(offset_of(Sig_Info, perf_flags) == 0x18)
|
||||
#assert(offset_of(Sig_Info, band) == 0x0c)
|
||||
#assert(offset_of(Sig_Info, fd) == 0x10)
|
||||
#assert(offset_of(Sig_Info, call_addr) == 0x0c)
|
||||
#assert(offset_of(Sig_Info, syscall) == 0x10)
|
||||
#assert(offset_of(Sig_Info, arch) == 0x14)
|
||||
}
|
||||
|
||||
SIGEV_MAX_SIZE :: 64
|
||||
@@ -684,6 +774,14 @@ Address_Family :: distinct Protocol_Family
|
||||
*/
|
||||
Socket_Msg :: bit_set[Socket_Msg_Bits; i32]
|
||||
|
||||
/*
|
||||
Struct representing a generic socket address.
|
||||
*/
|
||||
Sock_Addr :: struct #packed {
|
||||
sa_family: Address_Family,
|
||||
sa_data: [14]u8,
|
||||
}
|
||||
|
||||
/*
|
||||
Struct representing IPv4 socket address.
|
||||
*/
|
||||
@@ -691,6 +789,7 @@ Sock_Addr_In :: struct #packed {
|
||||
sin_family: Address_Family,
|
||||
sin_port: u16be,
|
||||
sin_addr: [4]u8,
|
||||
sin_zero: [size_of(Sock_Addr) - size_of(Address_Family) - size_of(u16be) - size_of([4]u8)]u8,
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -720,6 +819,7 @@ Sock_Addr_Any :: struct #raw_union {
|
||||
family: Address_Family,
|
||||
port: u16be,
|
||||
},
|
||||
using generic: Sock_Addr,
|
||||
using ipv4: Sock_Addr_In,
|
||||
using ipv6: Sock_Addr_In6,
|
||||
using uds: Sock_Addr_Un,
|
||||
|
||||
@@ -20,6 +20,15 @@ COMMON_LVB_GRID_RVERTICAL :: WORD(0x1000)
|
||||
COMMON_LVB_REVERSE_VIDEO :: WORD(0x4000)
|
||||
COMMON_LVB_UNDERSCORE :: WORD(0x8000)
|
||||
COMMON_LVB_SBCSDBCS :: WORD(0x0300)
|
||||
EV_BREAK :: DWORD(0x0040)
|
||||
EV_CTS :: DWORD(0x0008)
|
||||
EV_DSR :: DWORD(0x0010)
|
||||
EV_ERR :: DWORD(0x0080)
|
||||
EV_RING :: DWORD(0x0100)
|
||||
EV_RLSD :: DWORD(0x0020)
|
||||
EV_RXCHAR :: DWORD(0x0001)
|
||||
EV_RXFLAG :: DWORD(0x0002)
|
||||
EV_TXEMPTY :: DWORD(0x0004)
|
||||
|
||||
@(default_calling_convention="system")
|
||||
foreign kernel32 {
|
||||
@@ -109,7 +118,9 @@ foreign kernel32 {
|
||||
ClearCommError :: proc(hFile: HANDLE, lpErrors: ^Com_Error, lpStat: ^COMSTAT) -> BOOL ---
|
||||
GetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL ---
|
||||
SetCommState :: proc(handle: HANDLE, dcb: ^DCB) -> BOOL ---
|
||||
GetCommPorts :: proc(lpPortNumbers: PULONG, uPortNumbersCount: ULONG, puPortNumbersFound: PULONG) -> ULONG ---
|
||||
SetCommMask :: proc(handle: HANDLE, dwEvtMap: DWORD) -> BOOL ---
|
||||
GetCommMask :: proc(handle: HANDLE, lpEvtMask: LPDWORD) -> BOOL ---
|
||||
WaitCommEvent :: proc(handle: HANDLE, lpEvtMask: LPDWORD, lpOverlapped: LPOVERLAPPED) -> BOOL ---
|
||||
GetCommandLineW :: proc() -> LPCWSTR ---
|
||||
GetTempPathW :: proc(nBufferLength: DWORD, lpBuffer: LPCWSTR) -> DWORD ---
|
||||
GetCurrentProcess :: proc() -> HANDLE ---
|
||||
@@ -239,6 +250,10 @@ foreign kernel32 {
|
||||
hThread: HANDLE,
|
||||
lpContext: LPCONTEXT,
|
||||
) -> BOOL ---
|
||||
SetThreadContext :: proc(
|
||||
hThread: HANDLE,
|
||||
lpContext: LPCONTEXT,
|
||||
) -> BOOL ---
|
||||
CreateProcessW :: proc(
|
||||
lpApplicationName: LPCWSTR,
|
||||
lpCommandLine: LPWSTR,
|
||||
@@ -1068,6 +1083,11 @@ foreign one_core {
|
||||
PageProtection: ULONG,
|
||||
PreferredNode: ULONG,
|
||||
) -> PVOID ---
|
||||
GetCommPorts :: proc(
|
||||
lpPortNumbers: PULONG,
|
||||
uPortNumbersCount: ULONG,
|
||||
puPortNumbersFound: PULONG,
|
||||
) -> ULONG ---
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -143,6 +143,7 @@ LPWSAPROTOCOL_INFO :: ^WSAPROTOCOL_INFO
|
||||
LPSTR :: ^CHAR
|
||||
LPWSTR :: ^WCHAR
|
||||
OLECHAR :: WCHAR
|
||||
BSTR :: ^OLECHAR
|
||||
LPOLESTR :: ^OLECHAR
|
||||
LPCOLESTR :: LPCSTR
|
||||
LPFILETIME :: ^FILETIME
|
||||
@@ -2694,11 +2695,23 @@ EXCEPTION_MAXIMUM_PARAMETERS :: 15
|
||||
|
||||
EXCEPTION_DATATYPE_MISALIGNMENT :: 0x80000002
|
||||
EXCEPTION_BREAKPOINT :: 0x80000003
|
||||
EXCEPTION_SINGLE_STEP :: 0x80000004
|
||||
EXCEPTION_ACCESS_VIOLATION :: 0xC0000005
|
||||
EXCEPTION_IN_PAGE_ERROR :: 0xC0000006
|
||||
EXCEPTION_ILLEGAL_INSTRUCTION :: 0xC000001D
|
||||
EXCEPTION_NONCONTINUABLE_EXCEPTION :: 0xC0000025
|
||||
EXCEPTION_INVALID_DISPOSITION :: 0xC0000026
|
||||
EXCEPTION_ARRAY_BOUNDS_EXCEEDED :: 0xC000008C
|
||||
EXCEPTION_FLT_DENORMAL_OPERAND :: 0xC000008D
|
||||
EXCEPTION_FLT_DIVIDE_BY_ZERO :: 0xC000008E
|
||||
EXCEPTION_FLT_INEXACT_RESULT :: 0xC000008F
|
||||
EXCEPTION_FLT_INVALID_OPERATION :: 0xC0000090
|
||||
EXCEPTION_FLT_OVERFLOW :: 0xC0000091
|
||||
EXCEPTION_FLT_STACK_CHECK :: 0xC0000092
|
||||
EXCEPTION_FLT_UNDERFLOW :: 0xC0000093
|
||||
EXCEPTION_INT_DIVIDE_BY_ZERO :: 0xC0000094
|
||||
EXCEPTION_INT_OVERFLOW :: 0xC0000095
|
||||
EXCEPTION_PRIV_INSTRUCTION :: 0xC0000096
|
||||
EXCEPTION_STACK_OVERFLOW :: 0xC00000FD
|
||||
STATUS_PRIVILEGED_INSTRUCTION :: 0xC0000096
|
||||
|
||||
@@ -3415,8 +3428,6 @@ TIME_ZONE_INFORMATION :: struct {
|
||||
DaylightBias: LONG,
|
||||
}
|
||||
|
||||
|
||||
@(private="file")
|
||||
IMAGE_DOS_HEADER :: struct {
|
||||
e_magic: WORD,
|
||||
e_cblp: WORD,
|
||||
@@ -3534,6 +3545,19 @@ IMAGE_EXPORT_DIRECTORY :: struct {
|
||||
AddressOfNameOrdinals: DWORD, // RVA from base of image
|
||||
}
|
||||
|
||||
IMAGE_DEBUG_DIRECTORY :: struct {
|
||||
Characteristics: DWORD,
|
||||
TimeDateStamp: DWORD,
|
||||
MajorVersion: WORD,
|
||||
MinorVersion: WORD,
|
||||
Type: DWORD,
|
||||
SizeOfData: DWORD,
|
||||
AddressOfRawData: DWORD,
|
||||
PointerToRawData: DWORD,
|
||||
}
|
||||
|
||||
IMAGE_DEBUG_TYPE_CODEVIEW :: 2
|
||||
|
||||
SICHINTF :: DWORD
|
||||
SHCONTF :: DWORD
|
||||
SFGAOF :: ULONG
|
||||
|
||||
@@ -51,6 +51,7 @@ foreign user32 {
|
||||
IsWindowVisible :: proc(hwnd: HWND) -> BOOL ---
|
||||
IsWindowEnabled :: proc(hwnd: HWND) -> BOOL ---
|
||||
IsIconic :: proc(hwnd: HWND) -> BOOL ---
|
||||
IsZoomed :: proc(hwnd: HWND) -> BOOL ---
|
||||
BringWindowToTop :: proc(hWnd: HWND) -> BOOL ---
|
||||
GetTopWindow :: proc(hWnd: HWND) -> HWND ---
|
||||
SetForegroundWindow :: proc(hWnd: HWND) -> BOOL ---
|
||||
|
||||
Reference in New Issue
Block a user