diff --git a/m4/gen_bpf_attr_m4.awk b/m4/gen_bpf_attr_m4.awk new file mode 100644 index 00000000..5896369f --- /dev/null +++ b/m4/gen_bpf_attr_m4.awk @@ -0,0 +1,28 @@ +/^struct ([^[:space:]]+)_struct([[:space:]]+\/\* ([^[:space:]]+) \*\/)?[[:space:]]+{/ { + match($0, /^struct ([^[:space:]]+)_struct([[:space:]]+\/\* ([^[:space:]]+) \*\/)?[[:space:]]+{/, a) + + struct_name = a[1] + subtype_name = a[3] + + if (struct_name ~ /^BPF_/) + prefix = "union bpf_attr" + else + prefix = "struct " struct_name + + if (subtype_name != "") + prefix = prefix "." subtype_name + + in_struct = 1 + next +} + +/^}( ATTRIBUTE_ALIGNED\(.*\))?;/ { + in_struct = 0 + next +} + +(in_struct == 1) { + if (match($0, /^[[:space:]]+[^;\[\]]+[[:space:]]+([^[:space:]\[\];]+)(\[[^;]*\])?;$/, a)) { + print "\t\t" prefix "." a[1] "," + } +} diff --git a/m4/gen_bpf_attr_m4.sh b/m4/gen_bpf_attr_m4.sh index 313b9093..ad620ce4 100755 --- a/m4/gen_bpf_attr_m4.sh +++ b/m4/gen_bpf_attr_m4.sh @@ -34,36 +34,7 @@ AC_DEFUN([st_BPF_ATTR], [dnl AC_CHECK_MEMBERS(m4_normalize([ EOF -gawk -e ' -/^struct ([^[:space:]]+)_struct([[:space:]]+\/\* ([^[:space:]]+) \*\/)?[[:space:]]+{/ { - match($0, /^struct ([^[:space:]]+)_struct([[:space:]]+\/\* ([^[:space:]]+) \*\/)?[[:space:]]+{/, a) - - struct_name = a[1] - subtype_name = a[3] - - if (struct_name ~ /^BPF_/) - prefix = "union bpf_attr" - else - prefix = "struct " struct_name - - if (subtype_name != "") - prefix = prefix "." subtype_name - - in_struct = 1 - next -} - -/^}( ATTRIBUTE_ALIGNED\(.*\))?;/ { - in_struct = 0 - next -} - -(in_struct == 1) { - if (match($0, /^[[:space:]]+[^;\[\]]+[[:space:]]+([^[:space:]\[\];]+)(\[[^;]*\])?;$/, a)) { - print "\t\t" prefix "." a[1] "," - } -} -' < "$input" | sort -u +gawk -f "${0%/*}"/gen_bpf_attr_m4.awk < "$input" | sort -u cat <<'EOF' union bpf_attr.dummy