From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mark H Weaver Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] Miscellaneous for 2.0 Date: Tue, 01 Mar 2011 13:55:04 -0500 Message-ID: <87mxlesmbb.fsf@netris.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1299007757 31516 80.91.229.12 (1 Mar 2011 19:29:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 1 Mar 2011 19:29:17 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Tue Mar 01 20:29:13 2011 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PuVFv-0004H8-Sz for guile-devel@m.gmane.org; Tue, 01 Mar 2011 20:29:12 +0100 Original-Received: from localhost ([127.0.0.1]:40647 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PuVFv-0005lL-9f for guile-devel@m.gmane.org; Tue, 01 Mar 2011 14:29:11 -0500 Original-Received: from [140.186.70.92] (port=58207 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PuUjP-0008Ky-Bs for guile-devel@gnu.org; Tue, 01 Mar 2011 13:59:29 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PuUjG-0005s6-RB for guile-devel@gnu.org; Tue, 01 Mar 2011 13:55:28 -0500 Original-Received: from world.peace.net ([216.204.32.208]:34004) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PuUjG-0005qV-KY for guile-devel@gnu.org; Tue, 01 Mar 2011 13:55:26 -0500 Original-Received: from ip68-9-118-38.ri.ri.cox.net ([68.9.118.38] helo=freedomincluded) by world.peace.net with esmtpa (Exim 4.69) (envelope-from ) id 1PuUix-0004tY-3x; Tue, 01 Mar 2011 13:55:07 -0500 Original-Received: from mhw by freedomincluded with local (Exim 4.69) (envelope-from ) id 1PuUiv-0006xe-7D; Tue, 01 Mar 2011 13:55:05 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 216.204.32.208 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:11740 Archived-At: --=-=-= Here are a few simple patches for 2.0 which should be non-controversial. I'd like to apply these to both stable-2.0 and master. Any objections? Mark --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-Fix-bytevectors-VALIDATE_REAL-to-test-for-reals-not-.patch Content-Description: Fix bytevectors VALIDATE_REAL to test for reals, not rationals >From d8fa1a889ab3335fff2a4b468cf3e809f05d1add Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Tue, 1 Mar 2011 12:46:38 -0500 Subject: [PATCH 1/4] Fix bytevectors VALIDATE_REAL to test for reals, not rationals Reported and fixed by Daniel Llorens . * libguile/bytevectors.c (VALIDATE_REAL): Test for reals, not rationals. * test-suite/tests/srfi-4.test (f32 vectors, f64 vectors): Add tests. --- libguile/bytevectors.c | 2 +- test-suite/tests/srfi-4.test | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/libguile/bytevectors.c b/libguile/bytevectors.c index f014697..a969e3b 100644 --- a/libguile/bytevectors.c +++ b/libguile/bytevectors.c @@ -1667,7 +1667,7 @@ double_from_foreign_endianness (const union scm_ieee754_double *source) /* FIXME: SCM_VALIDATE_REAL rejects integers, etc. grrr */ #define VALIDATE_REAL(pos, v) \ do { \ - SCM_ASSERT_TYPE (scm_is_true (scm_rational_p (v)), v, pos, FUNC_NAME, "real"); \ + SCM_ASSERT_TYPE (scm_is_real (v), v, pos, FUNC_NAME, "real"); \ } while (0) /* Templace getters and setters. */ diff --git a/test-suite/tests/srfi-4.test b/test-suite/tests/srfi-4.test index d7e5b1a..0cdfb66 100644 --- a/test-suite/tests/srfi-4.test +++ b/test-suite/tests/srfi-4.test @@ -352,7 +352,10 @@ (pass-if "make-f32vector" (equal? (list->f32vector '(7 7 7 7)) - (make-f32vector 4 7)))) + (make-f32vector 4 7))) + + (pass-if "+inf.0, -inf.0, +nan.0 in f32vector" + (f32vector? #f32(+inf.0 -inf.0 +nan.0)))) (with-test-prefix "f64 vectors" @@ -389,4 +392,7 @@ (pass-if "make-f64vector" (equal? (list->f64vector '(7 7 7 7)) - (make-f64vector 4 7)))) + (make-f64vector 4 7))) + + (pass-if "+inf.0, -inf.0, +nan.0 in f64vector" + (f64vector? #f64(+inf.0 -inf.0 +nan.0)))) -- 1.7.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-Fix-description-of-the-R6RS-finite-in-manual.patch Content-Description: Fix description of the R6RS `finite?' in manual >From 1fe145a563def1a115db8c810b6c3446ebe94538 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Tue, 1 Mar 2011 12:37:01 -0500 Subject: [PATCH 2/4] Fix description of the R6RS `finite?' in manual * doc/ref/r6rs.texi (rnrs base): `(finite? x)' returns true iff x is neither infinite nor a NaN. Previously, it stated that `finite?' was the negation of `infinite?', which was incorrect because NaNs are neither finite nor infinite. Combine description of 'nan?' with those of `finite?' and `infinite?'. --- doc/ref/r6rs.texi | 13 ++++++++----- 1 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/ref/r6rs.texi b/doc/ref/r6rs.texi index c1ac541..8f89286 100644 --- a/doc/ref/r6rs.texi +++ b/doc/ref/r6rs.texi @@ -356,7 +356,6 @@ grouped below by the existing manual sections to which they correspond. @deffn {Scheme Procedure} real? x @deffnx {Scheme Procedure} rational? x -@deffnx {Scheme Procedure} nan? x @deffnx {Scheme Procedure} numerator x @deffnx {Scheme Procedure} denominator x @deffnx {Scheme Procedure} rationalize x eps @@ -542,11 +541,15 @@ loss of numerical precision. imaginary parts are zero. @end deffn -@deffn {Scheme Procedure} finite? x +@deffn {Scheme Procedure} nan? x @deffnx {Scheme Procedure} infinite? x -@code{infinite?} returns @code{#t} if @var{x} is an infinite value, -@code{#f} otherwise. @code{finite?} returns the negation of -@code{infinite?}. +@deffnx {Scheme Procedure} finite? x +@code{nan?} returns @code{#t} if @var{x} is a NaN value, @code{#f} +otherwise. @code{infinite?} returns @code{#t} if @var{x} is an infinite +value, @code{#f} otherwise. @code{finite?} returns @code{#t} if @var{x} +is neither infinite nor a NaN value, otherwise it returns @code{#f}. +Every real number satisfies exactly one of these predicates. An +exception is raised if @var{x} is not real. @end deffn @deffn {Scheme Syntax} assert expr -- 1.7.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0003-Update-comments-regarding-GMP-earlier-than-4.2.patch Content-Description: Update comments regarding GMP earlier than 4.2. >From d929345ce019187bad5184e6ff3c31693ae1dddb Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Tue, 22 Feb 2011 21:39:37 -0500 Subject: [PATCH 3/4] Update comments regarding GMP earlier than 4.2. * libguile/numbers.c: Update comments regarding GMP earlier than 4.2. Remove speculations about versions of GMP that had not yet been released when the comments were written. Replace them with facts that are now known about the changes made in GMP 4.2. --- libguile/numbers.c | 32 ++++++++++++++++++-------------- 1 files changed, 18 insertions(+), 14 deletions(-) diff --git a/libguile/numbers.c b/libguile/numbers.c index b8cfa5d..be86eb5 100644 --- a/libguile/numbers.c +++ b/libguile/numbers.c @@ -134,9 +134,9 @@ static double acosh (double x) { return log (x + sqrt (x * x - 1)); } static double atanh (double x) { return 0.5 * log ((1 + x) / (1 - x)); } #endif -/* mpz_cmp_d in gmp 4.1.3 doesn't recognise infinities, so xmpz_cmp_d uses - an explicit check. In some future gmp (don't know what version number), - mpz_cmp_d is supposed to do this itself. */ +/* mpz_cmp_d in GMP before 4.2 didn't recognise infinities, so + xmpz_cmp_d uses an explicit check. Starting with GMP 4.2 (released + in March 2006), mpz_cmp_d now handles infinities properly. */ #if 1 #define xmpz_cmp_d(z, d) \ (isinf (d) ? (d < 0.0 ? 1 : -1) : mpz_cmp_d (z, d)) @@ -316,16 +316,15 @@ scm_i_dbl2num (double u) we need to use mpz_getlimbn. mpz_tstbit is not right, it treats negatives as twos complement. - In current gmp 4.1.3, mpz_get_d rounding is unspecified. It ends up - following the hardware rounding mode, but applied to the absolute value - of the mpz_t operand. This is not what we want so we put the high - DBL_MANT_DIG bits into a temporary. In some future gmp, don't know when, - mpz_get_d is supposed to always truncate towards zero. + In GMP before 4.2, mpz_get_d rounding was unspecified. It ended up + following the hardware rounding mode, but applied to the absolute + value of the mpz_t operand. This is not what we want so we put the + high DBL_MANT_DIG bits into a temporary. Starting with GMP 4.2 + (released in March 2006) mpz_get_d now always truncates towards zero. - ENHANCE-ME: The temporary init+clear to force the rounding in gmp 4.1.3 - is a slowdown. It'd be faster to pick out the relevant high bits with - mpz_getlimbn if we could be bothered coding that, and if the new - truncating gmp doesn't come out. */ + ENHANCE-ME: The temporary init+clear to force the rounding in GMP + before 4.2 is a slowdown. It'd be faster to pick out the relevant + high bits with mpz_getlimbn. */ double scm_i_big2dbl (SCM b) @@ -337,7 +336,12 @@ scm_i_big2dbl (SCM b) #if 1 { - /* Current GMP, eg. 4.1.3, force truncation towards zero */ + /* For GMP earlier than 4.2, force truncation towards zero */ + + /* FIXME: DBL_MANT_DIG is the number of base-`FLT_RADIX' digits, + _not_ the number of bits, so this code will break badly on a + system with non-binary doubles. */ + mpz_t tmp; if (bits > DBL_MANT_DIG) { @@ -353,7 +357,7 @@ scm_i_big2dbl (SCM b) } } #else - /* Future GMP */ + /* GMP 4.2 or later */ result = mpz_get_d (SCM_I_BIG_MPZ (b)); #endif -- 1.7.1 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0004-Remove-incorrect-footnote-from-GOOPS-manual.patch Content-Description: Remove incorrect footnote from GOOPS manual >From 4c912a67e14847f3bb70fd23bdb72e768735dbb3 Mon Sep 17 00:00:00 2001 From: Mark H Weaver Date: Tue, 1 Mar 2011 13:46:08 -0500 Subject: [PATCH 4/4] Remove incorrect footnote from GOOPS manual * doc/ref/goops.texi (Inheritance): Remove footnote which incorrectly stated that was not shown in the class hierarchy figure. --- doc/ref/goops.texi | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/doc/ref/goops.texi b/doc/ref/goops.texi index 95e71da..362a6e3 100644 --- a/doc/ref/goops.texi +++ b/doc/ref/goops.texi @@ -1104,9 +1104,7 @@ Those class definitions define a hierarchy which is shown in @ref{fig:hier}. In this figure, the class @code{} is also shown; this class is the superclass of all Scheme objects. In particular, @code{} is the superclass of all standard Scheme -types.@footnote{@code{}, which is the direct subclass of -@code{} and the direct superclass of @code{}, has been -omitted in this figure.} +types. @float Figure,fig:hier @iftex -- 1.7.1 --=-=-=--