patch for making src/cllib/rng.lisp compile under sbcl-0.8.21

Ram Bhamidipaty <[email protected]> Fri, 22 Apr 2005 15:39:09 -0700
Newsgroups gmane.lisp.clocc.general
Message-ID <[email protected]>
Here are the changes I needed to make to get the current
cvs head version of clocc to compiler under sbcl-0.8.21.

The changes are:

1. According to some of the docs I found eval-when with compile, load
   eval is deprecated and the new thing is :compile-toplevel etc. So
   I made those changes. Turns out this change is not required, but
   it did reduce some of the warning messages.

2. *random-state* is being added to the common-lisp package. sbcl
   has this package locked and thus the compile fails. I added
   some commands that unlock the package to allow this symbol to
   be defined.

   Probably there are many portability issues that I am not thinking
   about - someone with more experience with lisp will need to
   think about that.

3. the definition of +beta-algo-go+ needs to be moved closer to the
   start of the file. otherwise sbcl will complain that this symbol
   is undefined when trying to compile ziggurat-init.

I hope these patches can be incorporated into clocc.

-Ram



axis47b> cvs diff -c rng.lisp
Index: rng.lisp
===================================================================
RCS file: /cvsroot/clocc/clocc/src/cllib/rng.lisp,v
retrieving revision 1.14
diff -u -3 -p -c -r1.14 rng.lisp
cvs diff: conflicting specifications of output style
*** rng.lisp    8 Mar 2005 22:50:54 -0000       1.14
--- rng.lisp    22 Apr 2005 22:32:10 -0000
***************
*** 108,114 ****
  ;;;;  Initial revision
  ;;;;
  
! (eval-when (compile load eval)
    (require :cllib-base (translate-logical-pathname "clocc:src;cllib;base"))
    ;; `dfloat', `with-type'
    (require :cllib-withtype (translate-logical-pathname "cllib:withtype")))
--- 108,114 ----
  ;;;;  Initial revision
  ;;;;
  
! (eval-when (:compile-toplevel :load-toplevel :execute)
    (require :cllib-base (translate-logical-pathname "clocc:src;cllib;base"))
    ;; `dfloat', `with-type'
    (require :cllib-withtype (translate-logical-pathname "cllib:withtype")))
***************
*** 165,170 ****
--- 165,176 ----
  ;;
  ;; where r = x[n].
  ;;
+ (eval-when (:compile-toplevel :execute)
+   (defconstant +beta-algo-go+ 0.009572265238289d0)
+   (declaim (type (double-float 0.009572265238289d0 0.009572265238289d0)
+                +beta-algo-go+))
+   )
+ 
  (defun ziggurat-init (n r v scale f finv)
    ;; n = one less than the number of elements in the tables
    ;; r = x[n]
*************** mean of mu:
*** 243,250 ****
--- 249,258 ----
  
   STATE is the random state to use.  The logarithmic method is used.
  "
+   (declare (disable-package-locks common-lisp)
    (declare (type random-state *random-state*)
           (type (double-float (0d0)) mu))
+   (declare (enable-package-locks common-lisp))
    (* mu (- (log (random 1d0)))))
  
  
*************** order ORDER.
*** 1562,1573 ****
          (- (gen-gamma-variate-small-order r)
             (log x))))))
  
- (eval-when (compile eval)
-   (defconstant +beta-algo-go+ 0.009572265238289d0)
-   (declaim (type (double-float 0.009572265238289d0 0.009572265238289d0)
-                +beta-algo-go+))
-   )
- 
  ;; Ahrens and Dieter's Algorithm GO.
  #+(or)
  (defun gen-gamma-variate-algo-go (a &optional (*random-state* *random-state*))
--- 1570,1575 ----
*************** with parameters a and b:
*** 1822,1828 ****
  ;;; Binomial random variate
  
  #+(or)
! (eval-when (compile eval)
  (declaim (ftype (function ((and (integer 0) fixnum)
                           (non-negative-float double-float 1d0)
                           &optional random-state)
--- 1824,1830 ----
  ;;; Binomial random variate
  
  #+(or)
! (eval-when (:compile-toplevel :execute)
  (declaim (ftype (function ((and (integer 0) fixnum)
                           (non-negative-float double-float 1d0)
                           &optional random-state)
*************** with parameters N and p:
*** 1877,1883 ****
  ;;; Poisson random variate
  
  #+(or)
! (eval-when (compile)
    (declaim (ftype (function ((double-float 0d0) &optional random-state)
                            (and (integer 0) fixnum))
                  gen-poisson-variate)))
--- 1879,1885 ----
  ;;; Poisson random variate
  
  #+(or)
! (eval-when (:compile-toplevel)
    (declaim (ftype (function ((double-float 0d0) &optional random-state)
                            (and (integer 0) fixnum))
                  gen-poisson-variate)))


-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click