Changeset 17247 in project


Ignore:
Timestamp:
02/13/10 05:56:49 (10 years ago)
Author:
Kon Lovett
Message:

Treat 8bit from 64bit as 8byte vec

Location:
release/4/srfi-27/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/srfi-27/trunk/entropy-clock.scm

    r17246 r17247  
    4343    #:entropy-system-clock
    4444    ;
    45     "Entropy from system clock - f64rand( time(0) )"
     45    "Entropy from system clock"
    4646    ;
    47     (lambda () (entropic-u8/f64 _f64rand) )
     47    (make-entropic-u8/f64 _f64rand)
    4848    ;
    49     (lambda () (_f64rand) )
     49    _f64rand
    5050    ;
    5151    (lambda (u8cnt u8vec) (entropic-u8vector-filled/f64 u8cnt u8vec _f64rand) )
  • release/4/srfi-27/trunk/entropy-procedure.scm

    r17246 r17247  
    4141
    4242(define (make-entropy-source/f64procedure f64proc . args)
    43   (apply make-entropy-source/procedures (lambda () (entropic-u8/f64 f64proc)) f64proc args) )
     43  (apply make-entropy-source/procedures (make-entropic-u8/f64 f64proc) f64proc args) )
    4444
    4545) ;module entropy-procedure
  • release/4/srfi-27/trunk/entropy-support.scm

    r17246 r17247  
    99
    1010  (;export
    11     entropic-u8/f64
     11    make-entropic-u8/f64
    1212    entropic-u8vector-filled
    1313    entropic-u8vector-filled/f64
     
    6060; these suck - need to treat result of 'f64gen' as 8-byte vector w/ auto-fill
    6161#;(define (entropic-u8/f64 f64gen) (inexact->exact (fptruncate (fpmodulo (f64gen) 256.0))))
    62 (define (entropic-u8/f64 f64gen) (##core#inline "C_quickflonumtruncate" (f64gen)))
     62#;(define (entropic-u8/f64 f64gen) (##core#inline "C_quickflonumtruncate" (f64gen)))
     63
     64(define (make-entropic-u8/f64 f64gen)
     65  (let ((idx BYTES/F64) )
     66    (let-location ((dbl double))
     67      (lambda ()
     68        (if (fx= idx BYTES/F64) (begin (set! dbl (f64gen)) (set! idx 0))
     69            (set! idx (fx+ idx 1)) )
     70        ((foreign-lambda* unsigned-byte ((double d) (int idx)) "C_return (((uint8_t *)&d)[idx]);")
     71         dbl idx) ) ) ) )
    6372
    6473(define (entropic-u8vector-filled u8cnt u8vec u8gen)
Note: See TracChangeset for help on using the changeset viewer.