scc

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

gensys.sh (407B)


      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 awk 'NF == 2 {printf("0x%x\t%s\n", 33554432 + $1, $2)}' syscall.lst |
      9 while read num name
     10 do
     11 cat <<EOF > $name.s
     12 	.file	"$name.s"
     13 
     14 	.globl	$name
     15 $name:
     16 	movq	\$$num,%rax
     17 	syscall
     18 	jb	1f
     19 	retq
     20 
     21 1:	movq	%rax,_errno(%rip)
     22 	movq	\$-1,%rax
     23 	retq
     24 EOF
     25 done