~ chicken-core (chicken-5) aea23751abd310f60306e124d3a9c07d3164c897


commit aea23751abd310f60306e124d3a9c07d3164c897
Author:     Peter Bex <peter@more-magic.net>
AuthorDate: Tue Oct 11 21:54:27 2016 +0200
Commit:     Evan Hanson <evhan@foldling.org>
CommitDate: Fri Oct 28 12:26:42 2016 +1300

    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.
    
    Signed-off-by: Evan Hanson <evhan@foldling.org>

diff --git a/csi.scm b/csi.scm
index b0ed7cf6..6ba4d489 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 f591b91f..7580b568 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 6eb23526..c20c6d88 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 5f9bf7b4..020f335e 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 d03dd1ae..9584c693 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 9c5b95c0..3b4fb278 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 243d2d74..7ec05541 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 81231b86..af415abc 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)))
Trap