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