Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libm/arch Preserve the initial x87 control word in the g...



details:   https://anonhg.NetBSD.org/src/rev/8f1e91e45f4e
branches:  trunk
changeset: 791268:8f1e91e45f4e
user:      joerg <joerg%NetBSD.org@localhost>
date:      Mon Nov 11 00:31:51 2013 +0000

description:
Preserve the initial x87 control word in the global FP environment
in preparation for adjusting the default based on the main binary
version.

diffstat:

 lib/libm/arch/i387/fenv.c   |  12 ++++++++----
 lib/libm/arch/x86_64/fenv.c |  14 ++++++++++++--
 2 files changed, 20 insertions(+), 6 deletions(-)

diffs (76 lines):

diff -r 52faefd4af1a -r 8f1e91e45f4e lib/libm/arch/i387/fenv.c
--- a/lib/libm/arch/i387/fenv.c Sun Nov 10 22:08:58 2013 +0000
+++ b/lib/libm/arch/i387/fenv.c Mon Nov 11 00:31:51 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.5 2013/05/29 00:53:19 riastradh Exp $ */
+/* $NetBSD: fenv.c,v 1.6 2013/11/11 00:31:51 joerg Exp $ */
 
 /*-
  * Copyright (c) 2004-2005 David Schultz <das%FreeBSD.ORG@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: fenv.c,v 1.5 2013/05/29 00:53:19 riastradh Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.6 2013/11/11 00:31:51 joerg Exp $");
 
 #include <sys/param.h>
 #include <sys/sysctl.h>
@@ -115,16 +115,20 @@
  */
 static int __HAS_SSE = 0;
 
-static void __test_sse(void) __attribute__ ((constructor));
+static void __init_libm(void) __attribute__ ((constructor, used));
 
-static void __test_sse(void)
+static void __init_libm(void)
 {
        size_t oldlen = sizeof(__HAS_SSE);
        int rv;
+       uint16_t control;
 
        rv = sysctlbyname("machdep.sse", &__HAS_SSE, &oldlen, NULL, 0);
        if (rv == -1)
                __HAS_SSE = 0;
+
+       __fnstcw(&control);
+       __fe_dfl_env.x87.control = control;
 }
 
 /*
diff -r 52faefd4af1a -r 8f1e91e45f4e lib/libm/arch/x86_64/fenv.c
--- a/lib/libm/arch/x86_64/fenv.c       Sun Nov 10 22:08:58 2013 +0000
+++ b/lib/libm/arch/x86_64/fenv.c       Mon Nov 11 00:31:51 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.5 2013/10/18 17:03:02 christos Exp $ */
+/* $NetBSD: fenv.c,v 1.6 2013/11/11 00:31:51 joerg Exp $ */
 
 /*-
  * Copyright (c) 2004-2005 David Schultz <das (at) FreeBSD.ORG>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: fenv.c,v 1.5 2013/10/18 17:03:02 christos Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.6 2013/11/11 00:31:51 joerg Exp $");
 
 #include <assert.h>
 #include <fenv.h>
@@ -100,6 +100,16 @@
 };
 #define FE_DFL_ENV      ((const fenv_t *) &__fe_dfl_env)
 
+static void __init_libm(void) __attribute__ ((constructor, used));
+
+static void __init_libm(void)
+{
+       uint16_t control;
+
+       __fnstcw(&control);
+       __fe_dfl_env.x87.control = control;
+}
+
 
 /*
  * The feclearexcept() function clears the supported floating-point exceptions



Home | Main Index | Thread Index | Old Index