Gentoo Archives: gentoo-commits

From: "Ulrich Müller" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lisp/clozurecl/files/, dev-lisp/clozurecl/
Date: Sun, 22 Nov 2015 19:51:13
Message-Id: 1448221574.dc9d07ba16291325c42886e75511078fa3418ccb.ulm@gentoo
1 commit: dc9d07ba16291325c42886e75511078fa3418ccb
2 Author: Andrey Grozin <grozin <AT> gentoo <DOT> org>
3 AuthorDate: Sat Nov 21 04:52:27 2015 +0000
4 Commit: Ulrich Müller <ulm <AT> gentoo <DOT> org>
5 CommitDate: Sun Nov 22 19:46:14 2015 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=dc9d07ba
7
8 dev-lisp/clozurecl: fix bug with the ~e format
9
10 Upstream patch http://trac.clozure.com/ccl/changeset/16639
11 Bug: http://trac.clozure.com/ccl/ticket/563, http://trac.clozure.com/ccl/ticket/1186
12
13 Package-Manager: portage-2.2.25
14
15 dev-lisp/clozurecl/clozurecl-1.11-r1.ebuild | 94 ++++++++++++++++++++
16 dev-lisp/clozurecl/files/ccl-format.patch | 128 ++++++++++++++++++++++++++++
17 2 files changed, 222 insertions(+)
18
19 diff --git a/dev-lisp/clozurecl/clozurecl-1.11-r1.ebuild b/dev-lisp/clozurecl/clozurecl-1.11-r1.ebuild
20 new file mode 100644
21 index 0000000..5a39a3a
22 --- /dev/null
23 +++ b/dev-lisp/clozurecl/clozurecl-1.11-r1.ebuild
24 @@ -0,0 +1,94 @@
25 +# Copyright 1999-2015 Gentoo Foundation
26 +# Distributed under the terms of the GNU General Public License v2
27 +# $Id$
28 +
29 +EAPI=6
30 +
31 +inherit eutils multilib toolchain-funcs
32 +
33 +MY_PN=ccl
34 +MY_P=${MY_PN}-${PV}
35 +
36 +DESCRIPTION="Common Lisp implementation, derived from Digitool's MCL product"
37 +HOMEPAGE="http://ccl.clozure.com/"
38 +SRC_URI="
39 + x86? ( ftp://ftp.clozure.com/pub/release/${PV}/${MY_P}-linuxx86.tar.gz )
40 + amd64? ( ftp://ftp.clozure.com/pub/release/${PV}/${MY_P}-linuxx86.tar.gz )
41 + doc? ( http://ccl.clozure.com/docs/ccl.html )"
42 + # ppc? ( ftp://ftp.clozure.com/pub/release/${PV}/${MY_P}-linuxppc.tar.gz )
43 + # ppc64? ( ftp://ftp.clozure.com/pub/release/${PV}/${MY_P}-linuxppc.tar.gz )"
44 +
45 +LICENSE="LLGPL-2.1"
46 +SLOT="0"
47 +# KEYWORDS="~amd64 ~ppc ~ppc64 ~x86"
48 +KEYWORDS="~amd64 ~x86"
49 +IUSE="doc"
50 +
51 +RDEPEND=">=dev-lisp/asdf-2.33-r3:="
52 +DEPEND="${RDEPEND}
53 + !dev-lisp/openmcl"
54 +
55 +S="${WORKDIR}"/${MY_PN}
56 +PATCHES=( "${FILESDIR}"/ccl-format.patch )
57 +ENVD="${T}"/50ccl
58 +
59 +src_configure() {
60 + if use x86; then
61 + CCL_RUNTIME=lx86cl; CCL_HEADERS=x86-headers; CCL_KERNEL=linuxx8632
62 + elif use amd64; then
63 + CCL_RUNTIME=lx86cl64; CCL_HEADERS=x86-headers64; CCL_KERNEL=linuxx8664
64 + elif use ppc; then
65 + CCL_RUNTIME=ppccl; CCL_HEADERS=headers; CCL_KERNEL=linuxppc
66 + elif use ppc64; then
67 + CCL_RUNTIME=ppccl64; CCL_HEADERS=headers64; CCL_KERNEL=linuxppc64
68 + fi
69 +}
70 +
71 +src_prepare() {
72 + default
73 + cp /usr/share/common-lisp/source/asdf/build/asdf.lisp tools/ || die
74 +}
75 +
76 +src_compile() {
77 + emake -C lisp-kernel/${CCL_KERNEL} clean
78 + emake -C lisp-kernel/${CCL_KERNEL} all CC="$(tc-getCC)"
79 +
80 + unset CCL_DEFAULT_DIRECTORY
81 + ./${CCL_RUNTIME} -n -b -Q -e '(ccl:rebuild-ccl :full t)' -e '(ccl:quit)' || die "Compilation failed"
82 +
83 + # remove non-owner write permissions on the full-image
84 + chmod go-w ${CCL_RUNTIME}{,.image} || die
85 +
86 + esvn_clean
87 +}
88 +
89 +src_install() {
90 + local install_dir=/usr/$(get_libdir)/${PN}
91 +
92 + exeinto ${install_dir}
93 + # install executable
94 + doexe ${CCL_RUNTIME}
95 + # install core image
96 + cp ${CCL_RUNTIME}.image "${D}"/${install_dir} || die
97 + # install optional libraries
98 + dodir ${install_dir}/tools
99 + cp tools/*fsl "${D}"/${install_dir}/tools || die
100 +
101 + # until we figure out which source files are necessary for runtime
102 + # optional features and which aren't, we install all sources
103 + find . -type f -name '*fsl' -delete || die
104 + rm -f lisp-kernel/${CCL_KERNEL}/*.o || die
105 + cp -a compiler level-0 level-1 lib library \
106 + lisp-kernel scripts tools xdump contrib \
107 + "${D}"/${install_dir} || die
108 + cp -a ${CCL_HEADERS} "${D}"/${install_dir} || die
109 +
110 + make_wrapper ccl "${install_dir}/${CCL_RUNTIME}"
111 +
112 + echo "CCL_DEFAULT_DIRECTORY=${install_dir}" > "${ENVD}"
113 + doenvd "${ENVD}"
114 +
115 + dodoc doc/release-notes.txt
116 + use doc && dodoc "${DISTDIR}"/ccl.html
117 + use doc && dodoc -r examples
118 +}
119
120 diff --git a/dev-lisp/clozurecl/files/ccl-format.patch b/dev-lisp/clozurecl/files/ccl-format.patch
121 new file mode 100644
122 index 0000000..c2df37c
123 --- /dev/null
124 +++ b/dev-lisp/clozurecl/files/ccl-format.patch
125 @@ -0,0 +1,128 @@
126 +diff -r -U1 ccl.orig/lib/format.lisp ccl/lib/format.lisp
127 +--- ccl.orig/lib/format.lisp 2015-11-07 02:10:10.000000000 +0600
128 ++++ ccl/lib/format.lisp 2015-11-20 22:51:51.736191995 +0600
129 +@@ -1296,5 +1296,2 @@
130 +
131 +-
132 +-
133 +-
134 + ;;; Given a non-negative floating point number, SCALE-EXPONENT returns a
135 +@@ -1305,41 +1302,74 @@
136 +
137 +-
138 +-(defconstant long-log10-of-2 0.30103d0)
139 +-
140 +-#|
141 +-(defun scale-exponent (x)
142 +- (if (floatp x )
143 +- (scale-expt-aux (abs x) 0.0d0 1.0d0 1.0d1 1.0d-1 long-log10-of-2)
144 +- (report-bad-arg x 'float)))
145 +-
146 +-#|this is the slisp code that was in the place of the error call above.
147 +- before floatp was put in place of shortfloatp.
148 +- ;(scale-expt-aux x (%sp-l-float 0) (%sp-l-float 1) %long-float-ten
149 +- ; %long-float-one-tenth long-log10-of-2)))
150 +-|#
151 +-
152 +-; this dies with floating point overflow (?) if fed least-positive-double-float
153 +-
154 +-(defun scale-expt-aux (x zero one ten one-tenth log10-of-2)
155 +- (let ((exponent (nth-value 1 (decode-float x))))
156 +- (if (= x zero)
157 +- (values zero 1)
158 +- (let* ((e (round (* exponent log10-of-2)))
159 +- (x (if (minusp e) ;For the end ranges.
160 +- (* x ten (expt ten (- -1 e)))
161 +- (/ x ten (expt ten (1- e))))))
162 +- (do ((d ten (* d ten))
163 +- (y x (/ x d))
164 +- (e e (1+ e)))
165 +- ((< y one)
166 +- (do ((m ten (* m ten))
167 +- (z y (* z m))
168 +- (e e (1- e)))
169 +- ((>= z one-tenth) (values x e)))))))))
170 +-|#
171 +-
172 +-(defun scale-exponent (n)
173 +- (let ((exp (nth-value 1 (decode-float n))))
174 +- (values (round (* exp long-log10-of-2)))))
175 +-
176 ++(defconstant single-float-min-e
177 ++ (nth-value 1 (decode-float least-positive-single-float)))
178 ++(defconstant double-float-min-e
179 ++ (nth-value 1 (decode-float least-positive-double-float)))
180 ++
181 ++;;; Adapted from CMUCL.
182 ++
183 ++;; This is a modified version of the scale computation from Burger and
184 ++;; Dybvig's paper "Printing floating-point quickly and accurately."
185 ++;; We only want the exponent, so most things not needed for the
186 ++;; computation of the exponent have been removed. We also implemented
187 ++;; the floating-point log approximation given in Burger and Dybvig.
188 ++;; This is very noticeably faster for large and small numbers. It is
189 ++;; slower for intermediate sized numbers.
190 ++(defun accurate-scale-exponent (v)
191 ++ (declare (type float v))
192 ++ (if (zerop v)
193 ++ 1
194 ++ (let ((float-radix 2) ; b
195 ++ (float-digits (float-digits v)) ; p
196 ++ (min-e
197 ++ (etypecase v
198 ++ (single-float single-float-min-e)
199 ++ (double-float double-float-min-e))))
200 ++ (multiple-value-bind (f e)
201 ++ (integer-decode-float v)
202 ++ (let ( ;; FIXME: these even tests assume normal IEEE rounding
203 ++ ;; mode. I wonder if we should cater for non-normal?
204 ++ (high-ok (evenp f)))
205 ++ ;; We only want the exponent here.
206 ++ (labels ((flog (x)
207 ++ (declare (type (float (0.0)) x))
208 ++ (let ((xd (etypecase x
209 ++ (single-float
210 ++ (float x 1d0))
211 ++ (double-float
212 ++ x))))
213 ++ (ceiling (- (the (double-float -400d0 400d0)
214 ++ (log xd 10d0))
215 ++ 1d-10))))
216 ++ (fixup (r s m+ k)
217 ++ (if (if high-ok
218 ++ (>= (+ r m+) s)
219 ++ (> (+ r m+) s))
220 ++ (+ k 1)
221 ++ k))
222 ++ (scale (r s m+)
223 ++ (let* ((est (flog v))
224 ++ (scale (the integer (10-to-e (abs est)))))
225 ++ (if (>= est 0)
226 ++ (fixup r (* s scale) m+ est)
227 ++ (fixup (* r scale) s (* m+ scale) est)))))
228 ++ (let (r s m+)
229 ++ (if (>= e 0)
230 ++ (let* ((be (expt float-radix e))
231 ++ (be1 (* be float-radix)))
232 ++ (if (/= f (expt float-radix (1- float-digits)))
233 ++ (setf r (* f be 2)
234 ++ s 2
235 ++ m+ be)
236 ++ (setf r (* f be1 2)
237 ++ s (* float-radix 2)
238 ++ m+ be1)))
239 ++ (if (or (= e min-e)
240 ++ (/= f (expt float-radix (1- float-digits))))
241 ++ (setf r (* f 2)
242 ++ s (* (expt float-radix (- e)) 2)
243 ++ m+ 1)
244 ++ (setf r (* f float-radix 2)
245 ++ s (* (expt float-radix (- 1 e)) 2)
246 ++ m+ float-radix)))
247 ++ (scale r s m+))))))))
248 +
249 +@@ -1922,3 +1952,3 @@
250 + (format-error "incompatible values for k and d")))
251 +- (when (not exp) (setq exp (scale-exponent number)))
252 ++ (when (not exp) (setq exp (accurate-scale-exponent (abs number))))
253 + AGAIN