~ chicken-core (chicken-5) 46903e12645f4030ea373c1e5c4ba3391acd8466
commit 46903e12645f4030ea373c1e5c4ba3391acd8466 Author: Peter Bex <peter@more-magic.net> AuthorDate: Sun Jun 4 17:30:13 2017 +0200 Commit: Peter Bex <peter@more-magic.net> CommitDate: Sun Jun 4 17:30:13 2017 +0200 Do not use labs() on C_words; llabs() is required on LLP platforms Instead, we define C_wabs to return absolute word. diff --git a/chicken.h b/chicken.h index 6addd311..efd89789 100644 --- a/chicken.h +++ b/chicken.h @@ -584,6 +584,7 @@ void *alloca (); #define C_S64_MAX INT64_MAX #if defined(C_LLP) +# define C_wabs llabs # define C_long C_s64 # ifndef LONG_LONG_MAX # define C_LONG_MAX LLONG_MAX @@ -593,6 +594,7 @@ void *alloca (); # define C_LONG_MIN LONG_LONG_MIN # endif #else +# define C_wabs labs # define C_long long # define C_LONG_MAX LONG_MAX # define C_LONG_MIN LONG_MIN @@ -2526,7 +2528,7 @@ inline static C_uword C_num_to_unsigned_int(C_word x) inline static C_word C_int_to_num(C_word **ptr, C_word n) { if(C_fitsinfixnump(n)) return C_fix(n); - else return C_bignum1(ptr, n < 0, labs(n)); + else return C_bignum1(ptr, n < 0, C_wabs(n)); } @@ -2571,7 +2573,7 @@ inline static C_word C_long_to_num(C_word **ptr, C_long n) if(C_fitsinfixnump(n)) { return C_fix(n); } else { - return C_bignum1(ptr, n < 0, labs(n)); + return C_bignum1(ptr, n < 0, C_wabs(n)); } } @@ -2992,7 +2994,7 @@ inline static C_word C_a_i_fixnum_difference(C_word **ptr, C_word n, C_word x, C C_word z = C_unfix(x) - C_unfix(y); if(!C_fitsinfixnump(z)) { - return C_bignum1(ptr, z < 0, labs(z)); + return C_bignum1(ptr, z < 0, C_wabs(z)); } else { return C_fix(z); } @@ -3003,7 +3005,7 @@ inline static C_word C_a_i_fixnum_plus(C_word **ptr, C_word n, C_word x, C_word C_word z = C_unfix(x) + C_unfix(y); if(!C_fitsinfixnump(z)) { - return C_bignum1(ptr, z < 0, labs(z)); + return C_bignum1(ptr, z < 0, C_wabs(z)); } else { return C_fix(z); } diff --git a/runtime.c b/runtime.c index 1a815908..1d2e7502 100644 --- a/runtime.c +++ b/runtime.c @@ -5859,11 +5859,11 @@ C_s_a_u_i_integer_negate(C_word **ptr, C_word n, C_word x) } -/* Faster version that ignores sign in bignums. TODO: Omit labs() too? */ +/* Faster version that ignores sign */ inline static int integer_length_abs(C_word x) { if (x & C_FIXNUM_BIT) { - return C_ilen(labs(C_unfix(x))); + return C_ilen(C_wabs(C_unfix(x))); } else { C_uword result = (C_bignum_size(x) - 1) * C_BIGNUM_DIGIT_LENGTH, *last_digit = C_bignum_digits(x) + C_bignum_size(x) - 1,Trap