scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit 78998efe6e308b35bbb723548e49d85b8d5d46de
parent 02741f466aea87b88a42ec4955132349ae38c8aa
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Tue, 14 Sep 2021 14:47:48 +0200

libc: Update arch/ppc/linux

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

Diffstat:
Asrc/libc/arch/ppc/linux/.gitignore | 13+++++++++++++
Msrc/libc/arch/ppc/linux/Makefile | 36+++++++++++++++++++-----------------
Msrc/libc/arch/ppc/linux/_cerrno.s | 7+++++--
Msrc/libc/arch/ppc/linux/gensys.sh | 28+++++++++++++++-------------
Msrc/libc/arch/ppc/linux/syscall.lst | 5+++--
5 files changed, 55 insertions(+), 34 deletions(-)

diff --git a/src/libc/arch/ppc/linux/.gitignore b/src/libc/arch/ppc/linux/.gitignore @@ -0,0 +1,13 @@ +_close.s +_creat.s +_exit.s +_getpid.s +_kill.s +_link.s +_open.s +_read.s +_sys_brk.s +_sys_errlist.c +_unlink.s +_waitpid.s +_write.s diff --git a/src/libc/arch/ppc/linux/Makefile b/src/libc/arch/ppc/linux/Makefile @@ -1,38 +1,40 @@ .POSIX: -PROJECTDIR =../../../../.. +PROJECTDIR = ../../../../.. +RULES = user + include $(PROJECTDIR)/scripts/rules.mk include ../../../rules.mk GENOBJS =\ - _Exit.$O\ - _read.$O\ - _write.$O\ - _open.$O\ _close.$O\ - _waitpid.$O\ - _create.$O\ + _creat.$O\ + _exit.$O\ + _getpid.$O\ + _kill.$O\ _link.$O\ + _open.$O\ + _read.$O\ + _sys_brk.$O\ _unlink.$O\ - _getpid.$O\ - _brk.$O\ - -GENSRC = $(GENOBJS:.$O=.s) + _waitpid.$O\ + _write.$O\ -OBJS = \ +OBJS =\ + _cerrno.o\ + _sys_errlist.o\ $(GENOBJS)\ - _cerrno.$O\ -# Rules +GENSRC = $(GENOBJS:.o=.s) -all: $(OBJS) $(CRT) +all: $(CRT) $(OBJS) -crt.$O: ../crt-posix.s +$(CRT): ../crt-posix.s $(GENSRC): syscall.lst ./gensys.sh $(@:.s=) clean: - rm -f $(GENSRC) + rm -f $(GENSRC) _sys_errlist.c include deps.mk diff --git a/src/libc/arch/ppc/linux/_cerrno.s b/src/libc/arch/ppc/linux/_cerrno.s @@ -1,12 +1,15 @@ .file "_cerrno.s" + + .text .globl _cerrno _cerrno: - cmpwi 0,0 - bne err + bso err blr + err: lis 14,errno@h ori 14,14,errno@l + neg 3,3 stw 3,0(14) xor 3,3,3 addi 3,3,-1 diff --git a/src/libc/arch/ppc/linux/gensys.sh b/src/libc/arch/ppc/linux/gensys.sh @@ -1,17 +1,19 @@ #!/bin/sh -awk '! /^#/ && $2 == "'$1'" { - syscall=$2 - fname=$2".s" +sed -n " + s/[ ]*#.*// + /$1/p" syscall.lst | +while read num name nargs +do +cat <<EOF > $name.s + .file "$name.s" - printf ("\t.file\t" \ - "\"%s\"\n" \ - "\t.globl\t%s\n" \ - "%s:\n", - fname, syscall, syscall) + .globl $name +$name: + li 0,$num + sc + mfcr 0 + b _cerrno +EOF - printf ("\tli\t0,%d\n" \ - "\tsc\n" \ - "\tmfcr\t0\n" \ - "\tb\t_cerrno\n", $1) -} ' syscall.lst >$1.s +done diff --git a/src/libc/arch/ppc/linux/syscall.lst b/src/libc/arch/ppc/linux/syscall.lst @@ -1,5 +1,5 @@ #number name -1 _Exit +1 _exit 3 _read 4 _write 5 _open @@ -9,4 +9,5 @@ 9 _link 10 _unlink 20 _getpid -45 _brk +37 _kill +45 _sys_brk