Skip to content

Commit 5c48173

Browse files
esyrldv-alt
authored andcommitted
m4: move the gawk script from m4/gen_bpf_attr_m4.sh into a separate file
As it turns out, old versions of gawk do not support -e option. * m4/gen_bpf_attr_m4.sh: Move the gawk script ... * m4/gen_bpf_attr_m4.awk: ... here.
1 parent 514a667 commit 5c48173

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

m4/gen_bpf_attr_m4.awk

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/^struct ([^[:space:]]+)_struct([[:space:]]+\/\* ([^[:space:]]+) \*\/)?[[:space:]]+{/ {
2+
match($0, /^struct ([^[:space:]]+)_struct([[:space:]]+\/\* ([^[:space:]]+) \*\/)?[[:space:]]+{/, a)
3+
4+
struct_name = a[1]
5+
subtype_name = a[3]
6+
7+
if (struct_name ~ /^BPF_/)
8+
prefix = "union bpf_attr"
9+
else
10+
prefix = "struct " struct_name
11+
12+
if (subtype_name != "")
13+
prefix = prefix "." subtype_name
14+
15+
in_struct = 1
16+
next
17+
}
18+
19+
/^}( ATTRIBUTE_ALIGNED\(.*\))?;/ {
20+
in_struct = 0
21+
next
22+
}
23+
24+
(in_struct == 1) {
25+
if (match($0, /^[[:space:]]+[^;\[\]]+[[:space:]]+([^[:space:]\[\];]+)(\[[^;]*\])?;$/, a)) {
26+
print "\t\t" prefix "." a[1] ","
27+
}
28+
}

m4/gen_bpf_attr_m4.sh

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,36 +34,7 @@ AC_DEFUN([st_BPF_ATTR], [dnl
3434
AC_CHECK_MEMBERS(m4_normalize([
3535
EOF
3636

37-
gawk -e '
38-
/^struct ([^[:space:]]+)_struct([[:space:]]+\/\* ([^[:space:]]+) \*\/)?[[:space:]]+{/ {
39-
match($0, /^struct ([^[:space:]]+)_struct([[:space:]]+\/\* ([^[:space:]]+) \*\/)?[[:space:]]+{/, a)
40-
41-
struct_name = a[1]
42-
subtype_name = a[3]
43-
44-
if (struct_name ~ /^BPF_/)
45-
prefix = "union bpf_attr"
46-
else
47-
prefix = "struct " struct_name
48-
49-
if (subtype_name != "")
50-
prefix = prefix "." subtype_name
51-
52-
in_struct = 1
53-
next
54-
}
55-
56-
/^}( ATTRIBUTE_ALIGNED\(.*\))?;/ {
57-
in_struct = 0
58-
next
59-
}
60-
61-
(in_struct == 1) {
62-
if (match($0, /^[[:space:]]+[^;\[\]]+[[:space:]]+([^[:space:]\[\];]+)(\[[^;]*\])?;$/, a)) {
63-
print "\t\t" prefix "." a[1] ","
64-
}
65-
}
66-
' < "$input" | sort -u
37+
gawk -f "${0%/*}"/gen_bpf_attr_m4.awk < "$input" | sort -u
6738

6839
cat <<'EOF'
6940
union bpf_attr.dummy

0 commit comments

Comments
 (0)