Changeset 7442 for branches/working-0710


Ignore:
Timestamp:
Oct 14, 2007, 8:25:45 PM (12 years ago)
Author:
wws
Message:

Finish the artist's conception of random and friends for 64-bit-target.

Location:
branches/working-0710/ccl
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/working-0710/ccl/level-0/l0-numbers.lisp

    r7395 r7442  
    17541754         (declare (fixnum n n32))
    17551755         (dotimes (i n32 (fast-mod n number))
    1756            (setq n (logior (the fixnum (ash n 16))
     1756           (setq n (logior (the fixnum (ash n 32))
    17571757                           (the fixnum (%next-random-seed state))))))))
    17581758    ((and (typep number 'double-float) (> (the double-float number) 0.0))
     
    18141814#+32-bit-target
    18151815(defun %next-random-seed (state)
    1816   (multiple-value-bind (high low) (%next-random-pair (%svref state 1)
    1817                                                      (%svref state 2))
     1816  (multiple-value-bind (high low) (%next-random-pair (random.seed-1 state)
     1817                                                     (random.seed-2 state))
    18181818    (declare (type (unsigned-byte 15) high)
    18191819             (type (unsigned-byte 16) low))
    1820     (setf (%svref state 1) high
    1821           (%svref state 2) low)
     1820    (setf (random.seed-1 state) high
     1821          (random.seed-2 state) low)
    18221822    (logior high (the fixnum (logand low (ash 1 15))))))
    18231823
  • branches/working-0710/ccl/level-1/l1-numbers.lisp

    r6027 r7442  
    421421      nil)))
    422422
     423(defun %cons-random-state (seed-1 seed-2)
     424  #+32-bit-target
     425  (gvector :istuct
     426           'random-state
     427           seed-1
     428           seed-2)
     429  #+64-bit-target
     430  (gvector :istruct
     431           'random-state
     432           (the fixnum (+ (the fixnum seed-2)
     433                          (the fixnum (ash (the fixnum seed-1) 16))))))
     434
    423435;;; random associated stuff except for the print-object method which
    424436;;; is still in "lib;numbers.lisp"
     
    428440  (unless (and (fixnump seed-2) (%i<= 0 seed-2) (%i< seed-2 #x10000))
    429441    (report-bad-arg seed-2 '(unsigned-byte 16)))
    430     (gvector :istruct
    431              'random-state
    432              seed-1
    433              seed-2))
    434 
    435 
    436 
    437 
     442    (%cons-random-state seed-1 seed-2))
    438443
    439444(defun make-random-state (&optional state)
     
    449454        (setq state (require-type (or state *random-state*) 'random-state))
    450455        (setq seed-1 (random.seed-1 state) seed-2 (random.seed-2 state))))
    451     (gvector :istruct 'random-state seed-1 seed-2)))
     456    (%cons-random-state seed-1 seed-2)))
    452457
    453458(defun random-state-p (thing) (istruct-typep thing 'random-state))
  • branches/working-0710/ccl/lib/numbers.lisp

    r7415 r7442  
    354354  (format stream "#.(~S ~S ~S)"         ;>> #.GAG!!!
    355355          'ccl::initialize-random-state
    356           (%svref rs 1)
    357           (%svref rs 2)))
     356          (random.seed-1 rs)
     357          (random.seed-2 rs)))
    358358
    359359#+64-bit-target
    360360(defmethod print-object ((rs random-state) stream)
    361   (let* ((s1 (%svref rs 1)))
     361  (let* ((s1 (random.seed-1 rs)))
    362362    (format stream "#.(~S ~S ~S)"       ;>> #.GAG!!!
    363363            'ccl::initialize-random-state
Note: See TracChangeset for help on using the changeset viewer.