ref: 26a9351dfdfb784400792a06ceb6b76fda488c03
parent: b26325b6eb3d24678b009cd8492b487ea7f493c0
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Tue Sep 14 10:47:48 EDT 2021
libc: Update arch/amd64/linux 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/linux/.gitignore
+++ b/src/libc/arch/amd64/linux/.gitignore
@@ -1,6 +1,5 @@
-_Exit.s
-_brk.s
_close.s
+_exit.s
_getpid.s
_getrusage.s
_gettimeofday.s
@@ -9,6 +8,7 @@
_open.s
_read.s
_sigaction.s
+_sys_brk.s
_sys_errlist.c
-_write.s
_unlink.s
+_write.s
--- a/src/libc/arch/amd64/linux/Makefile
+++ b/src/libc/arch/amd64/linux/Makefile
@@ -1,42 +1,40 @@
.POSIX:
-PROJECTDIR =../../../../..
+PROJECTDIR = ../../../../..
+
include $(PROJECTDIR)/scripts/rules.mk
include ../../../rules.mk
GENOBJS =\
- _Exit.$O\
_close.$O\
+ _exit.$O\
_getpid.$O\
+ _getrusage.$O\
+ _gettimeofday.$O\
_kill.$O\
_lseek.$O\
_open.$O\
_read.$O\
- _write.$O\
- _brk.$O\
- _gettimeofday.$O\
_sigaction.$O\
- _getrusage.$O\
+ _sys_brk.$O\
_unlink.$O\
+ _write.$O\
-GENSRC = $(GENOBJS:.$O=.s)
-
-OBJS = \
+OBJS =\
$(GENOBJS)\
- _cerrno.$O\
- _sys_errlist.$O\
+ _cerrno.o\
+ _sys_errlist.o\
-# Rules
+GENSRC = $(GENOBJS:.$O=.s)
all: $(OBJS) $(CRT)
-crt.$O: ../crt-posix.s
+$(CRT): ../crt-posix.s
$(GENSRC): syscall.lst
./gensys.sh $(@:.s=)
clean:
- rm -f $(GENSRC)
- rm -f _sys_errlist.c
+ rm -f $(GENSRC) _sys_errlist.c
include deps.mk
--- a/src/libc/arch/amd64/linux/gensys.sh
+++ b/src/libc/arch/amd64/linux/gensys.sh
@@ -8,17 +8,19 @@
sed -n "
s/[ ]*#.*//
/$1/p" syscall.lst |
-while read num name
+while read num name nargs
do
-
cat <<EOF > $name.s
.file "$name.s"
.globl $name
$name:
+ `case $nargs in 4|5|6)
+ echo "movq %rcx,%r10"
+ ;;
+ esac`
movq \$$num,%rax
syscall
jmp _cerrno
EOF
-
done
--- a/src/libc/arch/amd64/linux/syscall.lst
+++ b/src/libc/arch/amd64/linux/syscall.lst
@@ -1,14 +1,15 @@
-#number name
-0 _read
-1 _write
-2 _open
-3 _close
-8 _lseek
-12 _brk
-13 _sigaction
-39 _getpid
-60 _Exit
-62 _kill
-87 _unlink
-96 _gettimeofday
-98 _getrusage
+#Tab 15
+#number name nargs
+0 _read 3
+1 _write 3
+2 _open 3
+3 _close 1
+8 _lseek 3
+12 _sys_brk 1
+13 _sigaction 3
+39 _getpid 0
+60 _exit 1
+62 _kill 2
+87 _unlink 1
+96 _gettimeofday 2
+98 _getrusage 2