ref: 08608702436b819d3022aceb2b870e3284228810
parent: c2fea0a96195c859978cbe53f367c00036f17af2
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Aug 29 16:09:33 EDT 2018
[lib/c] Fix signal implementation for NetBSD The definition of struct sigaction was wrong and sa_flags was in a wrong offset.
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/_setcontext.s
@@ -1,0 +1,14 @@
+
+ .text
+ .globl _Exit
+ .globl _setcontext
+
+_setcontext:
+ movq %r15,%rdi
+ movq $0x134,%rax
+ syscall
+
+ # Something was wrong, finish the program. We can't call
+ # abort here because it could generate a loop
+ movq $-1,%rdi
+ jmp _Exit
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/_sigaction.c
@@ -1,0 +1,15 @@
+
+#include <stddef.h>
+#include <sys.h>
+
+extern int _sigaction2(int sig,
+ struct sigaction *new, struct sigaction *old,
+ int siginfo[], int num);
+
+int
+_sigaction(int sig, struct sigaction *new, struct sigaction *old)
+{
+ extern int _setcontext[];
+
+ return _sigaction2(sig, new, old, _setcontext, 2);
+}
--- /dev/null
+++ b/lib/c/target/amd64-sysv-netbsd/_sigaction2.s
@@ -1,0 +1,12 @@
+
+# This syscall cannot be autogenerated because it receives more than
+# 4 arguments
+
+ .text
+ .globl _sigaction2
+
+_sigaction2:
+ mov $0x154,%eax
+ mov %rcx,%r10
+ syscall
+ retq