summaryrefslogtreecommitdiffstats
path: root/lib/msun/amd64
diff options
context:
space:
mode:
authordas <das@FreeBSD.org>2005-03-16 19:03:46 +0000
committerdas <das@FreeBSD.org>2005-03-16 19:03:46 +0000
commit6448887f3bd81c49f6bad7a48dc2c5b80eab84cb (patch)
treeed1345d1aaf08f9b2af1cfc6cc10e15b82d917d1 /lib/msun/amd64
parentf472dda708da18436fce04e1b640051e98b0bcf9 (diff)
downloadFreeBSD-src-6448887f3bd81c49f6bad7a48dc2c5b80eab84cb.zip
FreeBSD-src-6448887f3bd81c49f6bad7a48dc2c5b80eab84cb.tar.gz
Replace fegetmask() and fesetmask() with feenableexcept(),
fedisableexcept(), and fegetexcept(). These two sets of routines provide the same functionality. I implemented the former as an undocumented internal interface to make the regression test easier to write. However, fe(enable|disable|get)except() is already part of glibc, and I would like to avoid gratuitous differences. The only major flaw in the glibc API is that there's no good way to report errors on processors that don't support all the unmasked exceptions.
Diffstat (limited to 'lib/msun/amd64')
-rw-r--r--lib/msun/amd64/fenv.c27
-rw-r--r--lib/msun/amd64/fenv.h7
2 files changed, 26 insertions, 8 deletions
diff --git a/lib/msun/amd64/fenv.c b/lib/msun/amd64/fenv.c
index dd21dad..95c82de 100644
--- a/lib/msun/amd64/fenv.c
+++ b/lib/msun/amd64/fenv.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -113,19 +113,36 @@ feupdateenv(const fenv_t *envp)
}
int
-__fesetmask(int mask)
+__feenableexcept(int mask)
{
int mxcsr, control, omask;
+ mask &= FE_ALL_EXCEPT;
__fnstcw(&control);
__stmxcsr(&mxcsr);
omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
- control = (control | FE_ALL_EXCEPT) & ~mask;
+ control &= ~mask;
__fldcw(control);
- mxcsr |= FE_ALL_EXCEPT << _SSE_EMASK_SHIFT;
mxcsr &= ~(mask << _SSE_EMASK_SHIFT);
__ldmxcsr(mxcsr);
return (~omask);
}
-__weak_reference(__fesetmask, fesetmask);
+int
+__fedisableexcept(int mask)
+{
+ int mxcsr, control, omask;
+
+ mask &= FE_ALL_EXCEPT;
+ __fnstcw(&control);
+ __stmxcsr(&mxcsr);
+ omask = (control | mxcsr >> _SSE_EMASK_SHIFT) & FE_ALL_EXCEPT;
+ control |= mask;
+ __fldcw(control);
+ mxcsr |= mask << _SSE_EMASK_SHIFT;
+ __ldmxcsr(mxcsr);
+ return (~omask);
+}
+
+__weak_reference(__feenableexcept, feenableexcept);
+__weak_reference(__fedisableexcept, fedisableexcept);
diff --git a/lib/msun/amd64/fenv.h b/lib/msun/amd64/fenv.h
index 29efad9..cbed18e 100644
--- a/lib/msun/amd64/fenv.h
+++ b/lib/msun/amd64/fenv.h
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -180,10 +180,11 @@ int feupdateenv(const fenv_t *__envp);
#if __BSD_VISIBLE
-int fesetmask(int __mask);
+int feenableexcept(int __mask);
+int fedisableexcpt(int __mask);
static __inline int
-fegetmask(void)
+fegetexcept(void)
{
int __control;
OpenPOWER on IntegriCloud