shithub: scc

Download patch

ref: 04eaa4bdf25f5d142a47eed13dff69a5cf4497e1
parent: d7f0e25b97d041a2645e2d90f6033949b01c7cc6
author: zerous Naveen Narayanan <zerous@nocebo.space>
date: Tue Sep 3 20:28:47 EDT 2019

Add gensys.sh and syscall.lst for i386

--- a/src/libc/arch/i386/linux/Makefile
+++ b/src/libc/arch/i386/linux/Makefile
@@ -3,14 +3,30 @@
 include $(PROJECTDIR)/scripts/rules.mk
 include ../../../rules.mk
 
-OBJS 	= crt.o
+OBJS 	=\
+	_Exit.o\
+	_close.o\
+	_open.o\
+	_read.o\
+	_write.o\
+	_lseek.o\
+	_brk.o\
+	_sigaction.o\
+	_getpid.o\
+	_Exit.o\
+	_kill.o\
+	crt.o\
 
-all:
+all: syscall
 	$(MAKE) objs
 
 objs: $(OBJS)
 
 crt.o:	../crt-posix.s
+
+syscall: syscall.lst
+	gensys.sh syscall.lst
+	touch syscall
 
 clean:
 	rm -f `awk '/[0-9]*	_/ {print $$2".s"}' syscall.lst`
--- /dev/null
+++ b/src/libc/arch/i386/linux/gensys.sh
@@ -1,0 +1,20 @@
+#!/bin/sh
+#
+# 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 eax
+
+sed 's/[ 	]*#.*//
+     /^$/d' syscall.lst |
+while read num name
+do
+cat <<EOF > $name.s
+	.file	"$name.s"
+
+	.globl	$name
+$name:
+	movl	\$$num,%eax
+	syscall
+	jmp	_cerrno
+EOF
+done
--- /dev/null
+++ b/src/libc/arch/i386/linux/syscall.lst
@@ -1,0 +1,11 @@
+#number name
+3	_read
+4	_write
+5	_open
+6	_close
+19	_lseek
+45	_brk
+67	_sigaction
+20	_getpid
+1	_Exit
+37	_kill