summaryrefslogtreecommitdiffstats
path: root/ffi.c
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-01-23 06:58:38 -0800
committerKaz Kylheku <kaz@kylheku.com>2019-01-23 06:58:38 -0800
commitb333ea2900a2e7c10d7b5cd35bf250c8e2d8d40f (patch)
treef0cd73c36dd467cefe1506326e6d0c23bda28a8d /ffi.c
parentf64d0bb5e0bfff833936d63849f86510a2328fee (diff)
downloadtxr-b333ea2900a2e7c10d7b5cd35bf250c8e2d8d40f.tar.gz
txr-b333ea2900a2e7c10d7b5cd35bf250c8e2d8d40f.tar.bz2
txr-b333ea2900a2e7c10d7b5cd35bf250c8e2d8d40f.zip
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.
Diffstat (limited to 'ffi.c')
-rw-r--r--ffi.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/ffi.c b/ffi.c
index 07e361ae..17936396 100644
--- a/ffi.c
+++ b/ffi.c
@@ -926,7 +926,7 @@ static val ffi_le_u32_get(struct txr_ffi_type *tft, mem_t *src, val self)
static void ffi_be_i64_put(struct txr_ffi_type *tft, val n,
mem_t *dst, val self)
{
-#if SIZEOF_PTR >= 8
+#if CHAR_BIT * SIZEOF_PTR >= 64
cnum v = c_num(n);
if (v < -convert(cnum, 0x7FFFFFFFFFFFFFFF - 1) || v > 0x7FFFFFFFFFFFFFFF)
@@ -964,7 +964,7 @@ range:
static val ffi_be_i64_get(struct txr_ffi_type *tft, mem_t *src, val self)
{
-#if SIZEOF_PTR >= 8
+#if CHAR_BIT * SIZEOF_PTR >= 64
cnum n = (convert(cnum, src[0]) << 56 | convert(cnum, src[1]) << 48 |
convert(cnum, src[2]) << 40 | convert(cnum, src[3]) << 32 |
convert(cnum, src[4]) << 24 | convert(cnum, src[5]) << 16 |
@@ -984,7 +984,7 @@ static val ffi_be_i64_get(struct txr_ffi_type *tft, mem_t *src, val self)
static void ffi_be_u64_put(struct txr_ffi_type *tft, val n,
mem_t *dst, val self)
{
-#if SIZEOF_PTR >= 8
+#if CHAR_BIT * SIZEOF_PTR >= 64
ucnum v = c_unum(n);
if (v > 0xFFFFFFFFFFFFFFFF)
@@ -1022,7 +1022,7 @@ range:
static val ffi_be_u64_get(struct txr_ffi_type *tft, mem_t *src, val self)
{
-#if SIZEOF_PTR >= 8
+#if CHAR_BIT * SIZEOF_PTR >= 64
ucnum n = (convert(ucnum, src[0]) << 56 | convert(ucnum, src[1]) << 48 |
convert(ucnum, src[2]) << 40 | convert(ucnum, src[3]) << 32 |
convert(ucnum, src[4]) << 24 | convert(ucnum, src[5]) << 16 |
@@ -1040,7 +1040,7 @@ static val ffi_be_u64_get(struct txr_ffi_type *tft, mem_t *src, val self)
static void ffi_le_i64_put(struct txr_ffi_type *tft, val n,
mem_t *dst, val self)
{
-#if SIZEOF_PTR >= 8
+#if CHAR_BIT * SIZEOF_PTR >= 64
cnum v = c_num(n);
if (v < -convert(cnum, 0x7FFFFFFFFFFFFFFF - 1) || v > 0x7FFFFFFFFFFFFFFF)
@@ -1078,7 +1078,7 @@ range:
static val ffi_le_i64_get(struct txr_ffi_type *tft, mem_t *src, val self)
{
-#if SIZEOF_PTR >= 8
+#if CHAR_BIT * SIZEOF_PTR >= 64
cnum n = (convert(cnum, src[7]) << 56 | convert(cnum, src[6]) << 48 |
convert(cnum, src[5]) << 40 | convert(cnum, src[4]) << 32 |
convert(cnum, src[3]) << 24 | convert(cnum, src[2]) << 16 |
@@ -1098,7 +1098,7 @@ static val ffi_le_i64_get(struct txr_ffi_type *tft, mem_t *src, val self)
static void ffi_le_u64_put(struct txr_ffi_type *tft, val n,
mem_t *dst, val self)
{
-#if SIZEOF_PTR >= 8
+#if CHAR_BIT * SIZEOF_PTR >= 64
ucnum v = c_unum(n);
if (v > 0xFFFFFFFFFFFFFFFF)
@@ -1136,7 +1136,7 @@ range:
static val ffi_le_u64_get(struct txr_ffi_type *tft, mem_t *src, val self)
{
-#if SIZEOF_PTR >= 8
+#if CHAR_BIT * SIZEOF_PTR >= 64
ucnum n = (convert(ucnum, src[7]) << 56 | convert(ucnum, src[6]) << 48 |
convert(ucnum, src[5]) << 40 | convert(ucnum, src[4]) << 32 |
convert(ucnum, src[3]) << 24 | convert(ucnum, src[2]) << 16 |