[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 18/25: More long integer fixes for x86_64-w64-mingw32
From: |
Mike Gran |
Subject: |
[Guile-commits] 18/25: More long integer fixes for x86_64-w64-mingw32 |
Date: |
Thu, 10 Nov 2022 18:06:18 -0500 (EST) |
mike121 pushed a commit to branch wip-mingw
in repository guile.
commit 9a29293a88bd884a160ba84f06b8323335e0b039
Author: Michael Gran <spk121@yahoo.com>
AuthorDate: Mon Nov 7 21:57:45 2022 -0800
More long integer fixes for x86_64-w64-mingw32
* libguile/gc.c (scm_object_address): use uintptr_t instead of ulong
* libguile/gen-scmconfig.c (main): handle different sizes of scm_off_t
* libguile/integers.c (scm_integer_length_z): the mask size is bitcnt_max,
not UINTPTR_MAX
* libguile/ports.c (scm_set_port_line_x): test that line is an intptr_t,
not a long
* libguile/srfi-60.c (scm_srfi60_rotate_bit_fields): use correct size of
integer for bit-shifting
(scm_srfi60_reverse_bit_field): use correct integer size for bit-shifting
* libguile/symbols.h (scm_i_symbol_hash): cast to uintptr_t, not unsigned
long
---
libguile/gc.c | 2 +-
libguile/gen-scmconfig.c | 14 +++++++++-----
libguile/integers.c | 3 ++-
libguile/ports.c | 2 +-
libguile/srfi-60.c | 12 +++++++-----
libguile/symbols.h | 2 +-
6 files changed, 21 insertions(+), 14 deletions(-)
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))
- [Guile-commits] 12/25: DRAFT Add partial `scm_fcntl' support for MinGW., (continued)
- [Guile-commits] 12/25: DRAFT Add partial `scm_fcntl' support for MinGW., Mike Gran, 2022/11/10
- [Guile-commits] 14/25: REMOVEME mingw: Hardcode compile-time-file-name-convention to 'mingw., Mike Gran, 2022/11/10
- [Guile-commits] 15/25: REMOVEME guix: guile-mingw: Hardcode file-name-convention., Mike Gran, 2022/11/10
- [Guile-commits] 16/25: DEBUG guile.cmd, wine-guile.sh: Some Wine help., Mike Gran, 2022/11/10
- [Guile-commits] 05/25: Support for x86_64-w64-mingw32., Mike Gran, 2022/11/10
- [Guile-commits] 07/25: Fix 'absolute-file-name?' and others for cross-build to MinGW., Mike Gran, 2022/11/10
- [Guile-commits] 13/25: guix: Add guile-patched, guile-mingw., Mike Gran, 2022/11/10
- [Guile-commits] 19/25: For MinGW, use native signal func in sigaction, Mike Gran, 2022/11/10
- [Guile-commits] 22/25: Revert "Fix 'absolute-file-name?' and others for cross-build to MinGW.", Mike Gran, 2022/11/10
- [Guile-commits] 17/25: MinGW 64: fixes hash out-of-range error for 64-bit negative numbers, Mike Gran, 2022/11/10
- [Guile-commits] 18/25: More long integer fixes for x86_64-w64-mingw32,
Mike Gran <=
- [Guile-commits] 20/25: Revert "REMOVEME mingw: Hardcode compile-time-file-name-convention to 'mingw.", Mike Gran, 2022/11/10
- [Guile-commits] 24/25: Avoids sign extension error in bytevector construction, Mike Gran, 2022/11/10
- [Guile-commits] 25/25: Avoid mysterious "error no error" message in pipe, Mike Gran, 2022/11/10