summaryrefslogtreecommitdiffstats
path: root/usr.bin/kdump/mksubr
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/kdump/mksubr')
-rw-r--r--usr.bin/kdump/mksubr30
1 files changed, 30 insertions, 0 deletions
diff --git a/usr.bin/kdump/mksubr b/usr.bin/kdump/mksubr
index 1e9825a..8cf4f94 100644
--- a/usr.bin/kdump/mksubr
+++ b/usr.bin/kdump/mksubr
@@ -96,6 +96,36 @@ cat <<_EOF_
_EOF_
}
+#
+# Automatically generates a C function used when the argument
+# maps to a #definition
+#
+auto_if_type () {
+ local name grep file
+ name=$1
+ grep=$2
+ file=$3
+
+ cat <<_EOF_
+/* AUTO */
+void
+$name (int arg)
+{
+_EOF_
+ egrep "^#[[:space:]]*define[[:space:]]+"${grep}"[[:space:]]*" \
+ $include_dir/$file | \
+ awk '{ printf "\t"; \
+ if (NR > 1) \
+ printf "else " ; \
+ printf "if (arg == %s) \n\t\tprintf(\"%s\");\n", $2, $2 }'
+cat <<_EOF_
+ else /* Should not reach */
+ (void)printf("<invalid=%ld>", (long)arg);
+}
+
+_EOF_
+}
+
# C start
cat <<_EOF_
OpenPOWER on IntegriCloud