summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormiod <miod@openbsd.org>2001-09-16 14:26:35 +0000
committermiod <miod@openbsd.org>2001-09-16 14:26:35 +0000
commit95d9f500c2b83cd00b443a003d0c4c175cdc6457 (patch)
tree0a56c419b165298d87cabf5246d1d65371ed3e5c
parentreturn 0, not NULL, the function returns an int (diff)
downloadwireguard-openbsd-95d9f500c2b83cd00b443a003d0c4c175cdc6457.tar.xz
wireguard-openbsd-95d9f500c2b83cd00b443a003d0c4c175cdc6457.zip
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.
-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;
}