diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2019-01-23 06:58:38 -0800 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2019-01-23 06:58:38 -0800 |
commit | b333ea2900a2e7c10d7b5cd35bf250c8e2d8d40f (patch) | |
tree | f0cd73c36dd467cefe1506326e6d0c23bda28a8d /configure | |
parent | f64d0bb5e0bfff833936d63849f86510a2328fee (diff) | |
download | txr-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 'configure')
-rwxr-xr-x | configure | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1183,7 +1183,9 @@ read_syms() if [ -z "$intptr" ] ; then cat > conftest.c <<! #include <stddef.h> +#include <limits.h> #include "config.h" +char SIZEOF_BYTE[CHAR_BIT]; #ifdef HAVE_SUPERLONG_T char SIZEOF_SUPERLONG_T[sizeof (superlong_t)]; #endif @@ -1205,6 +1207,7 @@ char DUMMY; exit 1 fi + SIZEOF_BYTE=0 SIZEOF_PTR=0 SIZEOF_SHORT=0 SIZEOF_INT=0 @@ -1214,7 +1217,7 @@ char DUMMY; read_syms y - if [ $SIZEOF_PTR -eq 0 ] ; then + if [ $SIZEOF_PTR -eq 0 -o $SIZEOF_BYTE -eq 0 ] ; then printf "failed\n" exit 1 fi @@ -1238,7 +1241,7 @@ fi printf '"%s"\n' "$intptr" 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 * 8 - 2))) - 1) << 1) + 1)" +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 UINT_PTR_MAX (convert(uint_ptr_t, -1))\n" >> config.h @@ -2712,7 +2715,9 @@ file_offset_define=none for try in NOTHING _LARGE_FILES=1 _FILE_OFFSET_BITS=64 ; do cat > conftest.c <<! +#include <limits.h> #include <sys/types.h> +char SIZEOF_BYTE[CHAR_BIT]; char SIZEOF_OFF_T[sizeof (off_t)]; char DUMMY; ! @@ -2724,16 +2729,17 @@ char DUMMY; exit 1 fi + SIZEOF_BYTE=0 SIZEOF_OFF_T=0 read_syms - if [ $SIZEOF_OFF_T -eq 0 ] ; then + if [ $SIZEOF_OFF_T -eq 0 -o $SIZEOF_BYTE -eq 0 ] ; then printf "failed\n" exit 1 fi - if [ $SIZEOF_OFF_T -eq 8 ] ; then + if [ $(( SIZEOF_BYTE * SIZEOF_OFF_T )) -eq 64 ] ; then if [ $try = NOTHING ] ; then printf "default\n" file_offset_define= |