blob: ea283d49ba695671fe924c9844577c4e6e1b94b2 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001# Icky intimate knowledge of MiG output.
2
3BEGIN { print "/* This file is generated by shortcut.awk. */";
4 echo=1;
5 inproto=0; proto=""; arglist="";
6 }
7
8$1 == "LINTLIBRARY" { print "#include <mach.h>"; next }
9
10$1 == "weak_alias" { next }
11
12# Copy the first line of the definition, but
13# replace the function name (RPC) with CALL.
14$NF == rpc \
15 {
16 for (i = 1; i < NF; ++i) printf "%s ", $i;
17 print call;
18 next;
19 }
20
21# Collect the lines of the prototype in PROTO, and extract the parameter
22# names into ARGLIST.
23NF == 1 && $1 == ")" { inproto=0 }
24inproto { proto = proto $0;
25 arg = $NF;
26 gsub(/[^a-zA-Z0-9_,]/, "", arg);
27 arglist = arglist arg;
28 }
29NF == 1 && $1 == "(" { inproto=1 }
30
31/^{$/ { echo=0; }
32
33echo == 1 { print $0; }
34
35/^}$/ && proto != "" \
36 {
37 print "{";
38 print " kern_return_t err;";
39 print " extern kern_return_t " syscall " (" proto ");";
40 print " extern kern_return_t " rpc " (" proto ");";
41 print " err = " syscall " (" arglist ");";
42 print " if (err == MACH_SEND_INTERRUPTED)";
43 print " err = " rpc " (" arglist ");";
44 print " return err;"
45 print "}";
46 print "weak_alias (" call ", " alias ")";
47 # Declare RPC so the weak_alias that follows will work.
48 print "extern __typeof (" call ") " rpc ";";
49 echo = 1;
50 }