On Mon, 26 Jan 2009 16:51:28 EST John Baldwin <j...@freebsd.org> 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 <peterjer...@optushome.com.au> 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 <stdio.h> int main(void) { unsigned short cw; __asm__ __volatile__ ("fnstcw %0":"=m"(*&cw)); printf("cw=%#x\n", cw); return 0; } -- bakul PS: <tangent> On a mac, cc -m64 builds 64 bit binaries and cc -m32 builds 32 bit binaries. The following script makes it as easy to do so on a 64 bit FreeBSD -- at least on the few programs I tried. Ideally the right magic needs to be folded in gcc's builtin "specs". #!/bin/sh args=/usr/bin/cc while [ ".$1" != . ] do a=$1; shift case $a in -m32) args="$args -B/usr/lib32 -I/usr/include32 -m32";; *) args="$args $a";; esac done $args Ideally x86_64 platforms run *all* i386 programs (that don't depend on a 32 bit kernel). </tangent> _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"