diff --git a/collects/tests/racket/foreign-test.rktl b/collects/tests/racket/foreign-test.rktl index f2279b02a8..ecc5589b94 100644 --- a/collects/tests/racket/foreign-test.rktl +++ b/collects/tests/racket/foreign-test.rktl @@ -10,6 +10,21 @@ (test #f malloc 0 _int) (test #f malloc _int 0) +(let () + (define (try-int-boundary N _int _uint) + (test (- (expt 2 N)) cast (- (expt 2 N)) _int _int) + (test (sub1 (expt 2 N)) cast (sub1 (expt 2 N)) _int _int) + (test (expt 2 N) cast (expt 2 N) _uint _uint) + (test (sub1 (expt 2 (add1 N))) cast (sub1 (expt 2 (add1 N))) _uint _uint) + (err/rt-test (cast (expt 2 N) _int _int)) + (err/rt-test (cast (sub1 (- (expt 2 N))) _int _int)) + (err/rt-test (cast -1 _uint _uint)) + (err/rt-test (cast (- (expt 2 N)) _uint _uint))) + ;(try-int-boundary 7 _int8 _uint8) + ;(try-int-boundary 15 _int16 _uint16) + (try-int-boundary 31 _int32 _uint32) + (try-int-boundary 63 _int64 _uint64)) + (let ([big/little (if (system-big-endian?) (lambda (x y) x) (lambda (x y) y))] [p (malloc _int32)]) (ptr-set! p _int32 0) diff --git a/src/racket/src/bignum.c b/src/racket/src/bignum.c index 0ca65762dd..69727ed8ac 100644 --- a/src/racket/src/bignum.c +++ b/src/racket/src/bignum.c @@ -406,7 +406,7 @@ int scheme_bignum_get_long_long_val(const Scheme_Object *o, mzlonglong *v) *v = 0; return 1; } else if (SCHEME_BIGDIG(o)[MAX_BN_SIZE_FOR_LL - 1] == FIRST_BIT_MASK_LL -# ifndef USE_LONG_LONG_FOR_BIGDIG +# if !defined(USE_LONG_LONG_FOR_BIGDIG) && !defined(SIXTY_FOUR_BIT_INTEGERS) && !SCHEME_BIGDIG(o)[0] # endif && !SCHEME_BIGPOS(o)) {