From 8bd012bfeb25b98e8ce73eeb0ad904b98c1ed61e Mon Sep 17 00:00:00 2001 From: Abdulaziz Ghuloum Date: Mon, 24 Aug 2009 15:22:51 +0300 Subject: [PATCH] fx{+,-,*}/carry now chech that all their arguments are fixnums (causes segfaults when unchecked). --- scheme/ikarus.fixnums.ss | 13 ++++++++++--- scheme/last-revision | 2 +- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/scheme/ikarus.fixnums.ss b/scheme/ikarus.fixnums.ss index 4ea1328..520bb94 100644 --- a/scheme/ikarus.fixnums.ss +++ b/scheme/ikarus.fixnums.ss @@ -368,19 +368,26 @@ (die 'fxmax "not a fixnum" z)))] [(x) (if (fixnum? x) x (die 'fxmax "not a fixnum" x))])) - (define (fx*/carry fx1 fx2 fx3) + (define-syntax define-fx + (syntax-rules () + [(_ (name arg* ...) body) + (define (name arg* ...) + (unless (fixnum? arg*) (die 'name "not a fixnum" arg*)) ... + body)])) + + (define-fx (fx*/carry fx1 fx2 fx3) (let ([s0 ($fx+ ($fx* fx1 fx2) fx3)]) (values s0 (sra (+ (* fx1 fx2) (- fx3 s0)) (fixnum-width))))) - (define (fx+/carry fx1 fx2 fx3) + (define-fx (fx+/carry fx1 fx2 fx3) (let ([s0 ($fx+ ($fx+ fx1 fx2) fx3)]) (values s0 (sra (+ (+ fx1 fx2) (- fx3 s0)) (fixnum-width))))) - (define (fx-/carry fx1 fx2 fx3) + (define-fx (fx-/carry fx1 fx2 fx3) (let ([s0 ($fx- ($fx- fx1 fx2) fx3)]) (values s0 diff --git a/scheme/last-revision b/scheme/last-revision index f625eb6..bddb3cd 100644 --- a/scheme/last-revision +++ b/scheme/last-revision @@ -1 +1 @@ -1843 +1844