From owner-freebsd-sparc64@FreeBSD.ORG Sat Dec 23 22:23:16 2006 Return-Path: X-Original-To: freebsd-sparc64@freebsd.org Delivered-To: freebsd-sparc64@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 4A01C16A49E for ; Sat, 23 Dec 2006 22:23:16 +0000 (UTC) (envelope-from crewman6@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.226]) by mx1.freebsd.org (Postfix) with ESMTP id D7A3A13C455 for ; Sat, 23 Dec 2006 22:23:15 +0000 (UTC) (envelope-from crewman6@gmail.com) Received: by wx-out-0506.google.com with SMTP id s18so3033315wxc for ; Sat, 23 Dec 2006 14:23:14 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:references; b=JK8g5NeLBfnvrAmLB7RC3FP8PyJecS1hzhFWmbCv2nxUCzn9tCZHPsOMkullJy8eWWkg2F9HTRCJ6AkYJuelCE5juWMSQIqtUWQhj6Wu/+gwgR0HUlHpJSxFFDOwwQVJ70lzsIhjwZFboCH1AXejIyqmebUNinxUff3RpNvDbpE= Received: by 10.70.67.10 with SMTP id p10mr19152057wxa.1166910985253; Sat, 23 Dec 2006 13:56:25 -0800 (PST) Received: by 10.70.31.2 with HTTP; Sat, 23 Dec 2006 13:56:25 -0800 (PST) Message-ID: Date: Sat, 23 Dec 2006 15:56:25 -0600 From: crewman6@gmail.com To: freebsd-sparc64@freebsd.org In-Reply-To: <9ca8670b0612231351u62a3daeav6161f10fcad87d3b@mail.gmail.com> MIME-Version: 1.0 References: <200612231450.kBNEoHeO070170@freefall.freebsd.org> <9ca8670b0612231351u62a3daeav6161f10fcad87d3b@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline X-Content-Filtered-By: Mailman/MimeDel 2.1.5 Cc: Subject: Re: sparc64/107130: conversion from long double to long giving incorrect values X-BeenThere: freebsd-sparc64@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to the Sparc List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 23 Dec 2006 22:23:16 -0000 > > > ---------- Forwarded message ---------- > From: Marius Strobl > Date: Dec 23, 2006 8:50 AM > Subject: Re: sparc64/107130: conversion from long double to long giving > incorrect values > To: freebsd-sparc64@freebsd.org > > The following reply was made to PR sparc64/107130; it has been noted by > GNATS. > > From: Marius Strobl > To: Jim White > Cc: freebsd-gnats-submit@freebsd.org > Subject: Re: sparc64/107130: conversion from long double to long giving > incorrect values > Date: Sat, 23 Dec 2006 15:28:54 +0100 > > On Sat, Dec 23, 2006 at 07:54:11AM +0000, Jim White wrote: > > > > >How-To-Repeat: > > #include > > int main() > > { > > long double i; > > for (i=0;;i=i-1.0) > > printf("%Lf %d %ld %lld %f\n",i,(int)i,(long)i,(long > long)i,(double)i); > > return 0; > > } > > > > Sample Output: > > 0.000000 0 0 0 0.000000 > > -1.000000 -1 -1 -1 -1.000000 > > -2.000000 -2 -1 -1 -2.000000 > > -3.000000 -3 -1 -1 -3.000000 > > - 4.000000 -4 -1 -1 -4.000000 > > -5.000000 -5 -1 -1 -5.000000 > > -6.000000 -6 -1 -1 -6.000000 > > -7.000000 -7 -1 -1 -7.000000 > > -8.000000 -8 -1 -1 -8.000000 > > -9.000000 -9 -1 -1 -9.000000 > > -10.000000 -10 -1 -1 -10.000000 > > > > This appears to be caused by a typo in the FPU emulation code. > Could you please give the patch below a try (after applying > re-compile and re-install libc, if you're linking your > application statically re-compile it afterwards, too)? > > Marius > > > Index: fpu_implode.c > =================================================================== > RCS file: /usr/data/bsd/cvs/fbsd/src/lib/libc/sparc64/fpu/fpu_implode.c,v > retrieving revision 1.6 > diff -u -r1.6 fpu_implode.c > --- fpu_implode.c 28 Jul 2004 05:41:05 -0000 1.6 > +++ fpu_implode.c 23 Dec 2006 14:20:13 -0000 > @@ -277,7 +277,7 @@ > if (i >= ((u_int64_t)0x8000000000000000LL + sign)) > break; > if (sign) > - i = -1; > + i = -i; > res[1] = (int)i; > return (i >> 32); > > After applying the patch, the conversion results in correct values.