shithub: scc

Download patch

ref: 024c96cf957f7185b6d5e95bb8770f3de76f1de3
parent: 38d360b9a0c73d60a5e8e8df65854c53d6f145f5
author: Roberto E. Vargas Caballero <[email protected]>
date: Tue Sep 14 10:47:48 EDT 2021

libc: Update arch/amd64/netbsd

This code is being updated out of the tree of scc and
it is time to synchroniza both copies now.

--- a/src/libc/arch/amd64/netbsd/.gitignore
+++ b/src/libc/arch/amd64/netbsd/.gitignore
@@ -1,6 +1,6 @@
-_Exit.s
 _brk.s
 _close.s
+_exit.s
 _getpid.s
 _gettimeofday.s
 _kill.s
@@ -7,5 +7,7 @@
 _lseek.s
 _open.s
 _read.s
+_setcontext.s
+_sigaction2.s
 _sys_errlist.c
 _write.s
--- a/src/libc/arch/amd64/netbsd/Makefile
+++ b/src/libc/arch/amd64/netbsd/Makefile
@@ -5,24 +5,25 @@
 include ../../../rules.mk
 
 GENOBJS  =\
-	_Exit.$O\
+	_brk.$O\
 	_close.$O\
+	_exit.$O\
 	_getpid.$O\
+	_gettimeofday.$O\
 	_kill.$O\
 	_lseek.$O\
 	_open.$O\
 	_read.$O\
+	_setcontext.$O\
+	_sigaction2.$O\
 	_write.$O\
-	_brk.$O\
 
-GENSRC = $(GENOBJS:.$O=.s)
-
 OBJS =\
 	$(GENOBJS)\
-	_setcontext.$O\
-	_sigaction2.$O\
 	_sys_errlist.$O\
 
+GENSRC = $(GENOBJS:.$O=.s)
+
 all: $(OBJS) $(CRT)
 
 crt.$O: ../crt-posix.s ../netbsd/crt.s
@@ -31,7 +32,6 @@
 	./gensys.sh $(@:.s=)
 
 clean:
-	rm -f $(GENSRC)
-	rm -f syscall _sys_errlist.c
+	rm -f $(GENSRC) _sys_errlist.c
 
 include deps.mk
--- a/src/libc/arch/amd64/netbsd/_setcontext.s
+++ /dev/null
@@ -1,14 +1,0 @@
-
-	.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
--- a/src/libc/arch/amd64/netbsd/_sigaction2.s
+++ /dev/null
@@ -1,12 +1,0 @@
-
-# This syscall cannot be autogenerated because it receives more than
-# 4 arguments
-
-	.text
-	.globl	_sigaction2
-
-_sigaction2:
-	mov	$0x154,%eax
-	mov	%rcx,%r10
-	syscall
-	retq
--- a/src/libc/arch/amd64/netbsd/gensys.sh
+++ b/src/libc/arch/amd64/netbsd/gensys.sh
@@ -8,7 +8,7 @@
 sed -n "
      s/[ 	]*#.*//
      /$1/p" syscall.lst |
-while read num name
+while read num name nargs
 do
 cat <<EOF > $name.s
 	.file	"$name.s"
@@ -15,6 +15,10 @@
 
 	.globl	$name
 $name:
+	`case $nargs in 4|5|6)
+		echo "movq       %rcx,%r10"
+                ;;
+        esac`
 	movq	\$$num,%rax
 	syscall
 	jb	1f
--- a/src/libc/arch/amd64/netbsd/syscall.lst
+++ b/src/libc/arch/amd64/netbsd/syscall.lst
@@ -1,11 +1,14 @@
-#number	name
-1	_Exit
-3	_read
-4	_write
-5	_open
-6	_close
-17	_brk
-20	_getpid
-37	_kill
-199	_lseek
-418	_gettimeofday
+#Tab 15
+#number	name	nargs
+1	_exit	1
+3	_read	3
+4	_write	3
+5	_open	3
+6	_close	1
+17	_brk	1
+20	_getpid	0
+37	_kill	2
+199	_lseek	3
+308	_setcontext	1
+340	_sigaction2	5
+418	_gettimeofday	2