Index: lib/libsysdecode/flags.c =================================================================== --- lib/libsysdecode/flags.c +++ lib/libsysdecode/flags.c @@ -81,10 +81,11 @@ }; #define X(a) { a, #a }, +#define Y(a, b) { a, #b }, #define XEND { 0, NULL } #define TABLE_START(n) static struct name_table n[] = { -#define TABLE_ENTRY X +#define TABLE_ENTRY Y #define TABLE_END XEND }; #include "tables.h" Index: lib/libsysdecode/mktables =================================================================== --- lib/libsysdecode/mktables +++ lib/libsysdecode/mktables @@ -78,7 +78,40 @@ if ($i ~ /define/) \ break; \ ++i; \ - printf "TABLE_ENTRY(%s)\n", $i }' + printf "TABLE_ENTRY(%s, %s)\n", $i, $i }' + fi +cat <<_EOF_ +TABLE_END + +_EOF_ +} + +linux_gen_table() +{ + local name grep file excl filter + name=$1 + grep=$2 + file=$3 + excl=$4 + + if [ -z "$excl" ]; then + filter="cat" + else + filter="egrep -v" + fi + cat <<_EOF_ +TABLE_START(${name}) +_EOF_ + if [ -e "${include_dir}/${file}" ]; then + all_headers="${all_headers:+${all_headers} }${file}" + egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \ + $include_dir/$file | ${filter} ${excl} | \ + awk '{ for (i = 1; i <= NF; i++) \ + if ($i ~ /define/) \ + break; \ + ++i; \ + sub(/LINUX_/, "", $i); \ + printf "TABLE_ENTRY(LINUX_%s, %s)\n", $i, $i }' fi cat <<_EOF_ TABLE_END