summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2007-10-04 05:49:17 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2007-10-04 05:49:17 +0000
commit460f0dff62c18b8443e0faafeac6abb8444655b6 (patch)
tree4705d210730024641426ba9dfe298cdf4ce337cf
parent8a424acd97d08152eae9a261c0b9ef2abce82541 (diff)
fix evil 64-bit bug: if we're using longs for bitsets 1 << shift will
be undefined if shift > 31. Makes ccom work much better on 64-bit archs.
-rw-r--r--usr.bin/pcc/mip/mkext.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/pcc/mip/mkext.c b/usr.bin/pcc/mip/mkext.c
index 555e3ba7551..efc0329757b 100644
--- a/usr.bin/pcc/mip/mkext.c
+++ b/usr.bin/pcc/mip/mkext.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mkext.c,v 1.4 2007/09/24 16:04:01 otto Exp $ */
+/* $OpenBSD: mkext.c,v 1.5 2007/10/04 05:49:16 otto Exp $ */
/*
* Generate defines for the needed hardops.
*/
@@ -118,11 +118,14 @@ main(int argc, char *argv[])
}
fprintf(fh, "#define NUMBITS %d\n", bitsz);
fprintf(fh, "#define BITSET(arr, bit) "
- "(arr[bit/NUMBITS] |= (1 << (bit & (NUMBITS-1))))\n");
+ "(arr[bit/NUMBITS] |= ((%s)1 << (bit & (NUMBITS-1))))\n",
+ bitary);
fprintf(fh, "#define BITCLEAR(arr, bit) "
- "(arr[bit/NUMBITS] &= ~(1 << (bit & (NUMBITS-1))))\n");
+ "(arr[bit/NUMBITS] &= ~((%s)1 << (bit & (NUMBITS-1))))\n",
+ bitary);
fprintf(fh, "#define TESTBIT(arr, bit) "
- "(arr[bit/NUMBITS] & (1 << (bit & (NUMBITS-1))))\n");
+ "(arr[bit/NUMBITS] & ((%s)1 << (bit & (NUMBITS-1))))\n",
+ bitary);
fprintf(fh, "typedef %s bittype;\n", bitary);
/* register class definitions, used by graph-coloring */