shithub: mc

Download patch

ref: 73531212e6534484b75862554930d3d448c16d9b
parent: ba0a58dbd10671aca9fb0df12ac47c42f0d58251
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Oct 31 21:02:46 EDT 2016

Use uvlong for all printing of sizes on 9front.

	size_t is weird on 9front, and things keep breaking.
	Let's just cast to a known correct format and not
	worry.

--- a/6/genp9.c
+++ b/6/genp9.c
@@ -107,7 +107,7 @@
 				spec == 'x' ||
 				spec == 'u');
 		if (l->reg.colour == Rnone)
-			fprintf(fd, "%%P.%zd%s", l->reg.id, modenames[l->mode]);
+			fprintf(fd, "%%P.%llu%s", (uvlong)l->reg.id, modenames[l->mode]);
 		else
 			fprintf(fd, "%s", regnames[l->reg.colour]);
 		break;
@@ -226,7 +226,7 @@
 	for (i = 0; i < sz; i++) {
 		len = min(sz - i, 8);
 		if (i % 8 == 0)
-			fprintf(fd, "\tDATA %s+%zd(SB)/%zd,$\"", name, off + i, len);
+			fprintf(fd, "\tDATA %s+%llu(SB)/%llu,$\"", name, (uvlong)off + i, (uvlong)len);
 		if (p[i] == '"' || p[i] == '\\')
 			fprintf(fd, "\\");
 		if (isprint(p[i]))
@@ -286,7 +286,7 @@
 	uint8_t b;
 
 	if (val < 128) {
-		fprintf(fd, "\tDATA %s+%zd(SB)/1,$%llu //x\n", lbl, off, val);
+		fprintf(fd, "\tDATA %s+%llu(SB)/1,$%u // single\n", lbl, (uvlong)off, (unsigned)val);
 		return 1;
 	}
 
@@ -298,11 +298,11 @@
 	shift = 8 - i;
 	b = ~0ull << (shift + 1);
 	b |= val & ~(~0ull << shift);
-	fprintf(fd, "\tDATA %s+%zd(SB)/1,$%u\n", lbl, off, b);
+	fprintf(fd, "\tDATA %s+%llu(SB)/1,$%u //first\n", lbl, (uvlong)off, b);
 	val >>=  shift;
 	while (val != 0) {
 		n++;
-		fprintf(fd, "\tDATA %s+%zd(SB)/1,$%u// y\n", lbl, off+n, (uint)val & 0xff);
+		fprintf(fd, "\tDATA %s+%llu(SB)/1,$%llu // tail\n", lbl, (uvlong)off+n, (uvlong)val & 0xff);
 		val >>= 8;
 	}
 	return i;
@@ -317,19 +317,19 @@
 		return 0;
 	switch (b->type) {
 	case Bti8:
-		fprintf(fd, "\tDATA %s+%zd(SB)/1,$%lld\n", lbl, off+n, b->ival);
+		fprintf(fd, "\tDATA %s+%llu(SB)/1,$%lld\n", lbl, (uvlong)off+n, b->ival);
 		n += 1;
 		break;
 	case Bti16:
-		fprintf(fd, "\tDATA %s+%zd(SB)/2,$%lld\n", lbl, off+n, b->ival);
+		fprintf(fd, "\tDATA %s+%llu(SB)/2,$%lld\n", lbl, (uvlong)off+n, b->ival);
 		n += 2;
 		break;
 	case Bti32:
-		fprintf(fd, "\tDATA %s+%zd(SB)/4,$%lld\n", lbl, off+n, b->ival);
+		fprintf(fd, "\tDATA %s+%llu(SB)/4,$%lld\n", lbl, (uvlong)off+n, b->ival);
 		n += 4;
 		break;
 	case Bti64:
-		fprintf(fd, "\tDATA %s+%zd(SB)/8,$%lld\n", lbl, off+n, (vlong)b->ival);
+		fprintf(fd, "\tDATA %s+%llu(SB)/8,$%lld\n", lbl, (uvlong)off+n, (vlong)b->ival);
 		n += 8;
 		break;
 	case Btimin:
@@ -337,11 +337,11 @@
 		break;
 	case Btref:
 		if (b->ref.isextern || b->ref.str[0] == '.')
-			fprintf(fd, "\tDATA %s+%zd(SB)/8,$%s+%zd(SB)\n",
-					lbl, off+n, b->ref.str, b->ref.off);
+			fprintf(fd, "\tDATA %s+%llu(SB)/8,$%s+%llu(SB)\n",
+					lbl, (uvlong)off+n, b->ref.str, (uvlong)b->ref.off);
 		else
-			fprintf(fd, "\tDATA %s+%zd(SB)/8,$%s<>+%zd(SB)\n",
-					lbl, off+n, b->ref.str, b->ref.off);
+			fprintf(fd, "\tDATA %s+%llu(SB)/8,$%s<>+%llu(SB)\n",
+					lbl, (uvlong)off+n, b->ref.str, (uvlong)b->ref.off);
 		n += 8;
 		break;
 	case Btbytes:
@@ -353,7 +353,7 @@
 		break;
 	case Btpad:
 		for (i = 0; i < b->npad; i++)
-			fprintf(fd, "\tDATA %s+%zd(SB)/1,$0\n", lbl, off+n+i);
+			fprintf(fd, "\tDATA %s+%llu(SB)/1,$0\n", lbl, (uvlong)off+n+i);
 		n += b->npad;
 		break;
 	}
@@ -397,10 +397,10 @@
 	if (!b)
 		return;
 	if (b->isglobl) {
-		fprintf(fd, "GLOBL %s%s+0(SB),$%zd\n", Symprefix, b->lbl, blobsz(b));
+		fprintf(fd, "GLOBL %s%s+0(SB),$%llu\n", Symprefix, b->lbl, (uvlong)blobsz(b));
 		bprintf(lbl, sizeof lbl, "%s%s", Symprefix, b->lbl);
 	} else {
-		fprintf(fd, "GLOBL %s%s<>+0(SB),$%zd\n", Symprefix, b->lbl, blobsz(b));
+		fprintf(fd, "GLOBL %s%s<>+0(SB),$%llu\n", Symprefix, b->lbl, (uvlong)blobsz(b));
 		bprintf(lbl, sizeof lbl, "%s%s<>", Symprefix, b->lbl);
 	}
 	writeblob(fd, b, 0, lbl);
@@ -432,7 +432,7 @@
 	assert(blob->type == Ndecl);
 
 	lbl = htget(globls, blob);
-	fprintf(fd, "GLOBL %s+0(SB),$%zd\n", lbl, size(blob));
+	fprintf(fd, "GLOBL %s+0(SB),$%llu\n", lbl, (uvlong)size(blob));
 	if (blob->decl.init)
 		b = litblob(globls, strtab, blob->decl.init);
 	else