[sys/linux]: Fix compilation errors and -strict-style errors

This commit is contained in:
flysand7
2023-11-04 13:57:28 +11:00
parent 574d2baf09
commit f26ed39e86
3 changed files with 66 additions and 56 deletions
+3 -3
View File
@@ -1629,7 +1629,7 @@ PTrace_Request :: enum {
SECCOMP_GET_METADATA = 0x420d,
GET_SYSCALL_INFO = 0x420e,
GET_RSEQ_CONFIGURATION = 0x420f,
};
}
/*
ptrace options
@@ -1669,7 +1669,7 @@ PTrace_Get_Syscall_Info_Op :: enum u8 {
ENTRY = 1,
EXIT = 2,
SECCOMP = 3,
};
}
/*
ptrace's PEEKSIGINFO flags bits
@@ -1708,7 +1708,7 @@ Splice_Flags_Bits :: enum {
/*
Clock IDs for various system clocks.
*/
Clock_ID :: enum {
Clock_Id :: enum {
REALTIME = 0,
MONOTONIC = 1,
PROCESS_CPUTIME_ID = 2,
+25 -30
View File
@@ -346,7 +346,7 @@ shmget :: proc "contextless" (key: Key, size: uint, flags: IPC_Flags) -> (Key, E
*/
shmat :: proc "contextless" (key: Key, addr: rawptr, flags: IPC_Flags) -> (rawptr, Errno) {
ret := syscall(SYS_shmat, key, addr, transmute(i16) flags)
return errno_unwrap(ret, Key)
return errno_unwrap(ret, rawptr, uintptr)
}
shmctl_ds :: proc "contextless" (key: Key, cmd: IPC_Cmd, buf: ^Shmid_DS) -> (Errno) {
@@ -354,21 +354,16 @@ shmctl_ds :: proc "contextless" (key: Key, cmd: IPC_Cmd, buf: ^Shmid_DS) -> (Err
return Errno(-ret)
}
shmctl_info :: proc "contextless" (key: Key, cmd: IPC_Cmd, buf: ^Shmid_Info) -> (int, Errno) {
shmctl_info :: proc "contextless" (key: Key, cmd: IPC_Cmd, buf: ^Shm_Info) -> (int, Errno) {
ret := syscall(SYS_shmctl, key, cmd, buf)
return errno_unwrap(ret, int)
}
shmctl_stat :: proc "contextless" (index: int, cmd: IPC_Cmd, buf: ^Shmid_DS) -> (Key, Errno) {
ret := syscall(SYS_shmctl, key, cmd, buf)
return errno_unwrap(ret, Key)
}
/*
SystemV shared memory control.
Available since Linux 2.0.
*/
shmctl :: proc {shmctl_ds, shmctl_info, shmctl_stat}
shmctl :: proc {shmctl_ds, shmctl_info}
/*
Allocate a new file descriptor that refers to the same file as the one provided.
@@ -432,7 +427,7 @@ alarm :: proc "contextless" (seconds: u32) -> u32 {
Set the value of an internal timer.
Available since Linux 1.0.
*/
getitimer :: proc "contextless" (which: ITimer_Which, new: ^ITimer_Val, old: ^ITimer_Val) -> (Errno) {
setitimer :: proc "contextless" (which: ITimer_Which, new: ^ITimer_Val, old: ^ITimer_Val) -> (Errno) {
ret := syscall(SYS_getitimer, new, old)
return Errno(-ret)
}
@@ -451,13 +446,13 @@ getpid :: proc "contextless" () -> Pid {
Available since Linux 2.2.
On 32-bit platforms available since Linux 2.6.
*/
sendfile :: proc "contextless" (out: Fd, in: Fd, offset: ^i64, count: uint) -> (int, Errno) {
sendfile :: proc "contextless" (out_fd: Fd, in_fd: Fd, offset: ^i64, count: uint) -> (int, Errno) {
when size_of(int) == 8 {
ret := syscall(SYS_sendfile, out, in, offset, count)
return errno_unwrap(ret, Errno)
ret := syscall(SYS_sendfile, out_fd, in_fd, offset, count)
return errno_unwrap(ret, int)
} else {
ret := syscall(SYS_sendfile64, out, in, offset, count)
return errno_unwrap(ret, Errno)
ret := syscall(SYS_sendfile64, out_fd, in_fd, offset, count)
return errno_unwrap(ret, int)
}
}
@@ -829,7 +824,7 @@ semctl3 :: proc "contextless" (key: Key, semnum: i32, cmd: IPC_Cmd) -> (int, Err
return errno_unwrap(ret, int)
}
semctl4 :: proc "contextless" (key: Key, semnum: i32, cmd: IPC_Cmd, semun: Sem_Un) -> (int, Errno) {
semctl4 :: proc "contextless" (key: Key, semnum: i32, cmd: IPC_Cmd, semun: ^Sem_Un) -> (int, Errno) {
ret := syscall(SYS_semctl, key, semnum, cmd, semun)
return errno_unwrap(ret, int)
}
@@ -1341,9 +1336,9 @@ lchown :: proc "contextless" (name: cstring, uid: Uid, gid: Gid) -> (Errno) {
Set file mode creation mask.
Available since Linux 1.0.
*/
umask :: proc "contextless" (mask: Mask) -> Mask {
umask :: proc "contextless" (mask: Mode) -> Mode {
ret := syscall(SYS_umask, transmute(u32) mask)
return transmute(u32) cast(u32) ret
return transmute(Mode) cast(u32) ret
}
/*
@@ -1397,12 +1392,12 @@ ptrace_traceme :: proc "contextless" (rq: PTrace_Traceme_Type) -> (Errno) {
}
ptrace_peek :: proc "contextless" (rq: PTrace_Peek_Type, pid: Pid, addr: uintptr) -> (uint, Errno) {
ret := syscall(SYS_ptrace, rq, pid: Pid, addr, pid)
return errno_unwrap(rq, uint)
ret := syscall(SYS_ptrace, rq, pid, addr)
return errno_unwrap(ret, uint)
}
ptrace_poke :: proc "contextless" (rq: PTrace_Poke_Type, pid: Pid, addr: uintptr, data: uint) -> (Errno) {
ret := syscall(SYS_ptrace, rq, pid: Pid, addr, data)
ret := syscall(SYS_ptrace, rq, pid, addr, data)
return Errno(-ret)
}
@@ -1436,12 +1431,12 @@ ptrace_setfpxregs :: proc "contextless" (rq: PTrace_Setfpxregs_Type, pid: Pid, b
return Errno(-ret)
}
ptrace_getregset :: proc "contextless" (rq: PTrace_Getgetset_Type, pid: Pid, note: PTrace_Note_Type, buf: ^IO_Vec) -> (Errno) {
ptrace_getregset :: proc "contextless" (rq: PTrace_Getregset_Type, pid: Pid, note: PTrace_Note_Type, buf: ^IO_Vec) -> (Errno) {
ret := syscall(SYS_ptrace, rq, pid, note, buf)
return Errno(-ret)
}
ptrace_setregset :: proc "contextless" (rq: PTrace_Setgetset_Type, pid: Pid, note: PTrace_Note_Type, buf: ^IO_Vec) -> (Errno) {
ptrace_setregset :: proc "contextless" (rq: PTrace_Setregset_Type, pid: Pid, note: PTrace_Note_Type, buf: ^IO_Vec) -> (Errno) {
ret := syscall(SYS_ptrace, rq, pid, note, buf)
return Errno(-ret)
}
@@ -1456,13 +1451,13 @@ ptrace_peeksiginfo :: proc "contextless" (rq: PTrace_Peeksiginfo_Type, pid: Pid,
return Errno(-ret)
}
ptrace_getsigmask :: proc "contextless" (rq: PTrace_Getsigmask, pid: Pid, sigmask: ^Sig_Mask) -> (Errno) {
ret := syscall(SYS_ptrace, rq, pid, size_of(Sig_Mask), sigmask)
ptrace_getsigmask :: proc "contextless" (rq: PTrace_Getsigmask_Type, pid: Pid, sigmask: ^Sig_Set) -> (Errno) {
ret := syscall(SYS_ptrace, rq, pid, size_of(Sig_Set), sigmask)
return Errno(-ret)
}
ptrace_setsigmask :: proc "contextless" (rq: PTrace_Setsigmask, pid: Pid, sigmask: ^Sig_Mask) -> (Errno) {
ret := syscall(SYS_ptrace, rq, pid, size_of(Sig_Mask), sigmask)
ptrace_setsigmask :: proc "contextless" (rq: PTrace_Setsigmask_Type, pid: Pid, sigmask: ^Sig_Set) -> (Errno) {
ret := syscall(SYS_ptrace, rq, pid, size_of(Sig_Set), sigmask)
return Errno(-ret)
}
@@ -1740,10 +1735,10 @@ setregid :: proc "contextless" (real: Gid, effective: Gid) -> (Errno) {
*/
getgroups :: proc "contextless" (gids: []Gid) -> (int, Errno) {
when size_of(int) == 8 {
ret := syscall(SYS_getgroups, len(gids), rawptr(gids))
ret := syscall(SYS_getgroups, len(gids), raw_data(gids))
return errno_unwrap(ret, int)
} else {
ret := syscall(SYS_getgroups32, len(gids), rawptr(gids))
ret := syscall(SYS_getgroups32, len(gids), raw_data(gids))
return errno_unwrap(ret, int)
}
}
@@ -1755,10 +1750,10 @@ getgroups :: proc "contextless" (gids: []Gid) -> (int, Errno) {
*/
setgroups :: proc "contextless" (gids: []Gid) -> (Errno) {
when size_of(int) == 8 {
ret := syscall(SYS_setgroup, len(gids), rawptr(gids))
ret := syscall(SYS_setgroups, len(gids), raw_data(gids))
return Errno(-ret)
} else {
ret := syscall(SYS_setgroup32, len(gids), rawptr(gids))
ret := syscall(SYS_setgroups32, len(gids), raw_data(gids))
return Errno(-ret)
}
}
+38 -23
View File
@@ -564,7 +564,7 @@ Sig_Event :: struct {
value: Sig_Val,
signo: i32,
notify: i32,
using: struct #raw_union {
using _: struct #raw_union {
_: [SIGEV_PAD_SIZE]u32,
thread_id: Pid,
using _: struct {
@@ -651,7 +651,7 @@ Msg_Hdr :: struct {
iov: []IO_Vec, // ptr followed by length, abi matches
control: []u8,
flags: Socket_Msg,
};
}
/*
Multiple message header for sendmmsg/recvmmsg
@@ -754,7 +754,7 @@ IO_Vec :: struct {
/*
Access mode for shared memory
*/
IPC_Mode :: bit_set[IPC_Mode; u32]
IPC_Mode :: bit_set[IPC_Mode_Bits; u32]
/*
Flags used by IPC objects
@@ -772,7 +772,7 @@ IPC_Perm :: struct {
cgid: u32,
mode: IPC_Mode,
seq: u16,
_: [2 + 2*size_of(int)],
_: [2 + 2*size_of(int)]u8,
}
when size_of(int) == 8 || ODIN_ARCH == .i386 {
@@ -816,7 +816,7 @@ Shmid_DS :: _Arch_Shmid_DS
SystemV shared memory info.
*/
Shm_Info :: struct {
used_ids: i32
used_ids: i32,
shm_tot: uint,
shm_rss: uint,
shm_swp: uint,
@@ -843,7 +843,7 @@ when ODIN_ARCH == .i386 {
nsems: uint,
_: [2]uint,
}
else when ODIN_ARCH == .amd64 {
} else when ODIN_ARCH == .amd64 {
_Arch_Semid_DS :: struct {
perm: IPC_Perm,
otime: int,
@@ -891,8 +891,8 @@ Sem_Un :: struct #raw_union {
/*
SystenV semaphore info.
*/
Sem_Info {
map: i32,
Sem_Info :: struct {
semmap: i32,
mni: i32,
mns: i32,
mnu: i32,
@@ -915,7 +915,7 @@ Msg_Buf :: struct {
/*
SystemV message queue data.
*/
struct Msqid_DS {
Msqid_DS :: struct {
perm: IPC_Perm,
stime: uint,
rtime: uint,
@@ -925,8 +925,8 @@ struct Msqid_DS {
qbytes: uint,
lspid: Pid,
lrpid: Pid,
_: [2]uint
};
_: [2]uint,
}
/*
Interval timer types
@@ -945,7 +945,7 @@ ITimer_Val :: struct {
value: Time_Val,
}
ITimer_Spec {
ITimer_Spec :: struct {
interval: Time_Spec,
value: Time_Spec,
}
@@ -953,7 +953,7 @@ ITimer_Spec {
/*
Flags for POSIX interval timers.
*/
ITimer_Flags :: bit_set[ITimer_Flags_Bits, u32]
ITimer_Flags :: bit_set[ITimer_Flags_Bits; u32]
when ODIN_ARCH == .arm32 {
_Arch_User_Regs :: struct {
@@ -991,7 +991,7 @@ when ODIN_ARCH == .arm32 {
vregs: [32]u128,
fpsr: u32,
fpcr: u32,
_: [2]u32
_: [2]u32,
}
_Arch_User_FPX_Regs :: struct {}
} else when ODIN_ARCH == .i386 {
@@ -1042,7 +1042,7 @@ when ODIN_ARCH == .arm32 {
padding: [56]uint,
}
} else when ODIN_ARCH == .amd64 {
_Arch_User_Regs {
_Arch_User_Regs :: struct {
// Callee-preserved, may not be correct if the syscall doesn't need
// these registers
r15: uint,
@@ -1083,7 +1083,23 @@ when ODIN_ARCH == .arm32 {
mxcsr_mask: u32,
st_space: [32]u32,
xmm_space: [64]u32,
_: [24]u32;
_: [24]u32,
}
// FXSR instruction set state
_Arch_User_FPX_Regs :: struct {
cwd: u16,
swd: u16,
twd: u16,
fop: u16,
fip: uint,
fcs: uint,
foo: uint,
fos: uint,
mxcsr: uint,
_: uint,
st_space: [32]uint,
xmm_space: [32]uint,
padding: [56]uint,
}
}
@@ -1120,13 +1136,12 @@ PTrace_Peek_Sig_Info_Args :: struct {
/*
ptrace's PEEKSIGINFO flags.
*/
PTrace_Peek_Sig_Info_Flags :: bit_set[PTrace_Peek_Sig_Info_Flags_Bits, u32]
PTrace_Peek_Sig_Info_Flags :: bit_set[PTrace_Peek_Sig_Info_Flags_Bits; u32]
/*
ptrace's SECCOMP metadata.
*/
PTrace_Seccomp_Metadata
{
PTrace_Seccomp_Metadata :: struct {
filter_off: u64,
flags: u64,
}
@@ -1153,19 +1168,19 @@ PTrace_Syscall_Info :: struct {
args: [6]u64,
ret_data: u32,
},
};
};
},
}
/*
ptrace's results of GET_RSEQ_CONFIGURATION.
*/
PTrace_RSeq_Configuration {
PTrace_RSeq_Configuration :: struct {
rseq_abi_pointer: u64,
rseq_abi_size: u32,
signature: u32,
flags: u32,
_: u32,
};
}
/*
Note types for PTRACE_GETREGSET. Mirrors constants in `elf` definition,