summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2001-09-16 14:26:36 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2001-09-16 14:26:36 +0000
commit49a14902da86781825ac385de7568f436e8d1482 (patch)
treeece29f34cb093ffc22da730d809a54c30ad48083 /sys/kern
parentfef6b0388c91a0f98c12f4988b5391aa6624fe26 (diff)
Feature-sync with NetBSD (add the "config" keyword).
Allow multiple occurences of "struct foo". Add syntaxic sugar to make use of "struct" and "member" keywords more useful in genassym.cf files. This will be badly documented in a manpage, to come in a few minutes.
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/genassym.sh31
1 files changed, 25 insertions, 6 deletions
diff --git a/sys/kern/genassym.sh b/sys/kern/genassym.sh
index a4a60f64755..dd7e09482f3 100644
--- a/sys/kern/genassym.sh
+++ b/sys/kern/genassym.sh
@@ -1,5 +1,5 @@
-# $OpenBSD: genassym.sh,v 1.5 2001/09/11 18:26:10 miod Exp $
-# $NetBSD: genassym.sh,v 1.7 1997/06/25 03:09:06 thorpej Exp $
+# $OpenBSD: genassym.sh,v 1.6 2001/09/16 14:26:35 miod Exp $
+# $NetBSD: genassym.sh,v 1.9 1998/04/25 19:48:27 matthias Exp $
#
# Copyright (c) 1997 Matthias Pfaller.
@@ -50,6 +50,9 @@ BEGIN {
printf("#ifndef _KERNEL\n#define _KERNEL\n#endif\n");
printf("#define offsetof(type, member) ((size_t)(&((type *)0)->member))\n");
defining = 0;
+ type = "long";
+ asmtype = "n";
+ asmprint = "";
}
$0 ~ /^[ \t]*#.*/ || $0 ~ /^[ \t]*$/ {
@@ -57,6 +60,13 @@ $0 ~ /^[ \t]*#.*/ || $0 ~ /^[ \t]*$/ {
next;
}
+$0 ~ /^config[ \t]/ {
+ type = $2;
+ asmtype = $3;
+ asmprint = $4;
+ next;
+}
+
/^include[ \t]/ {
if (defining != 0) {
defining = 0;
@@ -81,12 +91,21 @@ $0 ~ /^endif/ {
/^struct[ \t]/ {
structname = $2;
- $0 = "define " structname "_SIZEOF sizeof(struct " structname ")";
+ prefixname = toupper($3);
+ if (struct[structname] == 1)
+ next;
+ else {
+ struct[structname] = 1;
+ $0 = "define " toupper(structname) "_SIZEOF sizeof(struct " structname ")";
+ }
# fall through
}
/^member[ \t]/ {
- $0 = "define " $2 " offsetof(struct " structname ", " $2 ")";
+ if (NF > 2)
+ $0 = "define " prefixname toupper($2) " offsetof(struct " structname ", " $3 ")";
+ else
+ $0 = "define " prefixname toupper($2) " offsetof(struct " structname ", " $2 ")";
# fall through
}
@@ -107,9 +126,9 @@ $0 ~ /^endif/ {
value = $0
gsub("^define[ \t]+[A-Za-z_][A-Za-z_0-9]*[ \t]+", "", value)
if (ccode)
- printf("printf(\"#define " $2 " %%ld\\n\", (long)" value ");\n");
+ printf("printf(\"#define " $2 " %%ld\\n\", (%s)" value ");\n", type);
else
- printf("__asm(\"XYZZY %s %%0\" : : \"n\" (%s));\n", $2, value);
+ printf("__asm(\"XYZZY %s %%%s0\" : : \"%s\" (%s));\n", $2, asmprint, asmtype, value);
next;
}