summaryrefslogtreecommitdiffstats
path: root/configure
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2019-05-25 22:03:54 -0700
committerKaz Kylheku <kaz@kylheku.com>2019-05-25 22:03:54 -0700
commit11b5c567124a61d8e8249a0fbcce47f2688573c6 (patch)
treec21798c867abd4d55c12f2e75edcabcd24672ee6 /configure
parent3e1f28aacb7fdf1d6e1558cc4ca26efb1443619c (diff)
downloadtxr-11b5c567124a61d8e8249a0fbcce47f2688573c6.tar.gz
txr-11b5c567124a61d8e8249a0fbcce47f2688573c6.tar.bz2
txr-11b5c567124a61d8e8249a0fbcce47f2688573c6.zip
bugfix: c_num won't convert most negative value.
This bug causes a problem particularly in FFI. THe conversion of an integer to the FFI int type begins by conversion via c_num to the cnum type, which is at least as wide as int. Alas, the INT_MIN value (e.g. #x-80000000 on 32 bits) will not convert! Fixing this has a ripple effect. We alter the INT_PTR_MIN constant to include this value. This causes the derived NUM_MIN to also include the extra negative value, extending the fixnum range by one value. Everything seems to be okay. * configure: Decrease value of INT_PTR_MIN and DOUBLE_INTPTR_MIN constants by one to include the most negative two's complement value. * ffi.c (make_ffi_type_enum): We must not subtract 1 from INT_PTR_MIN here any more. * mpi.c (mp_in_range): If the bignum is negative, then extend the range check by one value, so that we don't reject the most negative two's complement value.
Diffstat (limited to 'configure')
-rwxr-xr-xconfigure4
1 files changed, 2 insertions, 2 deletions
diff --git a/configure b/configure
index 8ee672b4..064ea3ee 100755
--- a/configure
+++ b/configure
@@ -1256,12 +1256,12 @@ printf "typedef $intptr int_ptr_t;\n" >> config.h
printf "typedef unsigned $intptr uint_ptr_t;\n" >> config.h
intptr_max_expr="((((convert(int_ptr_t, 1) << $((SIZEOF_PTR * SIZEOF_BYTE - 2))) - 1) << 1) + 1)"
printf "#define INT_PTR_MAX %s\n" "$intptr_max_expr" >> config.h
-printf "#define INT_PTR_MIN (-INT_PTR_MAX)\n" >> config.h
+printf "#define INT_PTR_MIN (-INT_PTR_MAX-1)\n" >> config.h
printf "#define UINT_PTR_MAX (convert(uint_ptr_t, -1))\n" >> config.h
double_intptr_max_expr="((((convert(double_intptr_t, 1) << $((2 * SIZEOF_PTR * SIZEOF_BYTE - 2))) - 1) << 1) + 1)"
printf "#define SIZEOF_DOUBLE_INTPTR (2*SIZEOF_PTR)\n" >> config.h
printf "#define DOUBLE_INTPTR_MAX %s\n" "$double_intptr_max_expr" >> config.h
-printf "#define DOUBLE_INTPTR_MIN (-DOUBLE_INTPTR_MAX)\n" >> config.h
+printf "#define DOUBLE_INTPTR_MIN (-DOUBLE_INTPTR_MAX-1)\n" >> config.h
printf "#define DOUBLE_UINTPTR_MAX (convert(double_uintptr_t, -1))\n" >> config.h
if [ -n "$longlong" ] && [ $SIZEOF_LONGLONG_T -eq $(( 2 * SIZEOF_PTR )) ]