Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
script3r
GitHub Repository: script3r/os161
Path: blob/master/user/lib/libc/syscalls/gensyscalls.sh
734 views
1
#!/bin/sh
2
#
3
# gensyscalls.sh
4
# Usage: ./gensyscalls.sh < syscalls.h
5
#
6
# Parses the kernel's syscalls.h into the body of syscalls.S
7
#
8
9
# tabs to spaces, just in case
10
tr '\t' ' ' |\
11
awk '
12
# Do not read the parts of the file that are not between the markers.
13
/^\/\*CALLBEGIN\*\// { look=1; }
14
/^\/\*CALLEND\*\// { look=0; }
15
16
# And, do not read lines that do not match the approximate right pattern.
17
look && /^#define SYS_/ && NF==3 {
18
sub("^SYS_", "", $2);
19
# print the name of the call and the number.
20
print $2, $3;
21
}
22
' | awk '{
23
# output something simple that will work in syscalls.S.
24
printf "SYSCALL(%s, %s)\n", $1, $2;
25
}'
26
27
28