shithub: scc

Download patch

ref: 51ee6bb33d83575c9da8e4bbaad11cd55b16400e
parent: c53fa30afa573aa16715f46a379cf8e8d5d5e8a6
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Wed Mar 8 05:39:03 EST 2017

[libc-qbe-linux] Copy sys directory from amd64-linux

Both sys-arch have the same implementation, because the
system is the same in both cases.

diff: cannot open b/libc/src/sys/qbe-linux//null: file does not exist: 'b/libc/src/sys/qbe-linux//null'
--- /dev/null
+++ b/libc/src/sys/qbe-linux/Makefile
@@ -1,0 +1,25 @@
+# See LICENSE file for copyright and license details.
+.POSIX:
+
+include ../../../../config.mk
+
+OBJ_GEN = _read.o _write.o _open.o _close.o _lseek.o _brk.o\
+          _rt_sigaction.o _getpid.o _Exit.o _kill.o
+
+ASM_GEN = $(OBJ_GEN:.o=.s)
+OBJ = $(OBJ_GEN)
+
+all: $(OBJ) system.mk
+
+.s.o:
+	$(AS) $< -o $@
+
+system.mk: Makefile
+	echo '$$(SYSOBJ)' = $(OBJ) > system.mk
+
+$(ASM_GEN): syscall.lst
+	awk -f syscall.awk < syscall.lst
+
+clean:
+	rm -f *.o
+	rm -f $(ASM_GEN)
--- /dev/null
+++ b/libc/src/sys/qbe-linux/syscall.awk
@@ -1,0 +1,11 @@
+# This job is very easy because app and kernel ABI are identical
+# until the 4th parameter, so we only have to set the syscall
+# number in rax
+
+/^#/	{next}
+	{name=$2 ".s"
+	 printf "%s:\n" \
+	        "\tmovq\t$%d,%%rax\n" \
+	        "\tsyscall\n" \
+	        "\tret\n",$2, $1 > name
+	 close(name)}
--- /dev/null
+++ b/libc/src/sys/qbe-linux/syscall.lst
@@ -1,0 +1,11 @@
+#number	name
+0	_read
+1	_write
+2	_open
+3	_close
+3	_lseek
+12	_brk
+13	_rt_sigaction
+38	_getpid
+60	_Exit
+32	_kill
--- /dev/null
+++ b/libc/src/sys/qbe-linux/system.mk
@@ -1,0 +1,1 @@
+$(SYSOBJ) = _read.o _write.o _open.o _close.o _lseek.o _brk.o _rt_sigaction.o _getpid.o _Exit.o _kill.o _sbrk.o