scc

simple C compiler
git clone git://git.2f30.org/scc
Log | Files | Refs | README | LICENSE

commit 36d9492c408ec4d07629be1798fec2ea4cc17b0e
parent b2548524277b4e64afb2f4cc3fc19f4993f7e3b6
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Wed,  8 Mar 2017 10:39:03 +0100

[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.

Diffstat:
Alibc/src/sys/qbe-linux/Makefile | 25+++++++++++++++++++++++++
Alibc/src/sys/qbe-linux/syscall.awk | 11+++++++++++
Alibc/src/sys/qbe-linux/syscall.lst | 11+++++++++++
Alibc/src/sys/qbe-linux/system.mk | 1+
4 files changed, 48 insertions(+), 0 deletions(-)

diff --git a/libc/src/sys/qbe-linux/Makefile b/libc/src/sys/qbe-linux/Makefile @@ -0,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) diff --git a/libc/src/sys/qbe-linux/syscall.awk b/libc/src/sys/qbe-linux/syscall.awk @@ -0,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)} diff --git a/libc/src/sys/qbe-linux/syscall.lst b/libc/src/sys/qbe-linux/syscall.lst @@ -0,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 diff --git a/libc/src/sys/qbe-linux/system.mk b/libc/src/sys/qbe-linux/system.mk @@ -0,0 +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