File: shortcut.awk

package info (click to toggle)
glibc 2.28-8
  • links: PTS, VCS
  • area: main
  • in suites: buster, experimental, sid
  • size: 271,788 kB
  • sloc: ansic: 1,008,637; asm: 259,607; makefile: 11,271; sh: 10,477; python: 6,910; cpp: 4,992; perl: 2,258; awk: 2,005; yacc: 290; pascal: 182; sed: 73
file content (52 lines) | stat: -rw-r--r-- 1,382 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Icky intimate knowledge of MiG output.

BEGIN { print "/* This file is generated by shortcut.awk.  */";
	print "#include <mach-shortcuts-hidden.h>";
	echo=1;
	inproto=0; proto=""; arglist="";
      }

$1 == "LINTLIBRARY" { print "#include <mach.h>"; next }

$1 == "weak_alias" { 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; }

/^}$/ && proto != "" \
  {
    print "{";
    print "  kern_return_t err;";
    print "  extern kern_return_t " syscall " (" proto ");";
    print "  extern kern_return_t " rpc " (" proto ");";
    print "  err = " syscall " (" arglist ");";
    print "  if (err == MACH_SEND_INTERRUPTED)";
    print "    err = " rpc " (" arglist ");";
    print "  return err;"
    print "}";
    print "weak_alias (" call ", " alias ")";
    print "libc_hidden_def (" call ")";
    # Declare RPC so the weak_alias that follows will work.
    print "extern __typeof (" call ") " rpc ";";
    echo = 1;
  }