shithub: mc

Download patch

ref: fb907237536db80a21dcb82d3eb11b880db4cfcb
parent: 95b8caa2f3679d450a19e9b62d8eacb70e51b073
author: Ori Bernstein <ori@eigenstate.org>
date: Fri Jan 22 16:10:42 EST 2016

Use uvlong.

	Format specifiers for precisely sized types are ugly.

--- a/6/asm.h
+++ b/6/asm.h
@@ -77,8 +77,8 @@
 	char isglobl;
 	char iscomdat;
 	union {
-		uint64_t npad;
-		uint64_t ival;
+		uvlong npad;
+		uvlong ival;
 		struct {
 			char *str;
 			char isextern;
--- a/6/gengas.c
+++ b/6/gengas.c
@@ -273,13 +273,13 @@
 	}
 }
 
-static void encodemin(FILE *fd, uint64_t val)
+static void encodemin(FILE *fd, uvlong val)
 {
 	size_t i, shift;
 	uint8_t b;
 
 	if (val < 128) {
-		fprintf(fd, "\t.byte %zd\n", val);
+		fprintf(fd, "\t.byte %llu\n", val);
 		return;
 	}
 
@@ -325,12 +325,12 @@
 	}
 	switch (b->type) {
 	case Btimin:	encodemin(fd, b->ival);	break;
-	case Bti8:	fprintf(fd, "\t.byte %zd\n", b->ival);	break;
-	case Bti16:	fprintf(fd, "\t.short %zd\n", b->ival);	break;
-	case Bti32:	fprintf(fd, "\t.long %zd\n", b->ival);	break;
-	case Bti64:	fprintf(fd, "\t.quad %zd\n", b->ival);	break;
+	case Bti8:	fprintf(fd, "\t.byte %llu\n", b->ival);	break;
+	case Bti16:	fprintf(fd, "\t.short %llu\n", b->ival);	break;
+	case Bti32:	fprintf(fd, "\t.long %llu\n", b->ival);	break;
+	case Bti64:	fprintf(fd, "\t.quad %llu\n", b->ival);	break;
 	case Btbytes:	writebytes(fd, b->bytes.buf, b->bytes.len);	break;
-	case Btpad:	fprintf(fd, "\t.fill %zd,1,0\n", b->npad);	break;
+	case Btpad:	fprintf(fd, "\t.fill %llu,1,0\n", b->npad);	break;
 	case Btref:	fprintf(fd, "\t.quad %s + %zd\n", b->ref.str, b->ref.off);	break;
 	case Btseq:
 		for (i = 0; i < b->seq.nsub; i++)
--- a/6/genp9.c
+++ b/6/genp9.c
@@ -280,13 +280,13 @@
 	}
 }
 
-static size_t encodemin(FILE *fd, uint64_t val, size_t off, char *lbl)
+static size_t encodemin(FILE *fd, uvlong val, size_t off, char *lbl)
 {
 	size_t i, shift, n;
 	uint8_t b;
 
 	if (val < 128) {
-		fprintf(fd, "\tDATA %s+%zd(SB)/1,$%zd //x\n", lbl, off, val);
+		fprintf(fd, "\tDATA %s+%zd(SB)/1,$%llu //x\n", lbl, off, val);
 		return 1;
 	}
 
@@ -317,15 +317,15 @@
 		return 0;
 	switch (b->type) {
 	case Bti8:
-		fprintf(fd, "\tDATA %s+%zd(SB)/1,$%zd\n", lbl, off+n, b->ival);
+		fprintf(fd, "\tDATA %s+%zd(SB)/1,$%llud\n", lbl, off+n, b->ival);
 		n += 1;
 		break;
 	case Bti16:
-		fprintf(fd, "\tDATA %s+%zd(SB)/2,$%zd\n", lbl, off+n, b->ival);
+		fprintf(fd, "\tDATA %s+%zd(SB)/2,$%llud\n", lbl, off+n, b->ival);
 		n += 2;
 		break;
 	case Bti32:
-		fprintf(fd, "\tDATA %s+%zd(SB)/4,$%zd\n", lbl, off+n, b->ival);
+		fprintf(fd, "\tDATA %s+%zd(SB)/4,$%llud\n", lbl, off+n, b->ival);
 		n += 4;
 		break;
 	case Bti64:
--- a/mk/c.mk
+++ b/mk/c.mk
@@ -9,7 +9,7 @@
 _LIBPATHS=$(addprefix -l, $(patsubst lib%.a,%,$(notdir $(DEPS)))) $(_PCLIBS)
 
 # yeah, I should probably remove -Werror, but it's nice for developing alone.
-CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-array-bounds -g -O0
+CFLAGS += -Wall -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -g -O0
 CFLAGS += -MMD -MP -MF .deps/$(subst /,-,$*).d
 
 LIB ?= $(INSTLIB)
--- a/parse/parse.h
+++ b/parse/parse.h
@@ -485,7 +485,7 @@
 
 Node *mkvoid(Srcloc loc);
 Node *mkbool(Srcloc l, int val);
-Node *mkint(Srcloc l, uint64_t val);
+Node *mkint(Srcloc l, uvlong val);
 Node *mkchar(Srcloc l, uint32_t val);
 Node *mkstr(Srcloc l, Str str);
 Node *mkfloat(Srcloc l, double flt);
@@ -501,7 +501,7 @@
 Ucon *mkucon(Srcloc l, Node *name, Type *ut, Type *uet);
 
 /* node util functions */
-uint64_t arraysz(Node *sz);
+uvlong arraysz(Node *sz);
 char *namestr(Node *name);
 char *lblstr(Node *n);
 char *declname(Node *n);