diff --git a/libguile/gc.c b/libguile/gc.c index 7717e9bef..bb2bcc72b 100644 --- a/libguile/gc.c +++ b/libguile/gc.c @@ -211,7 +211,7 @@ SCM_DEFINE (scm_object_address, "object-address", 1, 0, 0, "returned by this function for @var{obj}") #define FUNC_NAME s_scm_object_address { - return scm_from_ulong (SCM_UNPACK (obj)); + return scm_from_uintptr_t (SCM_UNPACK (obj)); } #undef FUNC_NAME diff --git a/libguile/gen-scmconfig.c b/libguile/gen-scmconfig.c index 4525455b6..098ef5066 100644 --- a/libguile/gen-scmconfig.c +++ b/libguile/gen-scmconfig.c @@ -325,14 +325,18 @@ main (int argc, char *argv[]) pf ("typedef int64_t scm_t_off;\n"); pf ("#define SCM_T_OFF_MAX INT64_MAX\n"); pf ("#define SCM_T_OFF_MIN INT64_MIN\n"); -#elif SIZEOF_OFF_T == SIZEOF_INT - pf ("typedef int scm_t_off;\n"); - pf ("#define SCM_T_OFF_MAX INT_MAX\n"); - pf ("#define SCM_T_OFF_MIN INT_MIN\n"); -#else +#elif SIZEOF_OFF_T == SIZEOF_LONG pf ("typedef long int scm_t_off;\n"); pf ("#define SCM_T_OFF_MAX LONG_MAX\n"); pf ("#define SCM_T_OFF_MIN LONG_MIN\n"); +#elif SIZEOF_OFF_T == SIZEOF_LONG_LONG + pf ("typedef long long int scm_t_off;\n"); + pf ("#define SCM_T_OFF_MAX LONG_LONG_MAX\n"); + pf ("#define SCM_T_OFF_MIN LONG_LONG_MIN\n"); +#else + pf ("typedef int scm_t_off;\n"); + pf ("#define SCM_T_OFF_MAX INT_MAX\n"); + pf ("#define SCM_T_OFF_MIN INT_MIN\n"); #endif pf ("/* Define to 1 if the compiler supports the " diff --git a/libguile/integers.c b/libguile/integers.c index dca15d5d3..778729777 100644 --- a/libguile/integers.c +++ b/libguile/integers.c @@ -2599,8 +2599,9 @@ scm_integer_length_z (struct scm_bignum *n) mpz_t zn; alias_bignum_to_mpz (n, zn); size_t size = mpz_sizeinbase (zn, 2); + const mp_bitcnt_t bitcnt_max = (mp_bitcnt_t) ~ (mp_bitcnt_t) 0; /* If negative and no 0 bits above the lowest 1, adjust result. */ - if (mpz_sgn (zn) < 0 && mpz_scan0 (zn, mpz_scan1 (zn, 0)) == UINTPTR_MAX) + if (mpz_sgn (zn) < 0 && mpz_scan0 (zn, mpz_scan1 (zn, 0)) == bitcnt_max) size--; scm_remember_upto_here_1 (n); return scm_from_size_t (size); diff --git a/libguile/ports.c b/libguile/ports.c index be6b4bc67..534b5ab3a 100644 --- a/libguile/ports.c +++ b/libguile/ports.c @@ -3915,7 +3915,7 @@ SCM_DEFINE (scm_set_port_line_x, "set-port-line!", 2, 0, 0, { port = SCM_COERCE_OUTPORT (port); SCM_VALIDATE_OPENPORT (1, port); - scm_to_long (line); + scm_to_intptr_t (line); scm_port_position_set_line (SCM_PORT (port)->position, line); return SCM_UNSPECIFIED; } diff --git a/libguile/srfi-60.c b/libguile/srfi-60.c index 616ce074f..956d2568e 100644 --- a/libguile/srfi-60.c +++ b/libguile/srfi-60.c @@ -139,10 +139,11 @@ SCM_DEFINE (scm_srfi60_rotate_bit_field, "rotate-bit-field", 4, 0, 0, behavior when shifting negative numbers, we do all operations using unsigned values, and then convert to signed at the end. */ + const uintptr_t UL1 = 1UL; uintptr_t unn = nn; - uintptr_t below = unn & ((1UL << ss) - 1); /* below start */ - uintptr_t above = unn & ~((1UL << ee) - 1); /* above end */ - uintptr_t fmask = ((1UL << ww) - 1) << ss; /* field mask */ + uintptr_t below = unn & ((UL1 << ss) - 1); /* below start */ + uintptr_t above = unn & ~((UL1 << ee) - 1); /* above end */ + uintptr_t fmask = ((UL1 << ww) - 1) << ss; /* field mask */ uintptr_t ff = unn & fmask; /* field */ uintptr_t uresult = (above | ((ff << cc) & fmask) @@ -243,8 +244,9 @@ SCM_DEFINE (scm_srfi60_reverse_bit_field, "reverse-bit-field", 3, 0, 0, if (ee <= SCM_INTPTR_T_BIT-1) { /* all within a intptr_t */ - intptr_t smask = 1L << ss; - intptr_t emask = 1L << (ee-1); + intptr_t L1 = 1L; + intptr_t smask = L1 << ss; + intptr_t emask = L1 << (ee-1); for ( ; swaps > 0; swaps--) { intptr_t sbit = nn & smask; diff --git a/libguile/symbols.h b/libguile/symbols.h index e8bc3346f..4f0a0c121 100644 --- a/libguile/symbols.h +++ b/libguile/symbols.h @@ -31,7 +31,7 @@ #define scm_is_symbol(x) (SCM_HAS_TYP7 (x, scm_tc7_symbol)) -#define scm_i_symbol_hash(x) ((unsigned long) SCM_CELL_WORD_2 (x)) +#define scm_i_symbol_hash(x) ((uintptr_t) SCM_CELL_WORD_2 (x)) #define scm_i_symbol_is_interned(x) \ (!(SCM_CELL_WORD_0 (x) & SCM_I_F_SYMBOL_UNINTERNED))