]> git.ipfire.org Git - thirdparty/glibc.git/blame - mach/shortcut.awk
* nscd/mem.c (mempool_alloc): Use posix_fallocate instead of ftruncate.
[thirdparty/glibc.git] / mach / shortcut.awk
CommitLineData
28f540f4
RM
1# 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# Copy the first line of the definition, but
11# replace the function name (RPC) with CALL.
12$NF == rpc \
13 {
14 for (i = 1; i < NF; ++i) printf "%s ", $i;
15 print call;
16 next;
17 }
18
19# Collect the lines of the prototype in PROTO, and extract the parameter
20# names into ARGLIST.
21NF == 1 && $1 == ")" { inproto=0 }
22inproto { proto = proto $0;
23 arg = $NF;
24 gsub(/[^a-zA-Z0-9_,]/, "", arg);
25 arglist = arglist arg;
26 }
27NF == 1 && $1 == "(" { inproto=1 }
28
29/^{$/ { echo=0; }
30
31echo == 1 { print $0; }
32
9ce8b3c8 33/^}$/ && proto != "" \
28f540f4
RM
34 {
35 print "{";
36 print " kern_return_t err;";
37 print " extern kern_return_t " syscall " (" proto ");";
958f803f 38 print " extern kern_return_t " rpc " (" proto ");";
28f540f4
RM
39 print " err = " syscall " (" arglist ");";
40 print " if (err == MACH_SEND_INTERRUPTED)";
41 print " err = " rpc " (" arglist ");";
42 print " return err;"
43 print "}";
958f803f
RM
44 print "weak_alias (" call ", " alias ")";
45 # Declare RPC so the weak_alias that follows will work.
46 print "extern __typeof (" call ") " rpc ";";
28f540f4
RM
47 echo = 1;
48 }