summaryrefslogtreecommitdiff
path: root/extra/scripts/gen-as-const.awk
diff options
context:
space:
mode:
authorKhem Raj <kraj@mvista.com>2008-12-31 00:31:38 +0000
committerKhem Raj <kraj@mvista.com>2008-12-31 00:31:38 +0000
commit15a971616c3e2f373264d0a2e4cd87aa11042737 (patch)
treede7759a5bfcc0548b63e7d289fd1829aba6dad48 /extra/scripts/gen-as-const.awk
parente422845f587db4139bd72fd3ae827ae91420855a (diff)
Merge some pre-work from branch, needed by NPTL.
Diffstat (limited to 'extra/scripts/gen-as-const.awk')
-rw-r--r--extra/scripts/gen-as-const.awk33
1 files changed, 33 insertions, 0 deletions
diff --git a/extra/scripts/gen-as-const.awk b/extra/scripts/gen-as-const.awk
new file mode 100644
index 000000000..f9ec31672
--- /dev/null
+++ b/extra/scripts/gen-as-const.awk
@@ -0,0 +1,33 @@
+# Script used in producing headers of assembly constants from C expressions.
+# The input to this script looks like:
+# #cpp-directive ...
+# NAME1
+# NAME2 expression ...
+# The output of this script is C code to be run through gcc -S and then
+# massaged to extract the integer constant values of the given C expressions.
+# A line giving just a name implies an expression consisting of just that name.
+
+BEGIN { started = 0 }
+
+# cpp directives go straight through.
+/^#/ { print; next }
+
+NF >= 1 && !started {
+ printf "void dummy(void);\n";
+ print "void dummy(void) {";
+ started = 1;
+}
+
+# Separator.
+$1 == "--" { next }
+
+NF == 1 { sub(/^.*$/, "& &"); }
+
+NF > 1 {
+ name = $1;
+ sub(/^[^ ]+[ ]+/, "");
+ printf "__asm__ (\"@@@name@@@%s@@@value@@@%%0@@@end@@@\" : : \"i\" (%s));\n",
+ name, $0;
+}
+
+END { if (started) print "}" }