Preserve the initial x87 control word in the global FP environment

in preparation for adjusting the default based on the main binary
version.
This commit is contained in:
joerg 2013-11-11 00:31:51 +00:00
parent bf2b340556
commit 0c8d18a9b2
2 changed files with 20 additions and 6 deletions

View File

@ -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>
@ -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 @@ fenv_t __fe_dfl_env = {
*/
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;
}
/*

View File

@ -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 @@ fenv_t __fe_dfl_env = {
};
#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