fenv-x86.c revision cacc4e75dbbff469c10a505168208f064c6c385c
/*-
* Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* 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
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 "namespace.h"
#include "fenv.h"*/
#if 0
const fenv_t __fe_dfl_env = {
0x0000,
0x0000,
0x1f80,
0xffffffff,
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }
};
#endif
enum __sse_support __has_sse =
#ifdef __SSE__
#else
#endif
"cpuid\n\tpopl %%ebx" \
: "=d" (*(x)) : : "eax", "ecx")
/*
* Test for SSE support on this processor. We need to do this because
* of the program was compiled to use SSE floating-point, but we can't
* use SSE on older processors.
*/
int
__test_sse(void)
{
int dx_features;
/* Am I a 486? */
/* Not a 486, so CPUID should work. */
if (dx_features & 0x2000000) {
return (1);
}
}
return (0);
}
#if 0 /* later */
int
{
int mxcsr;
if (__HAS_SSE()) {
}
return (0);
}
int
{
__fwait();
return (0);
}
int
{
/*
* fnstenv masks all exceptions, so we need to save and
* restore the control word to avoid this side effect.
*/
if (__HAS_SSE()) {
}
return (0);
}
int
{
int mxcsr;
__fnclex();
if (__HAS_SSE()) {
mxcsr &= ~FE_ALL_EXCEPT;
}
return (0);
}
int
{
if (__HAS_SSE())
else
mxcsr = 0;
return (0);
}
int
__feenableexcept(int mask)
{
mask &= FE_ALL_EXCEPT;
if (__HAS_SSE())
else
mxcsr = 0;
if (__HAS_SSE()) {
}
return (~omask);
}
int
__fedisableexcept(int mask)
{
mask &= FE_ALL_EXCEPT;
if (__HAS_SSE())
else
mxcsr = 0;
if (__HAS_SSE()) {
}
return (~omask);
}
#endif /* later */