aboutsummaryrefslogtreecommitdiff
path: root/mach/shortcut.awk
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
committerRoland McGrath <roland@gnu.org>1995-02-18 01:27:10 +0000
commit28f540f45bbacd939bfd07f213bcad2bf730b1bf (patch)
tree15f07c4c43d635959c6afee96bde71fb1b3614ee /mach/shortcut.awk
downloadglibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.gz
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.tar.bz2
glibc-28f540f45bbacd939bfd07f213bcad2bf730b1bf.zip
initial import
Diffstat (limited to 'mach/shortcut.awk')
-rw-r--r--mach/shortcut.awk45
1 files changed, 45 insertions, 0 deletions
diff --git a/mach/shortcut.awk b/mach/shortcut.awk
new file mode 100644
index 0000000000..d6090d7bf7
--- /dev/null
+++ b/mach/shortcut.awk
@@ -0,0 +1,45 @@
+# Icky intimate knowledge of MiG output.
+
+BEGIN { print "/* This file is generated by shortcut.awk. */";
+ echo=1;
+ inproto=0; proto=""; arglist="";
+ }
+
+$1 == "LINTLIBRARY" { print "#include <mach.h>"; next }
+
+# Copy the first line of the definition, but
+# replace the function name (RPC) with CALL.
+$NF == rpc \
+ {
+ for (i = 1; i < NF; ++i) printf "%s ", $i;
+ print call;
+ next;
+ }
+
+# Collect the lines of the prototype in PROTO, and extract the parameter
+# names into ARGLIST.
+NF == 1 && $1 == ")" { inproto=0 }
+inproto { proto = proto $0;
+ arg = $NF;
+ gsub(/[^a-zA-Z0-9_,]/, "", arg);
+ arglist = arglist arg;
+ }
+NF == 1 && $1 == "(" { inproto=1 }
+
+/^{$/ { echo=0; }
+
+echo == 1 { print $0; }
+
+/^}$/ \
+ {
+ print "{";
+ print " kern_return_t err;";
+ print " extern kern_return_t " syscall " (" proto ");";
+ print " err = " syscall " (" arglist ");";
+ print " if (err == MACH_SEND_INTERRUPTED)";
+ print " err = " rpc " (" arglist ");";
+ print " return err;"
+ print "}";
+ print "weak_alias (" call ", " alias ")"
+ echo = 1;
+ }