commit 94877581739a14b335f498a8e9ec31eceedf99ed
parent 4c293843e6eab23e2bf9f43d34136839e652a940
Author: Sebastian <sebastian@sebsite.pw>
Date: Wed, 10 May 2023 17:04:35 -0400
rt+freebsd: add more signal functions and constants
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
7 files changed, 124 insertions(+), 10 deletions(-)
diff --git a/rt/+freebsd/+aarch64.ha b/rt/+freebsd/+aarch64.ha
@@ -0,0 +1,30 @@
+export type siginfo = struct {
+ si_signo: int,
+ si_errno: int,
+ si_code: int,
+ si_pid: pid_t,
+ si_uid: uid_t,
+ si_status: int,
+ si_addr: *void,
+ si_value: sigval,
+ _reason: union {
+ _fault: struct {
+ _trapno: int,
+ },
+ _timer: struct {
+ _timerid: int,
+ _overrun: int,
+ },
+ _mesgq: struct {
+ _mqd: int,
+ },
+ _poll: struct {
+ _band: i64,
+ },
+ __spare__: struct {
+ __spare1__: i64,
+ __spare2__: [7]int,
+ },
+ },
+};
+
diff --git a/rt/+freebsd/+riscv64.ha b/rt/+freebsd/+riscv64.ha
@@ -0,0 +1,30 @@
+export type siginfo = struct {
+ si_signo: int,
+ si_errno: int,
+ si_code: int,
+ si_pid: pid_t,
+ si_uid: uid_t,
+ si_status: int,
+ si_addr: *void,
+ si_value: sigval,
+ _reason: union {
+ _fault: struct {
+ _trapno: int,
+ },
+ _timer: struct {
+ _timerid: int,
+ _overrun: int,
+ },
+ _mesgq: struct {
+ _mqd: int,
+ },
+ _poll: struct {
+ _band: i64,
+ },
+ __spare__: struct {
+ __spare1__: i64,
+ __spare2__: [7]int,
+ },
+ },
+};
+
diff --git a/rt/+freebsd/+x86_64.ha b/rt/+freebsd/+x86_64.ha
@@ -0,0 +1,30 @@
+export type siginfo = struct {
+ si_signo: int,
+ si_errno: int,
+ si_code: int,
+ si_pid: pid_t,
+ si_uid: uid_t,
+ si_status: int,
+ si_addr: *void,
+ si_value: sigval,
+ _reason: union {
+ _fault: struct {
+ _trapno: int,
+ },
+ _timer: struct {
+ _timerid: int,
+ _overrun: int,
+ },
+ _mesgq: struct {
+ _mqd: int,
+ },
+ _poll: struct {
+ _band: i64,
+ },
+ __spare__: struct {
+ __spare1__: i64,
+ __spare2__: [7]int,
+ },
+ },
+};
+
diff --git a/rt/+freebsd/syscalls.ha b/rt/+freebsd/syscalls.ha
@@ -537,3 +537,21 @@ export fn setrlimit(resource: int, rlim: *const rlimit) (void | errno) = {
wrap_return(syscall2(SYS_setrlimit,
resource: u64, rlim: uintptr: u64))?;
};
+
+export fn sigprocmask(
+ how: int,
+ set: nullable *const sigset,
+ old: nullable *sigset,
+) (int | errno) = {
+ return wrap_return(syscall3(SYS_sigprocmask,
+ how: u64, set: uintptr: u64, old: uintptr: u64))?: int;
+};
+
+export fn sigaction(
+ signum: int,
+ act: *const sigact,
+ old: nullable *sigact,
+) (int | errno) = {
+ return wrap_return(syscall3(SYS_sigaction,
+ signum: u64, act: uintptr: u64, old: uintptr: u64))?: int;
+};
diff --git a/rt/+freebsd/types.ha b/rt/+freebsd/types.ha
@@ -28,6 +28,14 @@ export type sigset = struct {
__bits: [4]u32,
};
+export def SA_ONSTACK: u64 = 0x0001;
+export def SA_RESTART: u64 = 0x0002;
+export def SA_RESETHAND: u64 = 0x0004;
+export def SA_NOCLDSTOP: u64 = 0x0008;
+export def SA_NODEFER: u64 = 0x0010;
+export def SA_NOCLDWAIT: u64 = 0x0020;
+export def SA_SIGINFO: u64 = 0x0040;
+
export def SIG_ERR: uintptr = -1;
export def SIG_DFL: uintptr = 0;
export def SIG_IGN: uintptr = 1;
@@ -43,16 +51,9 @@ export type sigact = struct {
sa_mask: sigset,
};
-export type siginfo = struct {
- // TODO: Fill in more of this
- si_signo: int,
- si_errno: int,
- si_code: int,
- si_pid: pid_t,
- si_uid: u32,
- si_status: int,
- si_addr: *void,
-};
+export def SIG_BLOCK: int = 1;
+export def SIG_UNBLOCK: int = 2;
+export def SIG_SETMASK: int = 3;
export type sigval = union {
sival_t: int,
@@ -333,6 +334,7 @@ export def SIGQUIT: int = 3;
export def SIGILL: int = 4;
export def SIGTRAP: int = 5;
export def SIGABRT: int = 6;
+export def SIGEMT: int = 7;
export def SIGFPE: int = 8;
export def SIGKILL: int = 9;
export def SIGBUS: int = 10;
@@ -341,6 +343,7 @@ export def SIGSYS: int = 12;
export def SIGPIPE: int = 13;
export def SIGALRM: int = 14;
export def SIGTERM: int = 15;
+export def SIGURG: int = 16;
export def SIGSTOP: int = 17;
export def SIGTSTP: int = 18;
export def SIGCONT: int = 19;
diff --git a/scripts/gen-stdlib b/scripts/gen-stdlib
@@ -53,6 +53,7 @@ gensrcs_rt() {
+freebsd/segmalloc.ha \
+freebsd/signal.ha \
+freebsd/socket.ha \
+ +freebsd/'+$(ARCH)'.ha \
+freebsd/syscallno.ha \
+freebsd/syscalls.ha \
+freebsd/types.ha \
diff --git a/stdlib.mk b/stdlib.mk
@@ -40,6 +40,7 @@ stdlib_rt_freebsd_srcs = \
$(STDLIB)/rt/+freebsd/segmalloc.ha \
$(STDLIB)/rt/+freebsd/signal.ha \
$(STDLIB)/rt/+freebsd/socket.ha \
+ $(STDLIB)/rt/+freebsd/+$(ARCH).ha \
$(STDLIB)/rt/+freebsd/syscallno.ha \
$(STDLIB)/rt/+freebsd/syscalls.ha \
$(STDLIB)/rt/+freebsd/types.ha \
@@ -2279,6 +2280,7 @@ testlib_rt_freebsd_srcs = \
$(STDLIB)/rt/+freebsd/segmalloc.ha \
$(STDLIB)/rt/+freebsd/signal.ha \
$(STDLIB)/rt/+freebsd/socket.ha \
+ $(STDLIB)/rt/+freebsd/+$(ARCH).ha \
$(STDLIB)/rt/+freebsd/syscallno.ha \
$(STDLIB)/rt/+freebsd/syscalls.ha \
$(STDLIB)/rt/+freebsd/types.ha \