shithub: riscv

ref: 5bd3330e0bad0b0f02d05139822f7412c232880c
dir: /sys/src/9/port/mksystab/

View raw version
#!/bin/rc

file=/sys/src/libc/9syscall/sys.h

cat <<'!'
#include "/sys/src/libc/9syscall/sys.h"

typedef uintptr Syscall(va_list);

!

sed 's/#define[ 	]*([A-Z0-9_][A-Z0-9_]*).*/SYS\1/; s/SYSSYSR1/SYSR1/' $file |
	tr A-Z a-z |
	sed 's/.*/Syscall &;/'

cat <<'!'
Syscall	sysdeath;

Syscall *systab[]={
!
sam -d $file >[2] /dev/null <<'!'
,s/#define.([A-Z0-9_]+).*/	[\1]	SYS\1,/g
,x/SYS[A-Z0-9_]+,/ | tr A-Z a-z
,x/syssysr1/c/sysr1
,x/sys_x[0-9]*/c/sysdeath
,x v/\[......+\]/ s/\]/]	
,p
!

cat <<'!'
};

char *sysctab[]={
!

sam -d $file >[2] /dev/null <<'!'
,s/#define.([A-Z0-9_]+).*/	[\1]	"\1",/g
,x/"[A-Z0-9_]+",/ y/"[A-Z]/ | tr A-Z a-z
,x/_"/c/"
,x/Sysr1/c/Running
,x/Rendezvous/c/Rendez
,x v/\[......+\]/ s/\]/]	
,p
!

cat <<'!'
};

int nsyscall = (sizeof systab/sizeof systab[0]);
!