Module Name: src Committed By: joerg Date: Mon Nov 11 11:10:45 UTC 2013
Modified Files: src/distrib/sets/lists/debug: mi src/distrib/sets/lists/tests: mi src/external/gpl3/gcc/dist/gcc/config/i386: netbsd-elf.h src/sys/arch/amd64/amd64: machdep.c netbsd32_machdep.c src/sys/arch/amd64/include: fpu.h src/sys/arch/i386/i386: machdep.c src/sys/arch/i386/include: npx.h src/sys/sys: param.h src/tests/lib/libm: Makefile Added Files: src/tests/lib/libm: t_precision.c Log Message: NetBSD 6.99.26: Switch i386 and amd64 to the x87 default control word as initial value for new processes. This means that long double computations get the expected 63bit mantissa. Binaries tagged as compiled for 6.99.25 and older get the old value. Add a simple test case to ensure that double and long double computation are working correctly. To generate a diff of this commit: cvs rdiff -u -r1.38 -r1.39 src/distrib/sets/lists/debug/mi cvs rdiff -u -r1.547 -r1.548 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.3 -r1.4 \ src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h cvs rdiff -u -r1.198 -r1.199 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.83 -r1.84 src/sys/arch/amd64/amd64/netbsd32_machdep.c cvs rdiff -u -r1.8 -r1.9 src/sys/arch/amd64/include/fpu.h cvs rdiff -u -r1.737 -r1.738 src/sys/arch/i386/i386/machdep.c cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/include/npx.h cvs rdiff -u -r1.434 -r1.435 src/sys/sys/param.h cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libm/Makefile cvs rdiff -u -r0 -r1.1 src/tests/lib/libm/t_precision.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/debug/mi diff -u src/distrib/sets/lists/debug/mi:1.38 src/distrib/sets/lists/debug/mi:1.39 --- src/distrib/sets/lists/debug/mi:1.38 Sat Nov 2 23:23:51 2013 +++ src/distrib/sets/lists/debug/mi Mon Nov 11 11:10:45 2013 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.38 2013/11/02 23:23:51 christos Exp $ +# $NetBSD: mi,v 1.39 2013/11/11 11:10:45 joerg Exp $ ./etc/mtree/set.debug comp-sys-root ./usr/lib/i18n/libBIG5_g.a comp-c-debuglib debuglib @@ -1980,6 +1980,7 @@ ./usr/libdata/debug/usr/tests/lib/libm/t_libm.debug tests-obsolete obsolete ./usr/libdata/debug/usr/tests/lib/libm/t_log.debug tests-lib-debug debug,atf ./usr/libdata/debug/usr/tests/lib/libm/t_pow.debug tests-lib-debug debug,atf +./usr/libdata/debug/usr/tests/lib/libm/t_precision.debug tests-lib-debug debug,atf ./usr/libdata/debug/usr/tests/lib/libm/t_round.debug tests-lib-debug debug,atf ./usr/libdata/debug/usr/tests/lib/libm/t_scalbn.debug tests-lib-debug debug,atf ./usr/libdata/debug/usr/tests/lib/libm/t_sin.debug tests-lib-debug debug,atf Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.547 src/distrib/sets/lists/tests/mi:1.548 --- src/distrib/sets/lists/tests/mi:1.547 Sun Oct 27 09:27:23 2013 +++ src/distrib/sets/lists/tests/mi Mon Nov 11 11:10:45 2013 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.547 2013/10/27 09:27:23 apb Exp $ +# $NetBSD: mi,v 1.548 2013/11/11 11:10:45 joerg Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -2358,6 +2358,7 @@ ./usr/tests/lib/libm/t_libm tests-obsolete obsolete ./usr/tests/lib/libm/t_log tests-lib-tests atf ./usr/tests/lib/libm/t_pow tests-lib-tests atf +./usr/tests/lib/libm/t_precision tests-lib-tests atf ./usr/tests/lib/libm/t_round tests-lib-tests atf ./usr/tests/lib/libm/t_scalbn tests-lib-tests atf ./usr/tests/lib/libm/t_sin tests-lib-tests atf Index: src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h diff -u src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h:1.3 src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h:1.4 --- src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h:1.3 Fri Sep 14 13:00:01 2012 +++ src/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h Mon Nov 11 11:10:45 2013 @@ -123,10 +123,6 @@ along with GCC; see the file COPYING3. #define TARGET_VERSION fprintf (stderr, " (NetBSD/i386 ELF)"); -#undef X87_ENABLE_ARITH -#define X87_ENABLE_ARITH(MODE) \ - (flag_excess_precision == EXCESS_PRECISION_FAST || (MODE) == DFmode) - /* Preserve i386 psABI */ #undef PREFERRED_STACK_BOUNDARY_DEFAULT #define PREFERRED_STACK_BOUNDARY_DEFAULT MIN_STACK_BOUNDARY Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.198 src/sys/arch/amd64/amd64/machdep.c:1.199 --- src/sys/arch/amd64/amd64/machdep.c:1.198 Wed Nov 6 06:23:15 2013 +++ src/sys/arch/amd64/amd64/machdep.c Mon Nov 11 11:10:45 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.198 2013/11/06 06:23:15 mrg Exp $ */ +/* $NetBSD: machdep.c,v 1.199 2013/11/11 11:10:45 joerg Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008, 2011 @@ -111,7 +111,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.198 2013/11/06 06:23:15 mrg Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.199 2013/11/11 11:10:45 joerg Exp $"); /* #define XENDEBUG_LOW */ @@ -1324,7 +1324,10 @@ setregs(struct lwp *l, struct exec_packa pcu_discard(&fpu_ops, false); pcb->pcb_flags = 0; - pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_NPXCW__; + if (pack->ep_osversion >= 699002600) + pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_NPXCW__; + else + pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_COMPAT_NPXCW__; pcb->pcb_savefpu.fp_fxsave.fx_mxcsr = __INITIAL_MXCSR__; pcb->pcb_savefpu.fp_fxsave.fx_mxcsr_mask = __INITIAL_MXCSR_MASK__; Index: src/sys/arch/amd64/amd64/netbsd32_machdep.c diff -u src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.83 src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.84 --- src/sys/arch/amd64/amd64/netbsd32_machdep.c:1.83 Sat Nov 2 00:41:58 2013 +++ src/sys/arch/amd64/amd64/netbsd32_machdep.c Mon Nov 11 11:10:45 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: netbsd32_machdep.c,v 1.83 2013/11/02 00:41:58 christos Exp $ */ +/* $NetBSD: netbsd32_machdep.c,v 1.84 2013/11/11 11:10:45 joerg Exp $ */ /* * Copyright (c) 2001 Wasabi Systems, Inc. @@ -36,7 +36,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.83 2013/11/02 00:41:58 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: netbsd32_machdep.c,v 1.84 2013/11/11 11:10:45 joerg Exp $"); #ifdef _KERNEL_OPT #include "opt_compat_netbsd.h" @@ -141,7 +141,10 @@ netbsd32_setregs(struct lwp *l, struct e l->l_md.md_flags |= MDL_COMPAT32; /* Force iret not sysret */ pcb->pcb_flags = PCB_COMPAT32; - pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_NPXCW__; + if (pack->ep_osversion >= 699002600) + pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_NPXCW__; + else + pcb->pcb_savefpu.fp_fxsave.fx_fcw = __NetBSD_COMPAT_NPXCW__; pcb->pcb_savefpu.fp_fxsave.fx_mxcsr = __INITIAL_MXCSR__; pcb->pcb_savefpu.fp_fxsave.fx_mxcsr_mask = __INITIAL_MXCSR_MASK__; Index: src/sys/arch/amd64/include/fpu.h diff -u src/sys/arch/amd64/include/fpu.h:1.8 src/sys/arch/amd64/include/fpu.h:1.9 --- src/sys/arch/amd64/include/fpu.h:1.8 Wed Oct 23 20:18:50 2013 +++ src/sys/arch/amd64/include/fpu.h Mon Nov 11 11:10:45 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: fpu.h,v 1.8 2013/10/23 20:18:50 drochner Exp $ */ +/* $NetBSD: fpu.h,v 1.9 2013/11/11 11:10:45 joerg Exp $ */ #ifndef _AMD64_FPU_H_ #define _AMD64_FPU_H_ @@ -47,8 +47,10 @@ struct savefpu_i387 { #define __INITIAL_MXCSR__ 0x1f80 #define __INITIAL_MXCSR_MASK__ 0xffbf -/* NetBSD uses IEEE double precision. */ -#define __NetBSD_NPXCW__ 0x127f +/* Modern NetBSD uses the default control word.. */ +#define __NetBSD_NPXCW__ 0x037f +/* NetBSD before 6.99.26 forced IEEE double precision. */ +#define __NetBSD_COMPAT_NPXCW__ 0x127f /* Linux just uses the default control word. */ #define __Linux_NPXCW__ 0x037f Index: src/sys/arch/i386/i386/machdep.c diff -u src/sys/arch/i386/i386/machdep.c:1.737 src/sys/arch/i386/i386/machdep.c:1.738 --- src/sys/arch/i386/i386/machdep.c:1.737 Fri Nov 8 03:12:48 2013 +++ src/sys/arch/i386/i386/machdep.c Mon Nov 11 11:10:45 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.737 2013/11/08 03:12:48 christos Exp $ */ +/* $NetBSD: machdep.c,v 1.738 2013/11/11 11:10:45 joerg Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2004, 2006, 2008, 2009 @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.737 2013/11/08 03:12:48 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.738 2013/11/11 11:10:45 joerg Exp $"); #include "opt_beep.h" #include "opt_compat_ibcs2.h" @@ -862,17 +862,23 @@ setregs(struct lwp *l, struct exec_packa struct pmap *pmap = vm_map_pmap(&l->l_proc->p_vmspace->vm_map); struct pcb *pcb = lwp_getpcb(l); struct trapframe *tf; + uint16_t control; #ifdef USER_LDT pmap_ldt_cleanup(l); #endif pcu_discard(&fpu_ops, false); + if (pack->ep_osversion >= 699002600) + control = __INITIAL_NPXCW__; + else + control = __NetBSD_COMPAT_NPXCW__; + if (i386_use_fxsave) { - pcb->pcb_savefpu.sv_xmm.sv_env.en_cw = __NetBSD_NPXCW__; + pcb->pcb_savefpu.sv_xmm.sv_env.en_cw = control; pcb->pcb_savefpu.sv_xmm.sv_env.en_mxcsr = __INITIAL_MXCSR__; } else - pcb->pcb_savefpu.sv_87.sv_env.en_cw = __NetBSD_NPXCW__; + pcb->pcb_savefpu.sv_87.sv_env.en_cw = control; memcpy(&pcb->pcb_fsd, &gdt[GUDATA_SEL], sizeof(pcb->pcb_fsd)); memcpy(&pcb->pcb_gsd, &gdt[GUDATA_SEL], sizeof(pcb->pcb_gsd)); Index: src/sys/arch/i386/include/npx.h diff -u src/sys/arch/i386/include/npx.h:1.25 src/sys/arch/i386/include/npx.h:1.26 --- src/sys/arch/i386/include/npx.h:1.25 Sat Jul 31 21:47:54 2010 +++ src/sys/arch/i386/include/npx.h Mon Nov 11 11:10:45 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: npx.h,v 1.25 2010/07/31 21:47:54 joerg Exp $ */ +/* $NetBSD: npx.h,v 1.26 2013/11/11 11:10:45 joerg Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -126,8 +126,10 @@ union savefpu { * with all exceptions masked. */ #define __INITIAL_NPXCW__ 0x037f -/* NetBSD uses IEEE double precision. */ -#define __NetBSD_NPXCW__ 0x127f +/* Modern NetBSD uses the default control word.. */ +#define __NetBSD_NPXCW__ 0x037f +/* NetBSD before 6.99.26 forced IEEE double precision. */ +#define __NetBSD_COMPAT_NPXCW__ 0x127f /* FreeBSD leaves some exceptions unmasked as well. */ #define __FreeBSD_NPXCW__ 0x1272 /* iBCS2 goes a bit further and leaves the underflow exception unmasked. */ Index: src/sys/sys/param.h diff -u src/sys/sys/param.h:1.434 src/sys/sys/param.h:1.435 --- src/sys/sys/param.h:1.434 Tue Oct 29 09:53:51 2013 +++ src/sys/sys/param.h Mon Nov 11 11:10:45 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: param.h,v 1.434 2013/10/29 09:53:51 hannken Exp $ */ +/* $NetBSD: param.h,v 1.435 2013/11/11 11:10:45 joerg Exp $ */ /*- * Copyright (c) 1982, 1986, 1989, 1993 @@ -63,7 +63,7 @@ * 2.99.9 (299000900) */ -#define __NetBSD_Version__ 699002500 /* NetBSD 6.99.25 */ +#define __NetBSD_Version__ 699002600 /* NetBSD 6.99.26 */ #define __NetBSD_Prereq__(M,m,p) (((((M) * 100000000) + \ (m) * 1000000) + (p) * 100) <= __NetBSD_Version__) Index: src/tests/lib/libm/Makefile diff -u src/tests/lib/libm/Makefile:1.18 src/tests/lib/libm/Makefile:1.19 --- src/tests/lib/libm/Makefile:1.18 Fri Apr 13 12:31:19 2012 +++ src/tests/lib/libm/Makefile Mon Nov 11 11:10:45 2013 @@ -1,4 +1,4 @@ -# $NetBSD: Makefile,v 1.18 2012/04/13 12:31:19 njoly Exp $ +# $NetBSD: Makefile,v 1.19 2013/11/11 11:10:45 joerg Exp $ .include <bsd.own.mk> @@ -17,6 +17,7 @@ TESTS_C+= t_infinity TESTS_C+= t_ldexp TESTS_C+= t_log TESTS_C+= t_pow +TESTS_C+= t_precision TESTS_C+= t_round TESTS_C+= t_scalbn TESTS_C+= t_sin Added files: Index: src/tests/lib/libm/t_precision.c diff -u /dev/null src/tests/lib/libm/t_precision.c:1.1 --- /dev/null Mon Nov 11 11:10:45 2013 +++ src/tests/lib/libm/t_precision.c Mon Nov 11 11:10:45 2013 @@ -0,0 +1,76 @@ +/* $NetBSD: t_precision.c,v 1.1 2013/11/11 11:10:45 joerg Exp $ */ + +/*- + * Copyright (c) 2013 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Joerg Sonnenberger. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#include <sys/cdefs.h> +__RCSID("$NetBSD: t_precision.c,v 1.1 2013/11/11 11:10:45 joerg Exp $"); + +#include <atf-c.h> +#include <atf-c/config.h> + +#include <float.h> +#include <stdlib.h> + +ATF_TC(t_precision); + +ATF_TC_HEAD(t_precision, tc) +{ + atf_tc_set_md_var(tc, "descr", + "Basic precision test for double and long double"); +} + +volatile double x = 1; +volatile long double y = 1; + +ATF_TC_BODY(t_precision, tc) +{ + x += DBL_EPSILON; + ATF_CHECK(x != 1.0); + x -= 1; + ATF_CHECK(x == DBL_EPSILON); + + x = 2; + x += DBL_EPSILON; + ATF_CHECK(x == 2.0); + + y += LDBL_EPSILON; + ATF_CHECK(y != 1.0L); + y -= 1; + ATF_CHECK(y == LDBL_EPSILON); + y = 2; + y += LDBL_EPSILON; + ATF_CHECK(y == 2.0L); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, t_precision); + + return atf_no_error(); +}