Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src NetBSD 6.99.26: Switch i386 and amd64 to the x87 default con...
details: https://anonhg.NetBSD.org/src/rev/dd06e632f2e1
branches: trunk
changeset: 791272:dd06e632f2e1
user: joerg <joerg%NetBSD.org@localhost>
date: Mon Nov 11 11:10:45 2013 +0000
description:
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.
diffstat:
distrib/sets/lists/debug/mi | 3 +-
distrib/sets/lists/tests/mi | 3 +-
external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h | 4 -
sys/arch/amd64/amd64/machdep.c | 9 +-
sys/arch/amd64/amd64/netbsd32_machdep.c | 9 +-
sys/arch/amd64/include/fpu.h | 8 +-
sys/arch/i386/i386/machdep.c | 14 ++-
sys/arch/i386/include/npx.h | 8 +-
sys/sys/param.h | 4 +-
tests/lib/libm/Makefile | 3 +-
tests/lib/libm/t_precision.c | 76 +++++++++++++++++++++
11 files changed, 116 insertions(+), 25 deletions(-)
diffs (truncated from 311 to 300 lines):
diff -r 6754f52359c4 -r dd06e632f2e1 distrib/sets/lists/debug/mi
--- a/distrib/sets/lists/debug/mi Mon Nov 11 10:24:53 2013 +0000
+++ b/distrib/sets/lists/debug/mi Mon Nov 11 11:10:45 2013 +0000
@@ -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
diff -r 6754f52359c4 -r dd06e632f2e1 distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Mon Nov 11 10:24:53 2013 +0000
+++ b/distrib/sets/lists/tests/mi Mon Nov 11 11:10:45 2013 +0000
@@ -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
diff -r 6754f52359c4 -r dd06e632f2e1 external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h
--- a/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h Mon Nov 11 10:24:53 2013 +0000
+++ b/external/gpl3/gcc/dist/gcc/config/i386/netbsd-elf.h Mon Nov 11 11:10:45 2013 +0000
@@ -123,10 +123,6 @@
#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
diff -r 6754f52359c4 -r dd06e632f2e1 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Mon Nov 11 10:24:53 2013 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Mon Nov 11 11:10:45 2013 +0000
@@ -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 @@
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__;
diff -r 6754f52359c4 -r dd06e632f2e1 sys/arch/amd64/amd64/netbsd32_machdep.c
--- a/sys/arch/amd64/amd64/netbsd32_machdep.c Mon Nov 11 10:24:53 2013 +0000
+++ b/sys/arch/amd64/amd64/netbsd32_machdep.c Mon Nov 11 11:10:45 2013 +0000
@@ -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 @@
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__;
diff -r 6754f52359c4 -r dd06e632f2e1 sys/arch/amd64/include/fpu.h
--- a/sys/arch/amd64/include/fpu.h Mon Nov 11 10:24:53 2013 +0000
+++ b/sys/arch/amd64/include/fpu.h Mon Nov 11 11:10:45 2013 +0000
@@ -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 @@
#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
diff -r 6754f52359c4 -r dd06e632f2e1 sys/arch/i386/i386/machdep.c
--- a/sys/arch/i386/i386/machdep.c Mon Nov 11 10:24:53 2013 +0000
+++ b/sys/arch/i386/i386/machdep.c Mon Nov 11 11:10:45 2013 +0000
@@ -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 @@
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));
diff -r 6754f52359c4 -r dd06e632f2e1 sys/arch/i386/include/npx.h
--- a/sys/arch/i386/include/npx.h Mon Nov 11 10:24:53 2013 +0000
+++ b/sys/arch/i386/include/npx.h Mon Nov 11 11:10:45 2013 +0000
@@ -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 @@
* 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. */
diff -r 6754f52359c4 -r dd06e632f2e1 sys/sys/param.h
--- a/sys/sys/param.h Mon Nov 11 10:24:53 2013 +0000
+++ b/sys/sys/param.h Mon Nov 11 11:10:45 2013 +0000
@@ -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__)
diff -r 6754f52359c4 -r dd06e632f2e1 tests/lib/libm/Makefile
--- a/tests/lib/libm/Makefile Mon Nov 11 10:24:53 2013 +0000
+++ b/tests/lib/libm/Makefile Mon Nov 11 11:10:45 2013 +0000
@@ -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_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
diff -r 6754f52359c4 -r dd06e632f2e1 tests/lib/libm/t_precision.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libm/t_precision.c Mon Nov 11 11:10:45 2013 +0000
@@ -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);
Home |
Main Index |
Thread Index |
Old Index