From b333ea2900a2e7c10d7b5cd35bf250c8e2d8d40f Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Wed, 23 Jan 2019 06:58:38 -0800 Subject: Fix some instances of 4 bytes = 32 bits assumption. * hash.c (equal_hash, eql_hash, cobj_eq_hash_op, hash_hash_op): Multiply object size by CHAR_BIT and switch on number of bits, rather than bytes. * sysif.c (off_t_num): Likewise. * arith.c, ffi.c, itypes.c, rand.c: In numerous #if directive, fix size tests from bytes to bits. * configure: in the test that detects integer types, and in the test for enabling large file offsets, detect one more variable from the system: the value of CHAR_BIT. This turns into SIZEOF_BYTE. We use that value instead of a hard-coded 8. --- sysif.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'sysif.c') diff --git a/sysif.c b/sysif.c index 43f8fe80..ccca25cf 100644 --- a/sysif.c +++ b/sysif.c @@ -1332,10 +1332,10 @@ static val crypt_wrap(val wkey, val wsalt) off_t off_t_num(val num, val self) { - switch (sizeof(off_t)) { - case 4: + switch (CHAR_BIT * sizeof(off_t)) { + case 32: return c_i32(num, self); - case 8: + case 64: return c_i64(num, self); default: internal_error("portme: unsupported off_t size"); -- cgit v1.2.3