scc

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

gensys.sh (376B)


      1 #!/bin/sh
      2 
      3 #
      4 # This job is very easy because app and kernel ABI are identical
      5 # until the 4th parameter, so we only have to set the syscall
      6 # number in rax
      7 
      8 sed 's/[ 	]*#.*//
      9      /^$/d' syscall.lst |
     10 while read num name
     11 do
     12 cat <<EOF > $name.s
     13 	.file	"$name.s"
     14 
     15 	.globl	$name
     16 $name:
     17 	movq	\$$num,%rax
     18 	syscall
     19 	jb	1f
     20 	retq
     21 
     22 1:	movq	%rax,(errno)
     23 	movq	\$-1,%rax
     24 	retq
     25 EOF
     26 done