blob: 1d61824254a16f754f650c370a3023f6733ecd50 (
plain)
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
|
#!/usr/bin/gawk -f
BEGIN {
print "/* DO NOT EDIT: AUTOMATICALLY GENERATED"
print " * Input files: bootrom-asm-offsets.awk bootrom-asm-offsets.c.in"
print " * DO NOT EDIT: AUTOMATICALLY GENERATED"
print " */"
print ""
system("cat bootrom-asm-offsets.c.in")
print "{"
}
{
/* find a structure definition */
if ($0 ~ /typedef struct .* {/) {
delete members;
i = 0;
/* extract each member of the structure */
while (1) {
getline
if ($1 == "}")
break;
gsub(/[*;]/, "");
members[i++] = $NF;
}
/* grab the structure's name */
struct = $NF;
sub(/;$/, "", struct);
/* output the DEFINE() macros */
while (i-- > 0)
print "\tDEFINE(" struct ", " members[i] ");"
print ""
}
}
END {
print "\treturn 0;"
print "}"
}
|