mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-28 14:00:31 +02:00
Support for x86_64-w64-mingw32.
On x86-64-MinGW the size of long is 4. As long is used for SCM_FIXNUM_BIT, that would mean incompatible .go files, and waste of cell space. So we would like to use long long, but the GMP interface uses long. To get around this, the x86-64-MinGW port now requires the use of mini-GMP. Mini-GMP has been changed to use intptr_t and uintptr_t. Likewise, "integers.{h,c}" and "numbers.{h,c}" now use intptr_t instead of scm_t_inum or long, and uintptr_t instead of unsigned long. * configure.ac: When x86_64-w64-mingw32, require mini-GMP. * libguile/mini-gmp.h: Use intptr_t instead of long, uintptr_t instead of unsigned long throughout. * libguile/mini-gmp.c: Likewise. * libguile/scm.h (SCM_INTPTR_T_BIT): New define. * libguile/numbers.h (SCM_FIXNUM_BIT): Use it. * libguile/numbers.c (L1, UL1): New macros. Use them thoughout instead of 1L, 1UL. (verify): Use SCM_INTPTR_T_BIT. (verify): Use SCM_INTPTR_T_MAX and SCM_INTPTR_T_MIN. (scm_from_inum): Remove macro. Use intptr_t and uintptr_t instead of scm_t_inum or long, and unsigned long. * libguile/numbers.h (scm_from_intptr, scm_from_uintptr, scm_to_intptr, scm_to_uintptr): New defines. * libguile/integers.h: Use intptr_t and uintptr_t instead of scm_t_inum and unsigned long. * libguile/integers.c (L1) : New macro. Use it thoughout instead of 1L. Use intptr_t and uintptr_t instead of long and unsigned long. (long_magnitude): Rename to... (intptr_t_magnitude): ...this. Use intptr_t, uintptr_t. (negative_long): Rename to... (negative_t_intptr): ...this. Use uintptr_t, INTPTR_MIN. (inum_magnitude): Use intptr_t. (ulong_to_bignum): Rename to... (uintptr_t_to_bignum): ...this. Use uintptr_t. (long_to_bignum): Rename to... (intptr_t_to_bignum): ...this. Use intptr_t. (long_to_scm): Rename to... (intptr_t_to_scm): ...this. Use intptr_to_bignum. (ulong_to_scm): Rename to... (uintptr_t_to_scm): ...this. Use uintptr_to_bignum. (long_sign): Rename to.. (intptr_t_sign): ...this. Use SCM_SIZEOF_INTPTR_T. (bignum_cmp_long): Rename to... (bignum_cmp_intptr_t): ...this. Use uintptr_t. * libguile/array-map.c (array_compare): Use uintptr_t instead of unsigned long and intptr_t instead of long. * libguile/arrays.c (make-shared-array): Use ssize_t instead of long. * libguile/bytevectors.c (is_signed_int32, is_unsigned_int32) [MINGW32 && __x86_64__]: Use ULL. (twos_complement): Use uintptr_t instead of unsigned long. * libguile/hash.c (JENKINS_LOOKUP3_HASHWORD2): Likewise. (narrow_string_hash, wide_string_hash, scm_i_string_hash, scm_i_locale_string_hash, scm_i_latin1_string_hash, scm_i_utf8_string_hash, scm_i_struct_hash, scm_raw_ihashq, scm_raw_ihash): Use and return uintptr_t instead of unsigned long. (scm_hashv, scm_hash): Use SCM_UINTPTR_T_MAX. * libguile/hash.h (scm_i_locale_string_hash, scm_i_latin1_string_hash, scm_i_utf8_string_hash): update prototypes. * libguile/scmsigs.c (sigaction): Use intptr_t instead of long. * libguile/strings.c (scm_i_make_symbol, (scm_i_c_make_symbol): Use uintptr_t instead of unsigned long. * libguile/strings.h (scm_i_make_symbol, (scm_i_c_make_symbol): Update declacations. * libguile/srfi-60.c: Use scm_to_uintptr, scm_from_intptr and variants throughout. * libguile/symbols.c (symbol-hash): Use scm_from_uintptr. Co-authored-by: Mike Gran <spk121@yahoo.com> Co-authored-by: Andy Wingo <wingo@pobox.com>
This commit is contained in:
parent
d58c9411ae
commit
76950b4281
19 changed files with 623 additions and 597 deletions
|
@ -112,31 +112,31 @@ extern double floor();
|
|||
the hash on a 64-bit system are equal to the hash on a 32-bit \
|
||||
system. The low 32 bits just add more entropy. */ \
|
||||
if (sizeof (ret) == 8) \
|
||||
ret = (((unsigned long) c) << 32) | b; \
|
||||
ret = (((uintptr_t) c) << 32) | b; \
|
||||
else \
|
||||
ret = c; \
|
||||
} while (0)
|
||||
|
||||
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
narrow_string_hash (const uint8_t *str, size_t len)
|
||||
{
|
||||
unsigned long ret;
|
||||
uintptr_t ret;
|
||||
JENKINS_LOOKUP3_HASHWORD2 (str, len, ret);
|
||||
ret >>= 2; /* Ensure that it fits in a fixnum. */
|
||||
return ret;
|
||||
}
|
||||
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
wide_string_hash (const scm_t_wchar *str, size_t len)
|
||||
{
|
||||
unsigned long ret;
|
||||
uintptr_t ret;
|
||||
JENKINS_LOOKUP3_HASHWORD2 (str, len, ret);
|
||||
ret >>= 2; /* Ensure that it fits in a fixnum. */
|
||||
return ret;
|
||||
}
|
||||
|
||||
unsigned long
|
||||
uintptr_t
|
||||
scm_i_string_hash (SCM str)
|
||||
{
|
||||
size_t len = scm_i_string_length (str);
|
||||
|
@ -148,13 +148,13 @@ scm_i_string_hash (SCM str)
|
|||
return wide_string_hash (scm_i_string_wide_chars (str), len);
|
||||
}
|
||||
|
||||
unsigned long
|
||||
uintptr_t
|
||||
scm_i_locale_string_hash (const char *str, size_t len)
|
||||
{
|
||||
return scm_i_string_hash (scm_from_locale_stringn (str, len));
|
||||
}
|
||||
|
||||
unsigned long
|
||||
uintptr_t
|
||||
scm_i_latin1_string_hash (const char *str, size_t len)
|
||||
{
|
||||
if (len == (size_t) -1)
|
||||
|
@ -164,11 +164,11 @@ scm_i_latin1_string_hash (const char *str, size_t len)
|
|||
}
|
||||
|
||||
/* A tricky optimization, but probably worth it. */
|
||||
unsigned long
|
||||
uintptr_t
|
||||
scm_i_utf8_string_hash (const char *str, size_t len)
|
||||
{
|
||||
const uint8_t *end, *ustr = (const uint8_t *) str;
|
||||
unsigned long ret;
|
||||
uintptr_t ret;
|
||||
|
||||
/* The length of the string in characters. This name corresponds to
|
||||
Jenkins' original name. */
|
||||
|
@ -219,8 +219,8 @@ scm_i_utf8_string_hash (const char *str, size_t len)
|
|||
|
||||
final (a, b, c);
|
||||
|
||||
if (sizeof (unsigned long) == 8)
|
||||
ret = (((unsigned long) c) << 32) | b;
|
||||
if (sizeof (uintptr_t) == 8)
|
||||
ret = (((uintptr_t) c) << 32) | b;
|
||||
else
|
||||
ret = c;
|
||||
|
||||
|
@ -228,16 +228,16 @@ scm_i_utf8_string_hash (const char *str, size_t len)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static unsigned long scm_raw_ihashq (scm_t_bits key);
|
||||
static unsigned long scm_raw_ihash (SCM obj, size_t depth);
|
||||
static uintptr_t scm_raw_ihashq (scm_t_bits key);
|
||||
static uintptr_t scm_raw_ihash (SCM obj, size_t depth);
|
||||
|
||||
/* Return the hash of struct OBJ. Traverse OBJ's fields to compute the
|
||||
result, unless DEPTH is zero. Assumes that OBJ is a struct. */
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
scm_i_struct_hash (SCM obj, size_t depth)
|
||||
{
|
||||
size_t struct_size, field_num;
|
||||
unsigned long hash;
|
||||
uintptr_t hash;
|
||||
|
||||
struct_size = SCM_STRUCT_SIZE (obj);
|
||||
|
||||
|
@ -257,7 +257,7 @@ scm_i_struct_hash (SCM obj, size_t depth)
|
|||
|
||||
/* Thomas Wang's integer hasher, from
|
||||
http://www.cris.com/~Ttwang/tech/inthash.htm. */
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
scm_raw_ihashq (scm_t_bits key)
|
||||
{
|
||||
if (sizeof (key) < 8)
|
||||
|
@ -283,7 +283,7 @@ scm_raw_ihashq (scm_t_bits key)
|
|||
}
|
||||
|
||||
/* `depth' is used to limit recursion. */
|
||||
static unsigned long
|
||||
static uintptr_t
|
||||
scm_raw_ihash (SCM obj, size_t depth)
|
||||
{
|
||||
if (SCM_IMP (obj))
|
||||
|
@ -318,7 +318,7 @@ scm_raw_ihash (SCM obj, size_t depth)
|
|||
{
|
||||
size_t len = SCM_SIMPLE_VECTOR_LENGTH (obj);
|
||||
size_t i = depth / 2;
|
||||
unsigned long h = scm_raw_ihashq (SCM_CELL_WORD_0 (obj));
|
||||
uintptr_t h = scm_raw_ihashq (SCM_CELL_WORD_0 (obj));
|
||||
if (len)
|
||||
while (i--)
|
||||
h ^= scm_raw_ihash (scm_c_vector_ref (obj, h % len), i);
|
||||
|
@ -326,7 +326,7 @@ scm_raw_ihash (SCM obj, size_t depth)
|
|||
}
|
||||
case scm_tc7_syntax:
|
||||
{
|
||||
unsigned long h;
|
||||
uintptr_t h;
|
||||
h = scm_raw_ihash (scm_syntax_expression (obj), depth);
|
||||
h ^= scm_raw_ihash (scm_syntax_wrap (obj), depth);
|
||||
h ^= scm_raw_ihash (scm_syntax_module (obj), depth);
|
||||
|
@ -386,7 +386,7 @@ SCM_DEFINE (scm_hashq, "hashq", 2, 0, 0,
|
|||
"different values, since @code{foo} will be garbage collected.")
|
||||
#define FUNC_NAME s_scm_hashq
|
||||
{
|
||||
unsigned long sz = scm_to_unsigned_integer (size, 1, ULONG_MAX);
|
||||
uintptr_t sz = scm_to_unsigned_integer (size, 1, UINTPTR_MAX);
|
||||
return scm_from_ulong (scm_ihashq (key, sz));
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
@ -419,7 +419,7 @@ SCM_DEFINE (scm_hashv, "hashv", 2, 0, 0,
|
|||
"different values, since @code{foo} will be garbage collected.")
|
||||
#define FUNC_NAME s_scm_hashv
|
||||
{
|
||||
unsigned long sz = scm_to_unsigned_integer (size, 1, ULONG_MAX);
|
||||
uintptr_t sz = scm_to_unsigned_integer (size, 1, UINTPTR_MAX);
|
||||
return scm_from_ulong (scm_ihashv (key, sz));
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
@ -442,7 +442,7 @@ SCM_DEFINE (scm_hash, "hash", 2, 0, 0,
|
|||
"integer in the range 0 to @var{size} - 1.")
|
||||
#define FUNC_NAME s_scm_hash
|
||||
{
|
||||
unsigned long sz = scm_to_unsigned_integer (size, 1, ULONG_MAX);
|
||||
uintptr_t sz = scm_to_unsigned_integer (size, 1, UINTPTR_MAX);
|
||||
return scm_from_ulong (scm_ihash (key, sz));
|
||||
}
|
||||
#undef FUNC_NAME
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue