~ chicken-core (chicken-5) 4bea71ab16718617449c19f1080f6bd4851fd05f
commit 4bea71ab16718617449c19f1080f6bd4851fd05f Author: Peter Bex <peter@more-magic.net> AuthorDate: Tue Oct 11 21:42:30 2016 +0200 Commit: Evan Hanson <evhan@foldling.org> CommitDate: Fri Oct 28 12:26:32 2016 +1300 Replace uses of (##sys#fudge 7) by C_wordstobytes. Signed-off-by: Evan Hanson <evhan@foldling.org> diff --git a/lolevel.scm b/lolevel.scm index bac44f9c..cd98f528 100644 --- a/lolevel.scm +++ b/lolevel.scm @@ -341,8 +341,8 @@ EOF (let ((unset (list 'unset))) (lambda (n #!optional (init unset)) (##sys#check-exact n 'make-pointer-vector) - (let* ((mul (##sys#fudge 7)) ; wordsize - (size (fx* n mul)) + (let* ((words->bytes (foreign-lambda int "C_wordstobytes" int)) + (size (words->bytes n)) (buf (##sys#make-blob size))) (unless (eq? init unset) (when init diff --git a/runtime.c b/runtime.c index 8af8cddb..6eb23526 100644 --- a/runtime.c +++ b/runtime.c @@ -4862,7 +4862,7 @@ C_regparm C_word C_fcall C_fudge(C_word fudge_factor) panic(C_text("(##sys#fudge 6) [current CPU milliseconds] not implemented")); case C_fix(7): /* wordsize */ - return C_fix(sizeof(C_word)); + panic(C_text("(##sys#fudge 7) [wordsize] is obsolete")); case C_fix(8): /* words needed for double */ return C_fix(C_wordsperdouble(1)); diff --git a/support.scm b/support.scm index 1bce489a..5f9bf7b4 100644 --- a/support.scm +++ b/support.scm @@ -253,16 +253,9 @@ (any (lambda (c) (or (char-alphabetic? c) (char-numeric? c) (char=? #\_ c))) (cdr str) ) ) ) ) ) ) -(eval-when (load) - (define bytes->words (foreign-lambda int "C_bytestowords" int)) - (define words->bytes (foreign-lambda int "C_wordstobytes" int)) ) - -(eval-when (eval) - (define (bytes->words n) - (let ([wordsize (##sys#fudge 7)]) - (+ (quotient n wordsize) (if (zero? (modulo n wordsize)) 0 1)) ) ) - (define (words->bytes n) - (* n (##sys#fudge 7)) ) ) +;; TODO: Move these to (chicken memory)? +(define bytes->words (foreign-lambda int "C_bytestowords" int)) +(define words->bytes (foreign-lambda int "C_wordstobytes" int)) ;; Used only in batch-driver; move it there? (define (check-and-open-input-file fname . line) diff --git a/tests/compiler-tests.scm b/tests/compiler-tests.scm index 2d149d9f..769b338c 100644 --- a/tests/compiler-tests.scm +++ b/tests/compiler-tests.scm @@ -1,7 +1,8 @@ ;;;; compiler-tests.scm -(import bitwise flonum foreign srfi-4) +(import (chicken bitwise) (chicken flonum) (chicken foreign) + (srfi 4)) (import-for-syntax data-structures expand) ;; test dropping of previous toplevel assignments @@ -14,7 +15,8 @@ (assert (eq? 'ok (foo))) (assert (= 1 (foreign-type-size "char"))) -(let ((bytes-in-a-word (##sys#fudge 7))) +(let* ((words->bytes (foreign-lambda int "C_wordstobytes" int)) + (bytes-in-a-word (words->bytes 1))) (assert (= bytes-in-a-word (foreign-type-size "C_word")))) ;; test hiding of unexported toplevel variablesTrap