]> git.ipfire.org Git - thirdparty/glibc.git/blob - mach/shortcut.awk
2005-08-05 Roland McGrath <roland@redhat.com>
[thirdparty/glibc.git] / mach / shortcut.awk
1 # Icky intimate knowledge of MiG output.
2
3 BEGIN { 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.
23 NF == 1 && $1 == ")" { inproto=0 }
24 inproto { proto = proto $0;
25 arg = $NF;
26 gsub(/[^a-zA-Z0-9_,]/, "", arg);
27 arglist = arglist arg;
28 }
29 NF == 1 && $1 == "(" { inproto=1 }
30
31 /^{$/ { echo=0; }
32
33 echo == 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 }