Changeset 15559 in project


Ignore:
Timestamp:
08/24/09 16:43:08 (10 years ago)
Author:
felix winkelmann
Message:

test for srandom availability in extras was insufficient - removed srandom support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • chicken/trunk/extras.scm

    r14829 r15559  
    8686;;; Random numbers:
    8787
    88 (cond-expand
    89   (unix
    90 
    91     (define random-seed)
    92     (define randomize)
    93 
    94     (let ((srandom (foreign-lambda void "srandom" unsigned-integer)))
    95 
    96       (set! random-seed
    97         (lambda (#!optional (seed (current-seconds)))
    98           (##sys#check-integer seed 'random-seed)
    99           (srandom seed) ) )
    100 
    101       (set! randomize
    102         (lambda (#!optional (seed (##sys#fudge 2)))
    103           (##sys#check-exact seed 'randomize)
    104           (srandom seed) ) ) )
    105 
    106     (define (random n)
    107       (##sys#check-integer n 'random)
    108       (if (eq? 0 n)
    109           0
    110           ((foreign-lambda* long ((integer64 n)) "return( random() % ((uint64_t) n) );") n) ) ) )
    111   (else
    112 
    113     (define random-seed
    114       (let ((srand (foreign-lambda void "srand" unsigned-integer)))
    115         (lambda n
    116           (let ((t (if (null? n) (current-seconds) (car n))))
    117             (##sys#check-integer t 'random-seed)
    118             (srand t) ) ) ) )
    119 
    120     (define (randomize . n)
    121       (let ((nn (if (null? n) (##sys#fudge 2) (car n))))
    122         (##sys#check-exact nn 'randomize)
    123         (##core#inline "C_randomize" nn) ) )
    124 
    125     (define (random n)
    126       (##sys#check-exact n 'random)
    127       (if (eq? n 0)
    128           0
    129           (##core#inline "C_random_fixnum" n) ) ) ) )
     88(define random-seed
     89  (let ((srand (foreign-lambda void "srand" unsigned-integer)))
     90    (lambda n
     91      (let ((t (if (null? n) (current-seconds) (car n))))
     92        (##sys#check-integer t 'random-seed)
     93        (srand t) ) ) ) )
     94
     95(define (randomize . n)
     96  (let ((nn (if (null? n) (##sys#fudge 2) (car n))))
     97    (##sys#check-exact nn 'randomize)
     98    (##core#inline "C_randomize" nn) ) )
     99
     100(define (random n)
     101  (##sys#check-exact n 'random)
     102  (if (eq? n 0)
     103      0
     104      (##core#inline "C_random_fixnum" n) ) )
    130105
    131106
Note: See TracChangeset for help on using the changeset viewer.