shithub: scc

Download patch

ref: c2fea0a96195c859978cbe53f367c00036f17af2
parent: 1c2826a8e5a78c85eea6bd234ff384241b2dc3db
author: Roberto E. Vargas Caballero <[email protected]>
date: Wed Aug 29 16:34:47 EDT 2018

[lib/c] Add basic support for signals in OpenBSD

This support was copied from NetBSD and it wasn't tested.

--- a/lib/c/target/amd64-sysv-openbsd/Makefile
+++ b/lib/c/target/amd64-sysv-openbsd/Makefile
@@ -5,7 +5,7 @@
 
 SYSNAME    = amd64-sysv-netbsd
 SCC_CFLAGS = -static -nostdinc -I$(INCDIR) -I$(INCDIR)/bits/amd64-sysv/ -I.
-SYSOBJ     = raise.o signal.o
+SYSOBJ     = raise.o signal.o _setcontext.o _sigaction.o _sigaction2.o
 
 include syscall.mk
 include ../script/objlst.mk
--- /dev/null
+++ b/lib/c/target/amd64-sysv-openbsd/_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-openbsd/_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-openbsd/_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