shithub: scc

Download patch

ref: b9b8ac6cf7afbdcad2b2b725b09fdeddc63ba2b3
parent: 440e24ce81386865be595f5825bc7287d5063ccc
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Sep 14 10:47:48 EDT 2021

libc: Update arch/amd64/darwin

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/darwin/.gitignore
+++ b/src/libc/arch/amd64/darwin/.gitignore
@@ -1,5 +1,5 @@
 __close.s
-__Exit.s
+__exit.s
 __getpid.s
 __kill.s
 __lseek.s
--- a/src/libc/arch/amd64/darwin/Makefile
+++ b/src/libc/arch/amd64/darwin/Makefile
@@ -5,25 +5,22 @@
 include ../../../rules.mk
 
 GENOBJS =\
-	__Exit.$O\
 	__close.$O\
+	__exit.$O\
 	__getpid.$O\
 	__kill.$O\
 	__lseek.$O\
 	__open.$O\
 	__read.$O\
-	__write.$O\
 	__sigaction.$O\
+	__write.$O\
 
 GENSRC = $(GENOBJS:.$O=.s)
 
 OBJS  =\
 	$(GENOBJS)\
-	_getheap.$O\
 	_sys_errlist.$O\
 
-# Rules
-
 all: $(OBJS) $(CRT)
 
 crt.$O: ../crt-posix.s
@@ -32,7 +29,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/darwin/gensys.sh
+++ b/src/libc/arch/amd64/darwin/gensys.sh
@@ -5,10 +5,10 @@
 # until the 4th parameter, so we only have to set the syscall
 # number in rax
 
-awk 'NF == 2 && $2 == "'$1'" {
-	printf("0x%x\t%s\n", 33554432 + $1, $2)
-}' syscall.lst |
-while read num name
+awk 'BEGIN  {n = 33554432}
+            {gsub(/ *#./, "")}
+     /'$1'/ {printf("0x%x\t%s\t%s\n",  n + $1, $2, $3)}' syscall.lst |
+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/darwin/syscall.lst
+++ b/src/libc/arch/amd64/darwin/syscall.lst
@@ -1,9 +1,11 @@
-1	__Exit
-3	__read
-4	__write
-5	__open
-6	__close
-20	__getpid
-46	__sigaction
-37	__kill
-199	__lseek
+#Tab 15
+#number	name	nargs
+1	__exit	1
+3	__read	3
+4	__write	3
+5	__open	3
+6	__close	1
+20	__getpid	0
+46	__sigaction	3
+37	__kill	2
+199	__lseek	3