shithub: scc

Download patch

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

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.

--- /dev/null
+++ b/src/libc/arch/ppc/linux/.gitignore
@@ -1,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
--- 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\
+	_waitpid.$O\
+	_write.$O\
 
-GENSRC = $(GENOBJS:.$O=.s)
-
-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
--- 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
--- 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
--- 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