xref: /original-bsd/sys/hp/hpux/makesyscalls.sh (revision 27393bdf)
1#! /bin/sh -
2#	@(#)makesyscalls.sh	8.3 (Berkeley) 02/19/95
3
4set -e
5
6# name of compat option:
7compat=COMPAT_OHPUX
8
9# output files:
10sysnames="hpux_syscalls.c"
11syshdr="hpux_syscall.h"
12syssw="hpux_sysent.c"
13
14# tmp files:
15sysdcl="sysent.dcl"
16syscompat="sysent.compat"
17sysent="sysent.switch"
18
19trap "rm $sysdcl $syscompat $sysent" 0
20
21case $# in
22    0)	echo "Usage: $0 input-file" 1>&2
23	exit 1
24	;;
25esac
26
27awk < $1 "
28	BEGIN {
29		sysdcl = \"$sysdcl\"
30		syscompat = \"$syscompat\"
31		sysent = \"$sysent\"
32		sysnames = \"$sysnames\"
33		syshdr = \"$syshdr\"
34		compat = \"$compat\"
35		infile = \"$1\"
36		"'
37
38		printf "/*\n * System call switch table.\n *\n" > sysdcl
39		printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysdcl
40
41		printf "\n#ifdef %s\n", compat > syscompat
42		printf "#define compat(n, name) n, n * 4, __CONCAT(compat_43_,name)\n\n" > syscompat
43
44		printf "/*\n * System call names.\n *\n" > sysnames
45		printf " * DO NOT EDIT-- this file is automatically generated.\n" > sysnames
46
47		printf "/*\n * System call numbers.\n *\n" > syshdr
48		printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshdr
49	}
50	NR == 1 {
51		printf " * created from%s\n */\n\n", $0 > sysdcl
52		printf "#include <sys/param.h>\n" > sysdcl
53		printf "#include <sys/systm.h>\n\n" > sysdcl
54		printf "int\tnosys(),notimp();\n\n" > sysdcl
55
56		printf "struct sysent hpuxsysent[] = {\n" > sysent
57
58		printf " * created from%s\n */\n\n", $0 > sysnames
59		printf "char *hpuxsyscallnames[] = {\n" > sysnames
60
61		printf " * created from%s\n */\n\n", $0 > syshdr
62		next
63	}
64	NF == 0 || $1 ~ /^;/ {
65		next
66	}
67	$1 ~ /^#[ 	]*if/ {
68		print > sysent
69		print > sysdcl
70		print > syscompat
71		print > sysnames
72		savesyscall = syscall
73		next
74	}
75	$1 ~ /^#[ 	]*else/ {
76		print > sysent
77		print > sysdcl
78		print > syscompat
79		print > sysnames
80		syscall = savesyscall
81		next
82	}
83	$1 ~ /^#/ {
84		print > sysent
85		print > sysdcl
86		print > syscompat
87		print > sysnames
88		next
89	}
90	syscall != $1 {
91		printf "%s: line %d: syscall number out of sync at %d\n", \
92		   infile, NR, syscall
93		printf "line is:\n"
94		print
95		exit 1
96	}
97	{	comment = $4
98		for (i = 5; i <= NF; i++)
99			comment = comment " " $i
100		if (NF < 5)
101			$5 = $4
102	}
103	$2 == "STD" {
104		printf("int\t%s();\n", $4) > sysdcl
105		printf("\t{ %d, %d, %s },\t\t\t/* %d = %s */\n", \
106		    $3, $3 * 4, $4, syscall, $5) > sysent
107		printf("\t\"%s\",\t\t\t/* %d = %s */\n", \
108		    $5, syscall, $5) > sysnames
109		printf("#define\tSYS_%s\t%d\n", \
110		    $5, syscall) > syshdr
111		syscall++
112		next
113	}
114	$2 == "COMPAT" {
115		printf("int\tcompat_43_%s();\n", $4) > syscompat
116		printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \
117		    $3, $4, syscall, $5) > sysent
118		printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
119		    $5, syscall, $5) > sysnames
120		printf("\t\t\t\t/* %d is old %s */\n", \
121		    syscall, comment) > syshdr
122		syscall++
123		next
124	}
125	$2 == "LIBCOMPAT" {
126		printf("int\tcompat_43_%s();\n", $4) > syscompat
127		printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \
128		    $3, $4, syscall, $5) > sysent
129		printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
130		    $5, syscall, $5) > sysnames
131		printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \
132		    $5, syscall) > syshdr
133		syscall++
134		next
135	}
136	$2 == "OBSOL" {
137		printf("\t{ 0, 0, nosys },\t\t\t/* %d = obsolete %s */\n", \
138		    syscall, comment) > sysent
139		printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \
140		    $4, syscall, comment) > sysnames
141		printf("\t\t\t\t/* %d is obsolete %s */\n", \
142		    syscall, comment) > syshdr
143		syscall++
144		next
145	}
146	$2 == "UNIMPL" {
147		printf("\t{ 0, 0, nosys },\t\t\t/* %d = %s */\n", \
148		    syscall, comment) > sysent
149		printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \
150		    syscall, syscall, comment) > sysnames
151		syscall++
152		next
153	}
154	$2 == "NOTIMPL" {
155		printf("\t{ %d, %d, notimp },\t\t\t/* %d = %s (unimplemented) */\n", \
156		    $3, $3 * 4, syscall, comment) > sysent
157		printf("\t\"%s\",\t\t\t/* %d = %s (unimplemented) */\n", \
158		    $4, syscall, comment) > sysnames
159		syscall++
160		next
161	}
162	{
163		printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
164		exit 1
165	}
166	END {
167		printf("\n#else /* %s */\n", compat) > syscompat
168		printf("#define compat(n, name) 0, 0, nosys\n") > syscompat
169		printf("#endif /* %s */\n\n", compat) > syscompat
170
171		printf("};\n\n") > sysent
172		printf("int\thpuxnsysent = sizeof(hpuxsysent) / sizeof(hpuxsysent[0]);\n") > sysent
173
174		printf("};\n") > sysnames
175	} '
176
177cat $sysdcl $syscompat $sysent >$syssw
178
179chmod 444 $sysnames $syshdr $syssw
180