Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Johnston <jjohnstn@redhat.com>2007-09-28 22:58:10 +0400
committerJeff Johnston <jjohnstn@redhat.com>2007-09-28 22:58:10 +0400
commit1671fbe1ca0825a77cb9137a08cf4ad8a48d0f95 (patch)
tree79e8a71cd7363e82effb317acda5cd10c04050c7 /newlib/libm
parente30a7b84aa1527df63f20fe0cb3605afab652d94 (diff)
2007-09-28 Patrick Mansfield <patmans@us.ibm.com>
* libm/machine/spu/headers/dom_chkd_less_than.h: New file. * libm/machine/spu/headers/dom_chkd_negone_one.h: Ditto. * libm/machine/spu/headers/dom_chkf_less_than.h: Ditto. * libm/machine/spu/headers/dom_chkf_negone_one.h: Ditto. * libm/machine/spu/headers/acos.h: Add domain check. * libm/machine/spu/headers/acosf.h: Ditto. * libm/machine/spu/headers/acosh.h: Ditto. * libm/machine/spu/headers/acoshf.h: Ditto. * libm/machine/spu/headers/asin.h: Ditto. * libm/machine/spu/headers/asinf.h: Ditto. * libm/machine/spu/headers/atanh.h: Ditto. * libm/machine/spu/headers/atanhf.h: Ditto. * libm/machine/spu/headers/fmod.h: Ditto. * libm/machine/spu/headers/fmodf.h: Ditto. * libm/machine/spu/headers/log.h: Ditto. * libm/machine/spu/headers/log10.h: Ditto. * libm/machine/spu/headers/log1p.h: Ditto. * libm/machine/spu/headers/log1pf.h: Ditto. * libm/machine/spu/headers/log2.h: Ditto. * libm/machine/spu/headers/log2f.h: Ditto. * libm/machine/spu/headers/sqrt.h: Ditto. * libm/machine/spu/headers/sqrtf.h: Ditto. * libm/machine/spu/headers/tgamma.h: Ditto. * libm/machine/spu/headers/tgammaf.h: Ditto.
Diffstat (limited to 'newlib/libm')
-rw-r--r--newlib/libm/machine/spu/headers/acos.h14
-rw-r--r--newlib/libm/machine/spu/headers/acosf.h14
-rw-r--r--newlib/libm/machine/spu/headers/acosh.h12
-rw-r--r--newlib/libm/machine/spu/headers/acoshf.h12
-rw-r--r--newlib/libm/machine/spu/headers/asin.h14
-rw-r--r--newlib/libm/machine/spu/headers/asinf.h14
-rw-r--r--newlib/libm/machine/spu/headers/atanh.h14
-rw-r--r--newlib/libm/machine/spu/headers/atanhf.h14
-rw-r--r--newlib/libm/machine/spu/headers/dom_chkd_less_than.h59
-rw-r--r--newlib/libm/machine/spu/headers/dom_chkd_negone_one.h69
-rw-r--r--newlib/libm/machine/spu/headers/dom_chkf_less_than.h59
-rw-r--r--newlib/libm/machine/spu/headers/dom_chkf_negone_one.h69
-rw-r--r--newlib/libm/machine/spu/headers/fmod.h14
-rw-r--r--newlib/libm/machine/spu/headers/fmodf.h14
-rw-r--r--newlib/libm/machine/spu/headers/log.h12
-rw-r--r--newlib/libm/machine/spu/headers/log10.h12
-rw-r--r--newlib/libm/machine/spu/headers/log1p.h12
-rw-r--r--newlib/libm/machine/spu/headers/log1pf.h12
-rw-r--r--newlib/libm/machine/spu/headers/log2.h14
-rw-r--r--newlib/libm/machine/spu/headers/log2f.h9
-rw-r--r--newlib/libm/machine/spu/headers/sqrt.h5
-rw-r--r--newlib/libm/machine/spu/headers/sqrtf.h12
-rw-r--r--newlib/libm/machine/spu/headers/tgamma.h26
-rw-r--r--newlib/libm/machine/spu/headers/tgammaf.h25
24 files changed, 514 insertions, 17 deletions
diff --git a/newlib/libm/machine/spu/headers/acos.h b/newlib/libm/machine/spu/headers/acos.h
index a647ef2d5..feec8c329 100644
--- a/newlib/libm/machine/spu/headers/acos.h
+++ b/newlib/libm/machine/spu/headers/acos.h
@@ -1,6 +1,18 @@
#include "headers/acosd2.h"
+#include "headers/dom_chkd_negone_one.h"
static __inline double _acos(double x)
{
- return spu_extract(_acosd2(spu_promote(x, 0)), 0);
+ double res;
+ vector double vx;
+
+ vx = spu_splats(x);
+ res = spu_extract(_acosd2(vx), 0);
+#ifndef _IEEE_LIBM
+ /*
+ * Domain error if not in the interval [-1, +1]
+ */
+ dom_chkd_negone_one(vx);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/acosf.h b/newlib/libm/machine/spu/headers/acosf.h
index ba93fa266..49ab628fc 100644
--- a/newlib/libm/machine/spu/headers/acosf.h
+++ b/newlib/libm/machine/spu/headers/acosf.h
@@ -1,6 +1,18 @@
#include "headers/acosf4.h"
+#include "headers/dom_chkf_negone_one.h"
static __inline float _acosf(float x)
{
- return spu_extract(_acosf4(spu_promote(x, 0)), 0);
+ float res;
+ vector float vx;
+
+ vx = spu_splats(x);
+ res = spu_extract(_acosf4(vx), 0);
+#ifndef _IEEE_LIBM
+ /*
+ * Domain error if not in the interval [-1, +1]
+ */
+ dom_chkf_negone_one(vx);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/acosh.h b/newlib/libm/machine/spu/headers/acosh.h
index 960394b64..d84708a30 100644
--- a/newlib/libm/machine/spu/headers/acosh.h
+++ b/newlib/libm/machine/spu/headers/acosh.h
@@ -1,6 +1,16 @@
#include "headers/acoshd2.h"
+#include "headers/dom_chkd_less_than.h"
static __inline double _acosh(double x)
{
- return spu_extract(_acoshd2(spu_promote(x, 0)), 0);
+ double res;
+ vector double vx;
+ vector double vc = { 1.0, 1.0 };
+
+ vx = spu_promote(x, 0);
+ res = spu_extract(_acoshd2(vx), 0);
+#ifndef _IEEE_LIBM
+ dom_chkd_less_than(vx, vc);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/acoshf.h b/newlib/libm/machine/spu/headers/acoshf.h
index db25aaf51..537706c8a 100644
--- a/newlib/libm/machine/spu/headers/acoshf.h
+++ b/newlib/libm/machine/spu/headers/acoshf.h
@@ -1,6 +1,16 @@
#include "headers/acoshf4.h"
+#include "headers/dom_chkf_less_than.h"
static __inline float _acoshf(float x)
{
- return spu_extract(_acoshf4(spu_promote(x, 0)), 0);
+ float res;
+ vector float vx;
+ vector float vc = { 1.0, 1.0, 1.0, 1.0 };
+
+ vx = spu_promote(x, 0);
+ res = spu_extract(_acoshf4(vx), 0);
+#ifndef _IEEE_LIBM
+ dom_chkf_less_than(vx, vc);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/asin.h b/newlib/libm/machine/spu/headers/asin.h
index 67988a45b..881e532bc 100644
--- a/newlib/libm/machine/spu/headers/asin.h
+++ b/newlib/libm/machine/spu/headers/asin.h
@@ -1,6 +1,18 @@
#include "headers/asind2.h"
+#include "headers/dom_chkd_negone_one.h"
static __inline double _asin(double x)
{
- return spu_extract(_asind2(spu_promote(x, 0)), 0);
+ double res;
+ vector double vx;
+
+ vx = spu_splats(x);
+ res = spu_extract(_asind2(vx), 0);
+#ifndef _IEEE_LIBM
+ /*
+ * Domain error if not in the interval [-1, +1]
+ */
+ dom_chkd_negone_one(vx);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/asinf.h b/newlib/libm/machine/spu/headers/asinf.h
index f60585d54..cb468ecec 100644
--- a/newlib/libm/machine/spu/headers/asinf.h
+++ b/newlib/libm/machine/spu/headers/asinf.h
@@ -1,6 +1,18 @@
#include "headers/asinf4.h"
+#include "headers/dom_chkf_negone_one.h"
static __inline float _asinf(float x)
{
- return spu_extract(_asinf4(spu_promote(x, 0)), 0);
+ float res;
+ vector float vx;
+
+ vx = spu_splats(x);
+ res = spu_extract(_asinf4(vx), 0);
+#ifndef _IEEE_LIBM
+ /*
+ * Domain error if not in the interval [-1, +1]
+ */
+ dom_chkf_negone_one(vx);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/atanh.h b/newlib/libm/machine/spu/headers/atanh.h
index ebc6f96c1..f81ad2ede 100644
--- a/newlib/libm/machine/spu/headers/atanh.h
+++ b/newlib/libm/machine/spu/headers/atanh.h
@@ -1,6 +1,18 @@
#include "headers/atanhd2.h"
+#include "headers/dom_chkd_negone_one.h"
static __inline double _atanh(double x)
{
- return spu_extract(_atanhd2(spu_promote(x, 0)), 0);
+ double res;
+ vector double vx;
+
+ vx = spu_splats(x);
+ res = spu_extract(_atanhd2(vx), 0);
+#ifndef _IEEE_LIBM
+ /*
+ * Domain error if not in the interval [-1, +1]
+ */
+ dom_chkd_negone_one(vx);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/atanhf.h b/newlib/libm/machine/spu/headers/atanhf.h
index e21dfefd1..f838c9f47 100644
--- a/newlib/libm/machine/spu/headers/atanhf.h
+++ b/newlib/libm/machine/spu/headers/atanhf.h
@@ -1,6 +1,18 @@
#include "headers/atanhf4.h"
+#include "headers/dom_chkf_negone_one.h"
static __inline float _atanhf(float x)
{
- return spu_extract(_atanhf4(spu_promote(x, 0)), 0);
+ float res;
+ vector float vx;
+
+ vx = spu_splats(x);
+ res = spu_extract(_atanhf4(vx), 0);
+#ifndef _IEEE_LIBM
+ /*
+ * Domain error if not in the interval [-1, +1]
+ */
+ dom_chkf_negone_one(vx);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/dom_chkd_less_than.h b/newlib/libm/machine/spu/headers/dom_chkd_less_than.h
new file mode 100644
index 000000000..f7018d62a
--- /dev/null
+++ b/newlib/libm/machine/spu/headers/dom_chkd_less_than.h
@@ -0,0 +1,59 @@
+/*
+ Copyright 2007
+ International Business Machines Corporation,
+ Sony Computer Entertainment, Incorporated,
+ Toshiba Corporation,
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * 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.
+ * Neither the names of the copyright holders nor the names of their
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER
+ 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 <errno.h>
+
+/*
+ * dom_chkd_less_than: "domain check double less than"
+ *
+ * Set errno to EDOM if vx < vc.
+ *
+ * This is for scalar use only, the input is a vector double, but both
+ * values in both vectors must be the same.
+ */
+
+static __inline void dom_chkd_less_than (vector double vx, vector double vc)
+{
+ vector unsigned long long domain;
+ vector signed int verrno;
+ vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
+
+ domain = spu_cmpgt(vc, vx);
+ verrno = spu_splats(errno);
+ /*
+ * domain is 2 long longs, but they have the same value. Even so, no
+ * special code is needed to extract the scalar errno (we have all ones
+ * or all zeroes for the preferred scalar slot).
+ */
+ errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
+}
diff --git a/newlib/libm/machine/spu/headers/dom_chkd_negone_one.h b/newlib/libm/machine/spu/headers/dom_chkd_negone_one.h
new file mode 100644
index 000000000..e364f86f8
--- /dev/null
+++ b/newlib/libm/machine/spu/headers/dom_chkd_negone_one.h
@@ -0,0 +1,69 @@
+/*
+ Copyright 2007
+ International Business Machines Corporation,
+ Sony Computer Entertainment, Incorporated,
+ Toshiba Corporation,
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * 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.
+ * Neither the names of the copyright holders nor the names of their
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER
+ 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 <errno.h>
+
+/*
+ * dom_chkd_negone_one: "domain check double negative-one and one":
+ *
+ * Set errno to EDOM if |x| > 1.0.
+ *
+ * This is for scalar use only, the input is a vector double, but both
+ * values in the vector must be the same.
+ *
+ * We *only* set errno, and do not bother setting the actual return value
+ * of any functions to a NAN. That way, we have the same method for double
+ * and single precision (there are no float nans for single precision so
+ * those can't return a nan).
+ *
+ * Note that for newlib, errno is/was a function call, so not so obviously
+ * we are not branchless here. Unknown if adding a branch (and avoiding a
+ * call to __errno) is faster than this current code.
+ */
+
+static __inline void dom_chkd_negone_one (vector double vx)
+{
+ vector unsigned long long domain;
+ vector signed int verrno;
+ vector double ones = { 1.0, 1.0 };
+ vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
+
+ domain = spu_cmpabsgt(vx, ones);
+ verrno = spu_splats(errno);
+ /*
+ * domain is 2 long longs, but they have the same value. Even so, no
+ * special code is needed to extract the scalar errno (we have all ones
+ * or all zeroes for the preferred scalar slot).
+ */
+ errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
+}
diff --git a/newlib/libm/machine/spu/headers/dom_chkf_less_than.h b/newlib/libm/machine/spu/headers/dom_chkf_less_than.h
new file mode 100644
index 000000000..7475b2d91
--- /dev/null
+++ b/newlib/libm/machine/spu/headers/dom_chkf_less_than.h
@@ -0,0 +1,59 @@
+/*
+ Copyright 2007
+ International Business Machines Corporation,
+ Sony Computer Entertainment, Incorporated,
+ Toshiba Corporation,
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * 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.
+ * Neither the names of the copyright holders nor the names of their
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER
+ 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 <errno.h>
+
+/*
+ * dom_chkf_less_than: "domain check float less than"
+ *
+ * Set errno to EDOM if vx < vc.
+ *
+ * This is for scalar use only, the input is a vector float, but both
+ * values in both vectors must be the same.
+ */
+
+static __inline void dom_chkf_less_than (vector float vx, vector float vc)
+{
+ vector unsigned int domain;
+ vector signed int verrno;
+ vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
+
+ domain = spu_cmpgt(vc, vx);
+ verrno = spu_splats(errno);
+ /*
+ * domain is 2 long longs, but they have the same value. Even so, no
+ * special code is needed to extract the scalar errno (we have all ones
+ * or all zeroes for the preferred scalar slot).
+ */
+ errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
+}
diff --git a/newlib/libm/machine/spu/headers/dom_chkf_negone_one.h b/newlib/libm/machine/spu/headers/dom_chkf_negone_one.h
new file mode 100644
index 000000000..f2671a9df
--- /dev/null
+++ b/newlib/libm/machine/spu/headers/dom_chkf_negone_one.h
@@ -0,0 +1,69 @@
+/*
+ Copyright 2007
+ International Business Machines Corporation,
+ Sony Computer Entertainment, Incorporated,
+ Toshiba Corporation,
+
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * 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.
+ * Neither the names of the copyright holders nor the names of their
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 COPYRIGHT OWNER
+ 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 <errno.h>
+
+/*
+ * dom_chkf_negone_one: "domain check float negative-one and one":
+ *
+ * Set errno to EDOM if |x| > 1.0.
+ *
+ * This is for scalar use only, the input is a vector float, but all
+ * values in the vector must be the same.
+ *
+ * We *only* set errno, and do not bother setting the actual return value
+ * of any functions to a NAN. That way, we have the same method for float
+ * and single precision (there are no float nans for single precision so
+ * those can't return a nan).
+ *
+ * Note that for newlib, errno is/was a function call, so not so obviously
+ * we are not branchless here. Unknown if adding a branch (and avoiding a
+ * call to __errno) is faster than this current code.
+ */
+
+static __inline void dom_chkf_negone_one (vector float vx)
+{
+ vector unsigned int domain;
+ vector signed int verrno;
+ vector float ones = { 1.0, 1.0, 1.0, 1.0 };
+ vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
+
+ domain = spu_cmpabsgt(vx, ones);
+ verrno = spu_splats(errno);
+ /*
+ * domain is 4 ints, but they have the same value, even so no special
+ * code is needed to extract the scalar errno (we have all ones or all
+ * zeroes for the preferred scalar slot).
+ */
+ errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
+}
diff --git a/newlib/libm/machine/spu/headers/fmod.h b/newlib/libm/machine/spu/headers/fmod.h
index 1506fb8dc..0236da187 100644
--- a/newlib/libm/machine/spu/headers/fmod.h
+++ b/newlib/libm/machine/spu/headers/fmod.h
@@ -34,6 +34,7 @@
#define _FMOD_H_ 1
#include <spu_intrinsics.h>
+#include <errno.h>
#include "headers/vec_literal.h"
/* This implementation returns zero if y is a denorm or zero.
@@ -57,6 +58,10 @@ static __inline double _fmod(double x, double y)
vec_uint4 sign_mask = (vec_uint4)(VEC_SPLAT_U64(0x8000000000000000ULL));
vec_uint4 implied_1 = (vec_uint4)(VEC_SPLAT_U64(0x0010000000000000ULL));
vec_uint4 mant_mask = (vec_uint4)(VEC_SPLAT_U64(0x000FFFFFFFFFFFFFULL));
+ vec_ullong2 domain;
+ vec_int4 verrno;
+ vec_double2 vc = { 0.0, 0.0 };
+ vec_int4 fail = { EDOM, EDOM, EDOM, EDOM };
vx = (vec_uint4)spu_promote(x, 0);
vy = (vec_uint4)spu_promote(y, 0);
@@ -147,6 +152,15 @@ static __inline double _fmod(double x, double y)
result = spu_sel(spu_andc(result, spu_rlmask(result0, -1)), vx,
resultx);
+#ifndef _IEEE_LIBM
+ /*
+ * If y is zero, set errno to EDOM
+ */
+ domain = spu_cmpeq(vc, (vec_double2) vy);
+ verrno = spu_splats(errno);
+ errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
+#endif
+
return (spu_extract((vec_double2)result, 0));
}
#endif /* _FMOD_H_ */
diff --git a/newlib/libm/machine/spu/headers/fmodf.h b/newlib/libm/machine/spu/headers/fmodf.h
index 496ada490..a62141f97 100644
--- a/newlib/libm/machine/spu/headers/fmodf.h
+++ b/newlib/libm/machine/spu/headers/fmodf.h
@@ -33,6 +33,7 @@
#ifndef _FMODF_H_
#define _FMODF_H_ 1
+#include <errno.h>
#include <spu_intrinsics.h>
#include "headers/vec_literal.h"
@@ -83,6 +84,10 @@ static __inline float _fmodf(float x, float y)
vec_uint4 sign_mask = VEC_SPLAT_U32(0x80000000);
vec_uint4 implied_1 = VEC_SPLAT_U32(0x00800000);
vec_uint4 mant_mask = VEC_SPLAT_U32(0x007FFFFF);
+ vec_uint4 domain;
+ vec_int4 verrno;
+ vec_float4 vc = { 0.0, 0.0, 0.0, 0.0 };
+ vec_int4 fail = { EDOM, EDOM, EDOM, EDOM };
vx = (vec_uint4)spu_promote(x, 0);
vy = (vec_uint4)spu_promote(y, 0);
@@ -150,6 +155,15 @@ static __inline float _fmodf(float x, float y)
result = spu_sel(spu_andc(result, spu_rlmask(result0, -1)), vx,
resultx);
+#ifndef _IEEE_LIBM
+ /*
+ * If y is zero, set errno to EDOM
+ */
+ domain = spu_cmpeq(vc, (vec_float4) vy);
+ verrno = spu_splats(errno);
+ errno = spu_extract(spu_sel(verrno, fail, (vector unsigned int) domain), 0);
+#endif
+
return (spu_extract((vec_float4)result, 0));
#endif /* FMODF_INTEGER_RANGE */
}
diff --git a/newlib/libm/machine/spu/headers/log.h b/newlib/libm/machine/spu/headers/log.h
index 842abbf5e..9bb5e3bff 100644
--- a/newlib/libm/machine/spu/headers/log.h
+++ b/newlib/libm/machine/spu/headers/log.h
@@ -1,6 +1,16 @@
#include "headers/logd2.h"
+#include "headers/dom_chkd_less_than.h"
static __inline double _log(double x)
{
- return spu_extract(_logd2(spu_promote(x, 0)), 0);
+ double res;
+ vector double vx;
+ vector double vc = { 0.0, 0.0 };
+
+ vx = spu_promote(x, 0);
+ res = spu_extract(_logd2(vx), 0);
+#ifndef _IEEE_LIBM
+ dom_chkd_less_than(vx, vc);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/log10.h b/newlib/libm/machine/spu/headers/log10.h
index bc9007139..c3c6f9f80 100644
--- a/newlib/libm/machine/spu/headers/log10.h
+++ b/newlib/libm/machine/spu/headers/log10.h
@@ -1,6 +1,16 @@
#include "headers/log10d2.h"
+#include "headers/dom_chkd_less_than.h"
static __inline double _log10(double x)
{
- return spu_extract(_log10d2(spu_promote(x, 0)), 0);
+ double res;
+ vector double vx;
+ vector double vc = { 0.0, 0.0 };
+
+ vx = spu_promote(x, 0);
+ res = spu_extract(_log10d2(vx), 0);
+#ifndef _IEEE_LIBM
+ dom_chkd_less_than(vx, vc);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/log1p.h b/newlib/libm/machine/spu/headers/log1p.h
index 46244fbfd..758be8d37 100644
--- a/newlib/libm/machine/spu/headers/log1p.h
+++ b/newlib/libm/machine/spu/headers/log1p.h
@@ -1,6 +1,16 @@
#include "headers/log1pd2.h"
+#include "headers/dom_chkd_less_than.h"
static __inline double _log1p(double x)
{
- return spu_extract(_log1pd2(spu_promote(x, 0)), 0);
+ double res;
+ vector double vx;
+ vector double vc = { -1.0, -1.0 };
+
+ vx = spu_promote(x, 0);
+ res = spu_extract(_log1pd2(vx), 0);
+#ifndef _IEEE_LIBM
+ dom_chkd_less_than(vx, vc);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/log1pf.h b/newlib/libm/machine/spu/headers/log1pf.h
index 1eab9c9d2..b2af48669 100644
--- a/newlib/libm/machine/spu/headers/log1pf.h
+++ b/newlib/libm/machine/spu/headers/log1pf.h
@@ -1,6 +1,16 @@
#include "headers/log1pf4.h"
+#include "headers/dom_chkf_less_than.h"
static __inline float _log1pf(float x)
{
- return spu_extract(_log1pf4(spu_promote(x, 0)), 0);
+ float res;
+ vector float vx;
+ vector float vc = { -1.0, -1.0, -1.0, -1.0 };
+
+ vx = spu_promote(x, 0);
+ res = spu_extract(_log1pf4(vx), 0);
+#ifndef _IEEE_LIBM
+ dom_chkf_less_than(vx, vc);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/log2.h b/newlib/libm/machine/spu/headers/log2.h
index 50ab477c5..696bf9fae 100644
--- a/newlib/libm/machine/spu/headers/log2.h
+++ b/newlib/libm/machine/spu/headers/log2.h
@@ -1,6 +1,16 @@
#include "headers/log2d2.h"
+#include "headers/dom_chkd_less_than.h"
-static __inline double _log2(double vx)
+static __inline double _log2(double x)
{
- return spu_extract(_log2d2(spu_promote(vx, 0)), 0);
+ double res;
+ vector double vx;
+ vector double vc = { 0.0, 0.0 };
+
+ vx = spu_promote(x, 0);
+ res = spu_extract(_log2d2(vx), 0);
+#ifndef _IEEE_LIBM
+ dom_chkd_less_than(vx, vc);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/log2f.h b/newlib/libm/machine/spu/headers/log2f.h
index b72665fd4..26717c7c0 100644
--- a/newlib/libm/machine/spu/headers/log2f.h
+++ b/newlib/libm/machine/spu/headers/log2f.h
@@ -33,6 +33,9 @@
#ifndef _LOG2F_H_
#define _LOG2F_H_ 1
+#include <spu_intrinsics.h>
+#include "headers/dom_chkf_less_than.h"
+
/*
* FUNCTION
* float _log2f(float x)
@@ -73,6 +76,8 @@ static __inline float _log2f(float x)
float result;
float x2, x4;
float hi, lo;
+ vector float vx;
+ vector float vc = { 0.0, 0.0, 0.0, 0.0 };
in.f = x;
@@ -109,6 +114,10 @@ static __inline float _log2f(float x)
*/
result += (float)(exponent);
+#ifndef _IEEE_LIBM
+ vx = spu_promote(x, 0);
+ dom_chkf_less_than(vx, vc);
+#endif
return (result);
}
diff --git a/newlib/libm/machine/spu/headers/sqrt.h b/newlib/libm/machine/spu/headers/sqrt.h
index 064c47def..63b034dd9 100644
--- a/newlib/libm/machine/spu/headers/sqrt.h
+++ b/newlib/libm/machine/spu/headers/sqrt.h
@@ -43,6 +43,7 @@
*/
#include <spu_intrinsics.h>
#include "headers/vec_literal.h"
+#include "headers/dom_chkd_less_than.h"
static __inline double _sqrt(double in)
{
@@ -53,6 +54,7 @@ static __inline double _sqrt(double in)
vec_ullong2 mask = VEC_SPLAT_U64(0x7FE0000000000000ULL);
vec_double2 x, dx, de, dd, dy, dg, dy2, dhalf;
vec_double2 denorm, neg;
+ vec_double2 vc = { 0.0, 0.0 };
fhalf = VEC_SPLAT_F32(0.5f);
dhalf = VEC_SPLAT_F64(0.5);
@@ -124,6 +126,9 @@ static __inline double _sqrt(double in)
dg = spu_sel(spu_andc(spu_or(dg, neg), denorm), x, nochange);
+#ifndef _IEEE_LIBM
+ dom_chkd_less_than(spu_splats(in), vc);
+#endif
return (spu_extract(dg, 0));
}
#endif /* _SQRT_H_ */
diff --git a/newlib/libm/machine/spu/headers/sqrtf.h b/newlib/libm/machine/spu/headers/sqrtf.h
index 4ef91428b..c1f5ab223 100644
--- a/newlib/libm/machine/spu/headers/sqrtf.h
+++ b/newlib/libm/machine/spu/headers/sqrtf.h
@@ -1,6 +1,16 @@
#include "headers/sqrtf4.h"
+#include "headers/dom_chkf_less_than.h"
static __inline float _sqrtf(float in)
{
- return spu_extract(_sqrtf4(spu_promote(in, 0)), 0);
+ float res;
+ vector float vx;
+ vector float vc = { 0.0, 0.0, 0.0, 0.0 };
+
+ vx = spu_promote(in, 0);
+ res = spu_extract(_sqrtf4(vx), 0);
+#ifndef _IEEE_LIBM
+ dom_chkf_less_than(vx, vc);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/tgamma.h b/newlib/libm/machine/spu/headers/tgamma.h
index ea0c32e0f..bd2f31f27 100644
--- a/newlib/libm/machine/spu/headers/tgamma.h
+++ b/newlib/libm/machine/spu/headers/tgamma.h
@@ -1,6 +1,30 @@
+#include <errno.h>
+#include "headers/truncd2.h"
#include "headers/tgammad2.h"
static __inline double _tgamma(double x)
{
- return spu_extract(_tgammad2(spu_promote(x, 0)), 0);
+ double res;
+ vector double vx;
+ vector double truncx;
+ vector double vc = { 0.0, 0.0 };
+ vector unsigned long long cmpres;
+ vector signed int verrno, ferrno;
+ vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
+
+ vx = spu_promote(x, 0);
+ res = spu_extract(_tgammad2(vx), 0);
+
+#ifndef _IEEE_LIBM
+ /*
+ * use vector truncd2 rather than splat x, and splat truncx.
+ */
+ truncx = _truncd2(vx);
+ cmpres = spu_cmpeq(truncx, vx);
+ verrno = spu_splats(errno);
+ ferrno = spu_sel(verrno, fail, (vector unsigned int) cmpres);
+ cmpres = spu_cmpgt(vc, vx);
+ errno = spu_extract(spu_sel(verrno, ferrno, (vector unsigned int) cmpres), 0);
+#endif
+ return res;
}
diff --git a/newlib/libm/machine/spu/headers/tgammaf.h b/newlib/libm/machine/spu/headers/tgammaf.h
index c555d35b2..a30928c60 100644
--- a/newlib/libm/machine/spu/headers/tgammaf.h
+++ b/newlib/libm/machine/spu/headers/tgammaf.h
@@ -1,6 +1,29 @@
+#include <errno.h>
+#include "headers/truncf4.h"
#include "headers/tgammaf4.h"
static __inline float _tgammaf(float x)
{
- return spu_extract(_tgammaf4(spu_promote(x, 0)), 0);
+ float res;
+ vector float vx;
+ vector float truncx;
+ vector float vc = { 0.0, 0.0 };
+ vector unsigned int cmpres;
+ vector signed int verrno, ferrno;
+ vector signed int fail = { EDOM, EDOM, EDOM, EDOM };
+
+ vx = spu_promote(x, 0);
+ res = spu_extract(_tgammaf4(vx), 0);
+#ifndef _IEEE_LIBM
+ /*
+ * use vector truncf4 rather than splat x, and splat truncx.
+ */
+ truncx = _truncf4(vx);
+ cmpres = spu_cmpeq(truncx, vx);
+ verrno = spu_splats(errno);
+ ferrno = spu_sel(verrno, fail, (vector unsigned int) cmpres);
+ cmpres = spu_cmpgt(vc, vx);
+ errno = spu_extract(spu_sel(verrno, ferrno, (vector unsigned int) cmpres), 0);
+#endif
+ return res;
}