Deleted Added
full compact
makesyscalls.sh (6380) makesyscalls.sh (7090)
1#! /bin/sh -
2# @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
1#! /bin/sh -
2# @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93
3# $Id: makesyscalls.sh,v 1.10 1994/11/06 21:57:16 ats Exp $
3# $Id: makesyscalls.sh,v 1.11 1995/02/14 19:22:29 sos Exp $
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"
14syshide="../sys/syscall-hide.h"
15
16# tmp files:
17sysdcl="sysent.dcl"
18syscompat="sysent.compat"
19sysent="sysent.switch"
20
21trap "rm $sysdcl $syscompat $sysent" 0
22
23case $# in
24 0) echo "Usage: $0 input-file" 1>&2
25 exit 1
26 ;;
27esac
28
29awk < $1 "
30 BEGIN {
31 sysdcl = \"$sysdcl\"
32 syscompat = \"$syscompat\"
33 sysent = \"$sysent\"
34 sysnames = \"$sysnames\"
35 syshdr = \"$syshdr\"
36 compat = \"$compat\"
37 syshide = \"$syshide\"
38 infile = \"$1\"
39 "'
40
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 printf "/*\n * System call hiders.\n *\n" > syshide
53 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshide
54 }
55 NR == 1 {
56 printf " * created from%s\n */\n\n", $0 > sysdcl
57 printf "#include <sys/param.h>\n" > sysdcl
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"
14syshide="../sys/syscall-hide.h"
15
16# tmp files:
17sysdcl="sysent.dcl"
18syscompat="sysent.compat"
19sysent="sysent.switch"
20
21trap "rm $sysdcl $syscompat $sysent" 0
22
23case $# in
24 0) echo "Usage: $0 input-file" 1>&2
25 exit 1
26 ;;
27esac
28
29awk < $1 "
30 BEGIN {
31 sysdcl = \"$sysdcl\"
32 syscompat = \"$syscompat\"
33 sysent = \"$sysent\"
34 sysnames = \"$sysnames\"
35 syshdr = \"$syshdr\"
36 compat = \"$compat\"
37 syshide = \"$syshide\"
38 infile = \"$1\"
39 "'
40
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 printf "/*\n * System call hiders.\n *\n" > syshide
53 printf " * DO NOT EDIT-- this file is automatically generated.\n" > syshide
54 }
55 NR == 1 {
56 printf " * created from%s\n */\n\n", $0 > sysdcl
57 printf "#include <sys/param.h>\n" > sysdcl
58 printf "#include <sys/systm.h>\n" > sysdcl
59 printf "#include <sys/sysent.h>\n\n" > sysdcl
60
61 printf "struct sysent sysent[] = {\n" > sysent
62
63 printf " * created from%s\n */\n\n", $0 > sysnames
64 printf "char *syscallnames[] = {\n" > sysnames
65
66 printf " * created from%s\n */\n\n", $0 > syshdr
67
68 printf " * created from%s\n */\n\n", $0 > syshide
69 next
70 }
71 NF == 0 || $1 ~ /^;/ {
72 next
73 }
74 $1 ~ /^#[ ]*if/ {
75 print > sysent
76 print > sysdcl
77 print > syscompat
78 print > sysnames
79 print > syshide
80 savesyscall = syscall
81 next
82 }
83 $1 ~ /^#[ ]*else/ {
84 print > sysent
85 print > sysdcl
86 print > syscompat
87 print > sysnames
88 print > syshide
89 syscall = savesyscall
90 next
91 }
92 $1 ~ /^#/ {
93 print > sysent
94 print > sysdcl
95 print > syscompat
96 print > sysnames
97 print > syshide
98 next
99 }
100 syscall != $1 {
101 printf "%s: line %d: syscall number out of sync at %d\n", \
102 infile, NR, syscall
103 printf "line is:\n"
104 print
105 exit 1
106 }
107 { comment = $5
108 for (i = 6; i <= NF; i++)
109 comment = comment " " $i
110 if (NF < 6)
111 $6 = $5
112 if ($4 != "NOHIDE")
113 printf("HIDE_%s(%s)\n", $4, $5) > syshide
114 }
115 $2 == "STD" || $2 == "NODEF" {
116 if (( !nosys || $5 != "nosys" ) && ( !lkmnosys ||
117 $5 != "lkmnosys"))
118 printf("int\t%s();\n", $5) > sysdcl
119 if ($5 == "nosys")
120 nosys = 1
121 if ($5 == "lkmnosys")
122 lkmnosys = 1
123 printf("\t{ %d, %s },\t\t\t/* %d = %s */\n", \
124 $3, $5, syscall, $6) > sysent
125 printf("\t\"%s\",\t\t\t/* %d = %s */\n", \
126 $6, syscall, $6) > sysnames
127 if ($2 == "STD")
128 printf("#define\tSYS_%s\t%d\n", \
129 $6, syscall) > syshdr
130 syscall++
131 next
132 }
133 $2 == "COMPAT" {
134 printf("int\to%s();\n", $5) > syscompat
135 printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \
136 $3, $5, syscall, $6) > sysent
137 printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
138 $6, syscall, $6) > sysnames
139 printf("\t\t\t\t/* %d is old %s */\n", \
140 syscall, comment) > syshdr
141 syscall++
142 next
143 }
144 $2 == "LIBCOMPAT" {
145 printf("int\to%s();\n", $5) > syscompat
146 printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \
147 $3, $5, syscall, $6) > sysent
148 printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
149 $6, syscall, $6) > sysnames
150 printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \
151 $6, syscall) > syshdr
152 syscall++
153 next
154 }
155 $2 == "OBSOL" {
156 printf("\t{ 0, nosys },\t\t\t/* %d = obsolete %s */\n", \
157 syscall, comment) > sysent
158 printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \
159 $5, syscall, comment) > sysnames
160 printf("\t\t\t\t/* %d is obsolete %s */\n", \
161 syscall, comment) > syshdr
162 syscall++
163 next
164 }
165 $2 == "UNIMPL" {
166 printf("\t{ 0, nosys },\t\t\t/* %d = %s */\n", \
167 syscall, comment) > sysent
168 printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \
169 syscall, syscall, comment) > sysnames
170 syscall++
171 next
172 }
173 {
174 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
175 exit 1
176 }
177 END {
178 printf("\n#else /* %s */\n", compat) > syscompat
179 printf("#define compat(n, name) 0, nosys\n") > syscompat
180 printf("#endif /* %s */\n\n", compat) > syscompat
181
182 printf("};\n\n") > sysent
183 printf ("struct sysentvec aout_sysvec = {\n") > sysent
184 printf ("\tsizeof (sysent) / sizeof (sysent[0]),\n") > sysent
185 printf ("\tsysent,\n") > sysent
186 printf ("\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0\n};\n") > sysent
187 printf("};\n") > sysnames
188 } '
189
190cat $sysdcl $syscompat $sysent >$syssw
191
192chmod 444 $sysnames $syshdr $syssw $syshide
193
58 printf "#include <sys/sysent.h>\n\n" > sysdcl
59
60 printf "struct sysent sysent[] = {\n" > sysent
61
62 printf " * created from%s\n */\n\n", $0 > sysnames
63 printf "char *syscallnames[] = {\n" > sysnames
64
65 printf " * created from%s\n */\n\n", $0 > syshdr
66
67 printf " * created from%s\n */\n\n", $0 > syshide
68 next
69 }
70 NF == 0 || $1 ~ /^;/ {
71 next
72 }
73 $1 ~ /^#[ ]*if/ {
74 print > sysent
75 print > sysdcl
76 print > syscompat
77 print > sysnames
78 print > syshide
79 savesyscall = syscall
80 next
81 }
82 $1 ~ /^#[ ]*else/ {
83 print > sysent
84 print > sysdcl
85 print > syscompat
86 print > sysnames
87 print > syshide
88 syscall = savesyscall
89 next
90 }
91 $1 ~ /^#/ {
92 print > sysent
93 print > sysdcl
94 print > syscompat
95 print > sysnames
96 print > syshide
97 next
98 }
99 syscall != $1 {
100 printf "%s: line %d: syscall number out of sync at %d\n", \
101 infile, NR, syscall
102 printf "line is:\n"
103 print
104 exit 1
105 }
106 { comment = $5
107 for (i = 6; i <= NF; i++)
108 comment = comment " " $i
109 if (NF < 6)
110 $6 = $5
111 if ($4 != "NOHIDE")
112 printf("HIDE_%s(%s)\n", $4, $5) > syshide
113 }
114 $2 == "STD" || $2 == "NODEF" {
115 if (( !nosys || $5 != "nosys" ) && ( !lkmnosys ||
116 $5 != "lkmnosys"))
117 printf("int\t%s();\n", $5) > sysdcl
118 if ($5 == "nosys")
119 nosys = 1
120 if ($5 == "lkmnosys")
121 lkmnosys = 1
122 printf("\t{ %d, %s },\t\t\t/* %d = %s */\n", \
123 $3, $5, syscall, $6) > sysent
124 printf("\t\"%s\",\t\t\t/* %d = %s */\n", \
125 $6, syscall, $6) > sysnames
126 if ($2 == "STD")
127 printf("#define\tSYS_%s\t%d\n", \
128 $6, syscall) > syshdr
129 syscall++
130 next
131 }
132 $2 == "COMPAT" {
133 printf("int\to%s();\n", $5) > syscompat
134 printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \
135 $3, $5, syscall, $6) > sysent
136 printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
137 $6, syscall, $6) > sysnames
138 printf("\t\t\t\t/* %d is old %s */\n", \
139 syscall, comment) > syshdr
140 syscall++
141 next
142 }
143 $2 == "LIBCOMPAT" {
144 printf("int\to%s();\n", $5) > syscompat
145 printf("\t{ compat(%d,%s) },\t\t/* %d = old %s */\n", \
146 $3, $5, syscall, $6) > sysent
147 printf("\t\"old.%s\",\t\t/* %d = old %s */\n", \
148 $6, syscall, $6) > sysnames
149 printf("#define\tSYS_%s\t%d\t/* compatibility; still used by libc */\n", \
150 $6, syscall) > syshdr
151 syscall++
152 next
153 }
154 $2 == "OBSOL" {
155 printf("\t{ 0, nosys },\t\t\t/* %d = obsolete %s */\n", \
156 syscall, comment) > sysent
157 printf("\t\"obs_%s\",\t\t\t/* %d = obsolete %s */\n", \
158 $5, syscall, comment) > sysnames
159 printf("\t\t\t\t/* %d is obsolete %s */\n", \
160 syscall, comment) > syshdr
161 syscall++
162 next
163 }
164 $2 == "UNIMPL" {
165 printf("\t{ 0, nosys },\t\t\t/* %d = %s */\n", \
166 syscall, comment) > sysent
167 printf("\t\"#%d\",\t\t\t/* %d = %s */\n", \
168 syscall, syscall, comment) > sysnames
169 syscall++
170 next
171 }
172 {
173 printf "%s: line %d: unrecognized keyword %s\n", infile, NR, $2
174 exit 1
175 }
176 END {
177 printf("\n#else /* %s */\n", compat) > syscompat
178 printf("#define compat(n, name) 0, nosys\n") > syscompat
179 printf("#endif /* %s */\n\n", compat) > syscompat
180
181 printf("};\n\n") > sysent
182 printf ("struct sysentvec aout_sysvec = {\n") > sysent
183 printf ("\tsizeof (sysent) / sizeof (sysent[0]),\n") > sysent
184 printf ("\tsysent,\n") > sysent
185 printf ("\t0,\n\t0,\n\t0,\n\t0,\n\t0,\n\t0\n};\n") > sysent
186 printf("};\n") > sysnames
187 } '
188
189cat $sysdcl $syscompat $sysent >$syssw
190
191chmod 444 $sysnames $syshdr $syssw $syshide
192