Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Apr 1999 18:34:16 +1000
From:      Peter Jeremy <peter.jeremy@auss2.alcatel.com.au>
To:        dillon@apollo.backplane.com
Cc:        andreas@klemm.gtn.com, freebsd-current@FreeBSD.ORG
Subject:   Re: different systat -vmstat output when using egcs to compile kernel
Message-ID:  <99Apr5.182120est.40328@border.alcanet.com.au>

next in thread | raw e-mail | index | archive | help
Matthew Dillon <dillon@apollo.backplane.com> wrote:
>:The problem is that cpp (from gcc 2.8.1) _does_not_ remove
>:backslash-newline sequences from string constants (and maybe elsewhere
>:as well).  This causes problems with the DEVICE_NAMES macro defined in
>:vector.h and used in vector.s.
...
>    I suggest using ANSI string constants instead of K&R string constants.
>
>    This is perfectly legal:
>
>	char *s = "abcdefghi";
>
>	char *s = "abc" "def" "ghi";
>
>	char *s = "abc"
>		  "def"
>		  "ghi";

Currently we have something like:
#define	DEVICE_NAMES "\
clk0 irqnn\0\
rtc0 irqnn\0\
pci irqnn\0\
pci irqnn\0\
pci irqnn\0\
"
	.ascii	DEVICE_NAMES

Which expands and assembles into something like:
000020:  5c 6e 63 6c 6b 30 20 69  72 71 6e 6e 00 5c 6e 72  |\nclk0 irqnn.\nr|
000030:  74 63 30 20 69 72 71 6e  6e 00 5c 6e 70 63 69 20  |tc0 irqnn.\npci |
000040:  69 72 71 6e 6e 00 5c 6e  70 63 69 20 69 72 71 6e  |irqnn.\npci irqn|

Surprisingly, ANSI-C string concatenation _does_ work in gas, so the
following works correctly:

#define	DEVICE_NAMES \
"clk0 irqnn\0" \
"rtc0 irqnn\0" \
"pci irqnn\0" \
"pci irqnn\0" \
"pci irqnn\0"
	.ascii	DEVICE_NAMES

This suggests that what's needed is a patch to config to make it
generate ANSI strings.  The following (untested) patch should do it:

Index: mkglue.c
===================================================================
RCS file: /home/CVSROOT/./src/usr.sbin/config/mkglue.c,v
retrieving revision 1.14
diff -u -r1.14 mkglue.c
--- mkglue.c	1998/04/02 04:25:39	1.14
+++ mkglue.c	1999/04/05 08:31:55
@@ -368,17 +368,17 @@
 	fprintf(fp, " * Macros for interrupt vector routines\n");
 	fprintf(fp, " * Generated by config program\n");
 	fprintf(fp, " */\n\n");
-	fprintf(fp, "#define\tDEVICE_NAMES \"\\\n");
-	fprintf(fp, "clk0 irqnn\\0\\\n");
-	fprintf(fp, "rtc0 irqnn\\0\\\n");
-	fprintf(fp, "pci irqnn\\0\\\n");
-	fprintf(fp, "pci irqnn\\0\\\n");
-	fprintf(fp, "pci irqnn\\0\\\n");
-	fprintf(fp, "pci irqnn\\0\\\n");
-	fprintf(fp, "ipi irqnn\\0\\\n");
-	fprintf(fp, "ipi irqnn\\0\\\n");
-	fprintf(fp, "ipi irqnn\\0\\\n");
-	fprintf(fp, "ipi irqnn\\0\\\n");
+	fprintf(fp, "#define\tDEVICE_NAMES \\\n");
+	fprintf(fp, "\"clk0 irqnn\\0\" \\\n");
+	fprintf(fp, "\"rtc0 irqnn\\0\" \\\n");
+	fprintf(fp, "\"pci irqnn\\0\" \\\n");
+	fprintf(fp, "\"pci irqnn\\0\" \\\n");
+	fprintf(fp, "\"pci irqnn\\0\" \\\n");
+	fprintf(fp, "\"pci irqnn\\0\" \\\n");
+	fprintf(fp, "\"ipi irqnn\\0\" \\\n");
+	fprintf(fp, "\"ipi irqnn\\0\" \\\n");
+	fprintf(fp, "\"ipi irqnn\\0\" \\\n");
+	fprintf(fp, "\"ipi irqnn\\0\" \\\n");
 	dev_id = 10;
 	vector_devtab(fp, "bio", &dev_id);
 	vector_devtab(fp, "tty", &dev_id);
@@ -386,7 +386,7 @@
 	vector_devtab(fp, "cam", &dev_id);
 	vector_devtab(fp, "ha", &dev_id);
 	vector_devtab(fp, "null", &dev_id);
-	fprintf(fp, "\"\n\n");
+	fprintf(fp, "\n");
 	fprintf(fp, "#define\tNR_DEVICES\t%d\n", dev_id);
 	(void) fclose(fp);
 	moveifchanged(path("vector.h.new"), path("vector.h"));
@@ -406,7 +406,7 @@
 		mp = dp->d_conn;
 		if (mp == NULL || mp == TO_NEXUS || !eq(mp->d_name, "isa"))
 			continue;
-		fprintf(fp, "%s%d irqnn\\0\\\n", dp->d_name, dp->d_unit);
+		fprintf(fp, "\"%s%d irqnn\\0\" \\\n", dp->d_name, dp->d_unit);
 		(*dev_idp)++;
 	}
 }


Peter


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?99Apr5.182120est.40328>