summary refs log tree commit diff
path: root/scripts/gen-as-const.awk
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-12-27 23:05:53 +0000
committerRoland McGrath <roland@gnu.org>2002-12-27 23:05:53 +0000
commitaad08dbad983a352492542a61478074e5869dec6 (patch)
treea834bf94b853e8ac0331bbf0eed8e4862c44ff38 /scripts/gen-as-const.awk
parent4f172c25f1c39e86b433075d36f3e6c19e06f136 (diff)
downloadglibc-aad08dbad983a352492542a61478074e5869dec6.tar.gz
glibc-aad08dbad983a352492542a61478074e5869dec6.tar.xz
glibc-aad08dbad983a352492542a61478074e5869dec6.zip
2002-12-27 Roland McGrath <roland@redhat.com>
	* scripts/gen-as-const.awk: New file.
	* Makefile (distribute): Add it.
	* Makerules ($(common-objpfx)%.h %.h.d: %.sym): New pattern rule.
	(before-compile): Add $(gen-as-const-headers:%.sym=$(common-objpfx)%.h)
	to the list.
	(+depfiles): Add $(addprefix $(common-objpfx),$(gen-as-const-headers)).
Diffstat (limited to 'scripts/gen-as-const.awk')
-rw-r--r--scripts/gen-as-const.awk29
1 files changed, 29 insertions, 0 deletions
diff --git a/scripts/gen-as-const.awk b/scripts/gen-as-const.awk
new file mode 100644
index 0000000000..b29656ee71
--- /dev/null
+++ b/scripts/gen-as-const.awk
@@ -0,0 +1,29 @@
+# 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 {
+  print "void dummy(void) {";
+  started = 1;
+}
+
+NF == 1 { sub(/^.*$/, "& &"); }
+
+NF > 1 {
+  name = $1;
+  sub(/^[^ 	]+[ 	]+/, "");
+  printf "asm (\"@@@name@@@%s@@@value@@@%%0@@@end@@@\" : : \"i\" (%s));\n",
+    name, $0;
+}
+
+END { if (started) print "}" }