Fix incorrect blocksize calculation on Win64
authorKyrill Briantsev <kyrab@mail.ru>
Wed, 12 Mar 2014 19:31:21 +0000 (14:31 -0500)
committerAustin Seipp <austin@well-typed.com>
Thu, 13 Mar 2014 22:56:36 +0000 (17:56 -0500)
Fixes #8839

Signed-off-by: Austin Seipp <austin@well-typed.com>
includes/rts/storage/Block.h

index 5567bf4..29c081b 100644 (file)
@@ -9,16 +9,26 @@
 #ifndef RTS_STORAGE_BLOCK_H
 #define RTS_STORAGE_BLOCK_H
 
+#include "ghcconfig.h"
+
 /* The actual block and megablock-size constants are defined in
  * includes/Constants.h, all constants here are derived from these.
  */
 
 /* Block related constants (BLOCK_SHIFT is defined in Constants.h) */
 
+#if SIZEOF_LONG == SIZEOF_VOID_P
+#define UNIT 1UL
+#elif SIZEOF_LONG_LONG == SIZEOF_VOID_P
+#define UNIT 1ULL
+#else
+#error "Size of pointer is suspicious."
+#endif
+
 #ifdef CMINUSMINUS
 #define BLOCK_SIZE   (1<<BLOCK_SHIFT)
 #else
-#define BLOCK_SIZE   (1UL<<BLOCK_SHIFT)
+#define BLOCK_SIZE   (UNIT<<BLOCK_SHIFT)
 // Note [integer overflow]
 #endif
 
@@ -33,7 +43,7 @@
 #ifdef CMINUSMINUS
 #define MBLOCK_SIZE    (1<<MBLOCK_SHIFT)
 #else
-#define MBLOCK_SIZE    (1UL<<MBLOCK_SHIFT)
+#define MBLOCK_SIZE    (UNIT<<MBLOCK_SHIFT)
 // Note [integer overflow]
 #endif