From owner-freebsd-hackers@FreeBSD.ORG Wed Jan 28 20:41:30 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E83931065970 for ; Wed, 28 Jan 2009 20:41:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from cyrus.watson.org (cyrus.watson.org [65.122.17.42]) by mx1.freebsd.org (Postfix) with ESMTP id B91B18FC12 for ; Wed, 28 Jan 2009 20:41:29 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (pool-98-109-39-197.nwrknj.fios.verizon.net [98.109.39.197]) by cyrus.watson.org (Postfix) with ESMTPSA id 4B87C46B6C; Wed, 28 Jan 2009 15:41:29 -0500 (EST) Received: from localhost (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.14.3/8.14.3) with ESMTP id n0SKekcm099624; Wed, 28 Jan 2009 15:41:23 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Bakul Shah Date: Wed, 28 Jan 2009 15:35:30 -0500 User-Agent: KMail/1.9.7 References: <20071220093950.GA79196@server.vk2pj.dyndns.org> <200901261651.29116.jhb@freebsd.org> <20090128192421.C9E3D5B13@mail.bitblocks.com> In-Reply-To: <20090128192421.C9E3D5B13@mail.bitblocks.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200901281535.31501.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Wed, 28 Jan 2009 15:41:23 -0500 (EST) X-Virus-Scanned: ClamAV 0.94.2/8914/Wed Jan 28 01:40:00 2009 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx Cc: Kostik Belousov , freebsd-hackers@freebsd.org, Carl Shapiro Subject: Re: critical floating point incompatibility X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Jan 2009 20:41:31 -0000 On Wednesday 28 January 2009 2:24:21 pm Bakul Shah wrote: > On Mon, 26 Jan 2009 16:51:28 EST John Baldwin wrote: > > On Friday 21 December 2007 3:16:33 pm Kostik Belousov wrote: > > > On Fri, Dec 21, 2007 at 10:11:24AM -0800, Bakul Shah wrote: > > > > Peter Jeremy wrote: > > > > > On Wed, Dec 19, 2007 at 09:40:34PM -0800, Carl Shapiro wrote: > > > > > >The default setting of the x87 floating point control word on the i386 > > > > > >port is 0x127F. Among other things, this value sets the precision > > > > > >control to double precision. The default setting of the x87 floating > > > > > >point control word on the AMD64 is 0x37F. > > > > > ... > > > > > >It seems clear that the right thing to do is to set the floating point > > > > > >environment to the i386 default for i386 binaries. Is the current > > > > > >behavior intended? > > > > > > > > > > I believe this is an oversight. See the thread beginning > > > > > > > http://lists.freebsd.org/pipermail/freebsd-stable/2007-November/037947.html > > > > > > > > >From reading Bruce's last message in that thread, seems to me > > > > may be default for 64bit binaries should be the same as on > > > > i386. Anyone wanting different behavior can always call > > > > fpsetprec() etc. > > > > > > > > I think the fix is to change __INITIAL_FPUCW__ in > > > > /sys/amd64/include/fpu.h to 0x127F like on i386. > > > I think this shall be done for 32-bit processes only, or we get into > > > another ABI breaking nightmare. > > > > How about something like this: (Carl, can you please test this?) > > Your patch works fine on a recent -current. Here is a > program Carl had sent me more than a year ago for testing > this. May be some varition of it can be added to > compatibility tests. > > #include > int main(void) > { > unsigned short cw; > __asm__ __volatile__ ("fnstcw %0":"=m"(*&cw)); > printf("cw=%#x\n", cw); > return 0; > } > > -- bakul Cool, thanks for testing! -- John Baldwin