SRFI-151: Fix bit-set? on Win64 which uses long long

Most "1UL" references on bitwise operations should be replaced with
explicit C cast.
This commit is contained in:
okuoku 2017-12-14 04:13:04 +09:00
parent dee6f190d9
commit 1cba43a220
2 changed files with 7 additions and 7 deletions

View file

@ -20,11 +20,11 @@ extern "C" {
#ifdef _WIN32
#include <windows.h>
#include <errno.h>
#define sexp_isalpha(x) ((isalpha)((int)(x)))
#define sexp_isxdigit(x) ((isxdigit)((int)(x)))
#define sexp_isdigit(x) ((isdigit)((int)(x)))
#define sexp_tolower(x) ((tolower)((int)(x)))
#define sexp_toupper(x) ((toupper)((int)(x)))
#define sexp_isalpha(x) (isalpha(x))
#define sexp_isxdigit(x) (isxdigit(x))
#define sexp_isdigit(x) (isdigit(x))
#define sexp_tolower(x) (tolower(x))
#define sexp_toupper(x) (toupper(x))
#define SEXP_USE_POLL_PORT 0
#define sexp_poll_input(ctx, port) usleep(SEXP_POLL_SLEEP_TIME)
#define sexp_poll_output(ctx, port) usleep(SEXP_POLL_SLEEP_TIME)

View file

@ -398,13 +398,13 @@ sexp sexp_bit_set_p (sexp ctx, sexp self, sexp_sint_t n, sexp i, sexp x) {
return sexp_xtype_exception(ctx, self, "index must be non-negative", i);
if (sexp_fixnump(x)) {
return sexp_make_boolean((pos < sizeof(sexp_uint_t)*CHAR_BIT)
&& (sexp_unbox_fixnum(x) & (1UL<<pos)));
&& (sexp_unbox_fixnum(x) & ((sexp_uint_t)1<<pos)));
#if SEXP_USE_BIGNUMS
} else if (sexp_bignump(x)) {
pos /= (sizeof(sexp_uint_t)*CHAR_BIT);
rem = (sexp_unbox_fixnum(i) - pos*sizeof(sexp_uint_t)*CHAR_BIT);
return sexp_make_boolean((pos < (sexp_sint_t)sexp_bignum_length(x))
&& (sexp_bignum_data(x)[pos] & (1UL<<rem)));
&& (sexp_bignum_data(x)[pos] & ((sexp_uint_t)1<<rem)));
#endif
} else {
return sexp_type_exception(ctx, self, SEXP_FIXNUM, x);