From 84e286f309d3c737a6a87fcb5492ed3a81ed7c96 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Tue, 11 Oct 2016 21:54:27 +0200 Subject: [PATCH 2/9] Replace (##sys#fudge 3) by #:64bit feature checks. We could alternatively use cond-expand. When _defining_ the feature, we resort to checking the C_WORD_SIZE foreign value, which is more or less equivalent to what the fudge did. --- csi.scm | 2 +- library.scm | 9 +++++---- runtime.c | 6 +----- support.scm | 2 +- tests/arithmetic-test.scm | 4 ++-- tests/fixnum-tests.scm | 6 +++--- tests/lolevel-tests.scm | 2 +- tests/numbers-test.scm | 2 +- 8 files changed, 15 insertions(+), 18 deletions(-) diff --git a/csi.scm b/csi.scm index b0ed7cf..6ba4d48 100644 --- a/csi.scm +++ b/csi.scm @@ -483,7 +483,7 @@ EOF nursery size is ~S bytes, stack grows ~A~%~ Command line: \t~S~%" (machine-type) - (if (##sys#fudge 3) "(64-bit)" "") + (if (feature? #:64bit) "(64-bit)" "") (software-type) (software-version) (build-platform) diff --git a/library.scm b/library.scm index f591b91..7580b56 100644 --- a/library.scm +++ b/library.scm @@ -4394,12 +4394,12 @@ EOF (string-append (str sv) (str st) (str bp) (##sys#symbol->string mt)) ) ) (if full (let ((spec (string-append - (if (##sys#fudge 3) " 64bit" "") + (if (feature? #:64bit) " 64bit" "") (if (##sys#fudge 15) " symbolgc" "") (if (##sys#fudge 40) " manyargs" "") - (if (##sys#fudge 24) " dload" "") + (if (##sys#fudge 24) " dload" "") (if (##sys#fudge 28) " ptables" "") - (if (##sys#fudge 32) " gchooks" "") + (if (##sys#fudge 32) " gchooks" "") (if (##sys#fudge 39) " cross" "") ) ) ) (string-append "Version " ##sys#build-version @@ -4451,7 +4451,8 @@ EOF (when (##sys#fudge 24) (set! ##sys#features (cons #:dload ##sys#features))) (when (##sys#fudge 28) (set! ##sys#features (cons #:ptables ##sys#features))) (when (##sys#fudge 39) (set! ##sys#features (cons #:cross-chicken ##sys#features))) -(when (##sys#fudge 3) (set! ##sys#features (cons #:64bit ##sys#features))) +(when (fx= (foreign-value "C_WORD_SIZE" int) 64) + (set! ##sys#features (cons #:64bit ##sys#features))) (set! ##sys#features (let ((major (##sys#string-append "chicken-" (##sys#number->string (##sys#fudge 41))))) diff --git a/runtime.c b/runtime.c index 6eb2352..c20c6d8 100644 --- a/runtime.c +++ b/runtime.c @@ -4838,11 +4838,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor) panic(C_text("(##sys#fudge 2) [get time] not implemented")); case C_fix(3): /* 64-bit system? */ -#ifdef C_SIXTY_FOUR - return C_SCHEME_TRUE; -#else - return C_SCHEME_FALSE; -#endif + panic(C_text("(##sys#fudge 3) [64bit] is obsolete")); case C_fix(4): /* is this a console application? */ return C_mk_bool(!C_gui_mode); diff --git a/support.scm b/support.scm index 5f9bf7b..020f335 100644 --- a/support.scm +++ b/support.scm @@ -1586,7 +1586,7 @@ (define (big-fixnum? x) ;; XXX: This should probably be in c-platform (and (fixnum? x) - (##sys#fudge 3) ; 64 bit? + (feature? #:64bit) (or (fx> x 1073741823) (fx< x -1073741824) ) ) ) diff --git a/tests/arithmetic-test.scm b/tests/arithmetic-test.scm index d03dd1a..9584c69 100644 --- a/tests/arithmetic-test.scm +++ b/tests/arithmetic-test.scm @@ -121,7 +121,7 @@ (cond-expand (check-numbers "arithmetic-test.numbers.expected") (else - (if (##sys#fudge 3) + (if (feature? #:64bit) "arithmetic-test.64.expected" "arithmetic-test.32.expected"))) (lambda (x) @@ -138,4 +138,4 @@ (set! result (cdr result))) x))) -(exit (if errors? 1 0)) \ No newline at end of file +(exit (if errors? 1 0)) diff --git a/tests/fixnum-tests.scm b/tests/fixnum-tests.scm index 9c5b95c..3b4fb27 100644 --- a/tests/fixnum-tests.scm +++ b/tests/fixnum-tests.scm @@ -5,17 +5,17 @@ (assert (= -26 (fxo+ 74 -100))) (assert (= 1073741823 (fxo+ #x3ffffffe 1))) (assert - (if (##sys#fudge 3) ; 64-bit? + (if (feature? #:64bit) (not (fxo+ #x3fffffffffffffff 1)) (not (fxo+ #x3fffffff 1)))) (assert (= 4 (fxo- 6 2))) (assert (= -4 (fxo- 1000 1004))) (assert (= 2004 (fxo- 1000 -1004))) (assert - (if (##sys#fudge 3) ; 64-bit? + (if (feature? #:64bit) (= -4611686018427387904 (fxo- (- #x3fffffffffffffff) 1)) (= -1073741824 (fxo- (- #x3fffffff) 1)))) (assert - (if (##sys#fudge 3) ; 64-bit? + (if (feature? #:64bit) (not (fxo- (- #x3fffffffffffffff) 2)) (not (fxo- (- #x3fffffff) 2)))) diff --git a/tests/lolevel-tests.scm b/tests/lolevel-tests.scm index 243d2d7..7ec0554 100644 --- a/tests/lolevel-tests.scm +++ b/tests/lolevel-tests.scm @@ -246,7 +246,7 @@ (assert (= 4 (number-of-bytes "abcd"))) -(assert (= (if (##sys#fudge 3) 8 4) (number-of-bytes '#(1)))) +(assert (= (if (feature? #:64bit) 8 4) (number-of-bytes '#(1)))) ; make-record-instance diff --git a/tests/numbers-test.scm b/tests/numbers-test.scm index 81231b8..af415ab 100644 --- a/tests/numbers-test.scm +++ b/tests/numbers-test.scm @@ -28,7 +28,7 @@ ;; The minimal bignum in the sense that any smaller makes it a fixnum (define min-big (+ most-positive-fixnum 1)) -(define 64-bits? (##sys#fudge 3)) +(define 64-bits? (feature? #:64bit)) (define (show x) (print (and x (number->string x))) -- 2.1.4