<div dir="ltr">This looks great. By chat, you confirmed, you did the <div>multilib compile and link spot check plus it the psxfenv </div><div>test runs on erc32. Go ahead and submit this to newlib@.</div><div><br></div><div>The code has ifdefs for 64-bits. RTEMS has sparc64 support so</div><div>it would be straight forward to follow the x86_64 and i386 pattern</div><div>to add support for sparc64 right after it is merged. </div><div><br></div><div>NOTE: We do not have anyway to execute sparc64 code AFAIK so</div><div>this would be just the multilib compile and link test portion.</div><div><br></div><div>Great job!</div><div><br></div><div>--joel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 3, 2020 at 5:22 PM Eshan dhawan <<a href="mailto:eshandhawan51@gmail.com">eshandhawan51@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Signed-off-by: Eshan dhawan <<a href="mailto:eshandhawan51@gmail.com" target="_blank">eshandhawan51@gmail.com</a>><br>
---<br>
newlib/configure.host | 1 +<br>
newlib/libc/machine/sparc/sys/fenv.h | 85 +++++<br>
newlib/libm/machine/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a> | 1 +<br>
newlib/libm/machine/sparc/Makefile.am | 21 ++<br>
newlib/libm/machine/sparc/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a> | 11 +<br>
newlib/libm/machine/sparc/feclearexcept.c | 7 +<br>
newlib/libm/machine/sparc/fegetenv.c | 7 +<br>
newlib/libm/machine/sparc/fegetexceptflag.c | 7 +<br>
newlib/libm/machine/sparc/fegetround.c | 7 +<br>
newlib/libm/machine/sparc/feholdexcept.c | 7 +<br>
newlib/libm/machine/sparc/fenv.c | 350 ++++++++++++++++++++<br>
newlib/libm/machine/sparc/feraiseexcept.c | 7 +<br>
newlib/libm/machine/sparc/fesetenv.c | 7 +<br>
newlib/libm/machine/sparc/fesetexceptflag.c | 7 +<br>
newlib/libm/machine/sparc/fesetround.c | 7 +<br>
newlib/libm/machine/sparc/fetestexcept.c | 7 +<br>
newlib/libm/machine/sparc/feupdateenv.c | 7 +<br>
17 files changed, 546 insertions(+)<br>
create mode 100644 newlib/libc/machine/sparc/sys/fenv.h<br>
create mode 100644 newlib/libm/machine/sparc/Makefile.am<br>
create mode 100644 newlib/libm/machine/sparc/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a><br>
create mode 100644 newlib/libm/machine/sparc/feclearexcept.c<br>
create mode 100644 newlib/libm/machine/sparc/fegetenv.c<br>
create mode 100644 newlib/libm/machine/sparc/fegetexceptflag.c<br>
create mode 100644 newlib/libm/machine/sparc/fegetround.c<br>
create mode 100644 newlib/libm/machine/sparc/feholdexcept.c<br>
create mode 100644 newlib/libm/machine/sparc/fenv.c<br>
create mode 100644 newlib/libm/machine/sparc/feraiseexcept.c<br>
create mode 100644 newlib/libm/machine/sparc/fesetenv.c<br>
create mode 100644 newlib/libm/machine/sparc/fesetexceptflag.c<br>
create mode 100644 newlib/libm/machine/sparc/fesetround.c<br>
create mode 100644 newlib/libm/machine/sparc/fetestexcept.c<br>
create mode 100644 newlib/libm/machine/sparc/feupdateenv.c<br>
<br>
diff --git a/newlib/configure.host b/newlib/configure.host<br>
index a84c0c80a..f31f8bd1a 100644<br>
--- a/newlib/configure.host<br>
+++ b/newlib/configure.host<br>
@@ -321,6 +321,7 @@ case "${host_cpu}" in<br>
machine_dir=sh<br>
;;<br>
sparc*)<br>
+ libm_machine_dir=sparc<br>
machine_dir=sparc<br>
# FIXME: Might wish to make MALLOC_ALIGNMENT more generic.<br>
newlib_cflags="${newlib_cflags} -DMALLOC_ALIGNMENT=8"<br>
diff --git a/newlib/libc/machine/sparc/sys/fenv.h b/newlib/libc/machine/sparc/sys/fenv.h<br>
new file mode 100644<br>
index 000000000..0d8fb13ea<br>
--- /dev/null<br>
+++ b/newlib/libc/machine/sparc/sys/fenv.h<br>
@@ -0,0 +1,85 @@<br>
+/* $NetBSD: fenv.h,v 1.2 2017/01/14 12:00:13 martin Exp $ */<br>
+<br>
+/*-<br>
+ * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG><br>
+ * All rights reserved.<br>
+ *<br>
+ * Redistribution and use in source and binary forms, with or without<br>
+ * modification, are permitted provided that the following conditions<br>
+ * are met:<br>
+ * 1. Redistributions of source code must retain the above copyright<br>
+ * notice, this list of conditions and the following disclaimer.<br>
+ * 2. Redistributions in binary form must reproduce the above copyright<br>
+ * notice, this list of conditions and the following disclaimer in the<br>
+ * documentation and/or other materials provided with the distribution.<br>
+ *<br>
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND<br>
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE<br>
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF<br>
+ * SUCH DAMAGE.<br>
+ *<br>
+ * $FreeBSD$<br>
+ */<br>
+<br>
+#ifndef _SYS_FENV_H_<br>
+#define _SYS_FENV_H_<br>
+<br>
+#include <stdint.h><br>
+<br>
+#ifdef __arch64__<br>
+typedef uint64_t fenv_t;<br>
+typedef uint64_t fexcept_t;<br>
+#else<br>
+typedef uint32_t fenv_t;<br>
+typedef uint32_t fexcept_t;<br>
+#endif<br>
+<br>
+/*<br>
+ * Exception flags<br>
+ *<br>
+ * Symbols are defined in such a way, to correspond to the accrued<br>
+ * exception bits (aexc) fields of FSR.<br>
+ */<br>
+#define FE_INEXACT 0x00000020 /* 0000100000 */<br>
+#define FE_DIVBYZERO 0x00000040 /* 0001000000 */<br>
+#define FE_UNDERFLOW 0x00000080 /* 0010000000 */<br>
+#define FE_OVERFLOW 0x00000100 /* 0100000000 */<br>
+#define FE_INVALID 0x00000200 /* 1000000000 */<br>
+<br>
+#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \<br>
+ FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)<br>
+<br>
+/*<br>
+ * Rounding modes<br>
+ *<br>
+ * We can't just use the hardware bit values here, because that would<br>
+ * make FE_UPWARD and FE_DOWNWARD negative, which is not allowed.<br>
+ */<br>
+#define FE_TONEAREST 0 /* round to nearest representable number */<br>
+#define FE_TOWARDZERO 1 /* round to zero (truncate) */<br>
+#define FE_UPWARD 2 /* round toward positive infinity */<br>
+#define FE_DOWNWARD 3 /* round toward negative infinity */<br>
+#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \<br>
+ FE_UPWARD | FE_TOWARDZERO)<br>
+#define _ROUND_SHIFT 30<br>
+<br>
+<br>
+<br>
+/* Default floating-point environment */<br>
+extern const fenv_t *_fe_dfl_env;<br>
+#define FE_DFL_ENV _fe_dfl_env<br>
+<br>
+/* We need to be able to map status flag positions to mask flag positions */<br>
+#define _FPUSW_SHIFT 18<br>
+#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)<br>
+<br>
+<br>
+<br>
+#endif /* !_SYS_FENV_H_ */<br>
diff --git a/newlib/libm/machine/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a> b/newlib/libm/machine/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a><br>
index d4635214a..b8cf52bef 100644<br>
--- a/newlib/libm/machine/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a><br>
+++ b/newlib/libm/machine/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a><br>
@@ -33,6 +33,7 @@ if test -n "${libm_machine_dir}"; then<br>
spu) AC_CONFIG_SUBDIRS(spu) ;;<br>
riscv) AC_CONFIG_SUBDIRS(riscv) ;;<br>
x86_64) AC_CONFIG_SUBDIRS(x86_64) ;;<br>
+ sparc) AC_CONFIG_SUBDIRS(sparc) ;;<br>
esac;<br>
if test "${use_libtool}" = "yes"; then<br>
machlib=${libm_machine_dir}/lib${libm_machine_dir}.${aext}<br>
diff --git a/newlib/libm/machine/sparc/Makefile.am b/newlib/libm/machine/sparc/Makefile.am<br>
new file mode 100644<br>
index 000000000..34157760b<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/Makefile.am<br>
@@ -0,0 +1,21 @@<br>
+## Process this file with automake to generate Makefile.in<br>
+<br>
+INCLUDES = -I $(newlib_basedir)/../newlib/libm/common $(NEWLIB_CFLAGS) \<br>
+ $(CROSS_CFLAGS) $(TARGET_CFLAGS)<br>
+<br>
+LIB_SOURCES = \<br>
+ feclearexcept.c fegetenv.c fegetexceptflag.c \<br>
+ fegetround.c feholdexcept.c feraiseexcept.c fesetenv.c \<br>
+ fesetexceptflag.c fesetround.c fetestexcept.c feupdateenv.c \<br>
+ fenv.c<br>
+<br>
+noinst_LIBRARIES = lib.a<br>
+lib_a_SOURCES = $(LIB_SOURCES)<br>
+lib_a_CFLAGS = $(AM_CFLAGS)<br>
+lib_a_CCASFLAGS = $(AM_CCASFLAGS)<br>
+noinst_DATA =<br>
+<br>
+include $(srcdir)/../../../Makefile.shared<br>
+<br>
+ACLOCAL_AMFLAGS = -I ../../.. -I ../../../..<br>
+CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host<br>
diff --git a/newlib/libm/machine/sparc/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a> b/newlib/libm/machine/sparc/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a><br>
new file mode 100644<br>
index 000000000..7a22fa31c<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/<a href="http://configure.in" rel="noreferrer" target="_blank">configure.in</a><br>
@@ -0,0 +1,11 @@<br>
+<br>
+AC_PREREQ(2.59)<br>
+AC_INIT([newlib],[NEWLIB_VERSION])<br>
+AC_CONFIG_SRCDIR([Makefile.am])<br>
+<br>
+AC_CONFIG_AUX_DIR(../../../..)<br>
+<br>
+NEWLIB_CONFIGURE(../../..)<br>
+<br>
+AC_CONFIG_FILES([Makefile])<br>
+AC_OUTPUT<br>
diff --git a/newlib/libm/machine/sparc/feclearexcept.c b/newlib/libm/machine/sparc/feclearexcept.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/feclearexcept.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/fegetenv.c b/newlib/libm/machine/sparc/fegetenv.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/fegetenv.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/fegetexceptflag.c b/newlib/libm/machine/sparc/fegetexceptflag.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/fegetexceptflag.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/fegetround.c b/newlib/libm/machine/sparc/fegetround.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/fegetround.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/feholdexcept.c b/newlib/libm/machine/sparc/feholdexcept.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/feholdexcept.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/fenv.c b/newlib/libm/machine/sparc/fenv.c<br>
new file mode 100644<br>
index 000000000..127898021<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/fenv.c<br>
@@ -0,0 +1,350 @@<br>
+/* $NetBSD: fenv.c,v 1.2 2017/03/22 23:11:09 chs Exp $ */<br>
+<br>
+/*-<br>
+ * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG><br>
+ * All rights reserved.<br>
+ *<br>
+ * Redistribution and use in source and binary forms, with or without<br>
+ * modification, are permitted provided that the following conditions<br>
+ * are met:<br>
+ * 1. Redistributions of source code must retain the above copyright<br>
+ * notice, this list of conditions and the following disclaimer.<br>
+ * 2. Redistributions in binary form must reproduce the above copyright<br>
+ * notice, this list of conditions and the following disclaimer in the<br>
+ * documentation and/or other materials provided with the distribution.<br>
+ *<br>
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND<br>
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE<br>
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
+ */<br>
+#include <sys/cdefs.h><br>
+__RCSID("$NetBSD: fenv.c,v 1.2 2017/03/22 23:11:09 chs Exp $");<br>
+<br>
+<br>
+<br>
+#include <assert.h><br>
+#include <fenv.h><br>
+<br>
+#define _DIAGASSERT(x) assert(x)<br>
+<br>
+#ifdef __weak_alias<br>
+__weak_alias(feclearexcept,_feclearexcept)<br>
+__weak_alias(fedisableexcept,_fedisableexcept)<br>
+__weak_alias(feenableexcept,_feenableexcept)<br>
+__weak_alias(fegetenv,_fegetenv)<br>
+__weak_alias(fegetexcept,_fegetexcept)<br>
+__weak_alias(fegetexceptflag,_fegetexceptflag)<br>
+__weak_alias(fegetround,_fegetround)<br>
+__weak_alias(feholdexcept,_feholdexcept)<br>
+__weak_alias(feraiseexcept,_feraiseexcept)<br>
+__weak_alias(fesetenv,_fesetenv)<br>
+__weak_alias(fesetexceptflag,_fesetexceptflag)<br>
+__weak_alias(fesetround,_fesetround)<br>
+__weak_alias(fetestexcept,_fetestexcept)<br>
+__weak_alias(feupdateenv,_feupdateenv)<br>
+#endif<br>
+<br>
+/* Load floating-point state register (32bits) */<br>
+#define __ldfsr(__r) __asm__ __volatile__ \<br>
+ ("ld %0, %%fsr" : : "m" (__r))<br>
+<br>
+/* Save floating-point state register (32bits) */<br>
+#define __stfsr(__r) __asm__ __volatile__ \<br>
+ ("st %%fsr, %0" : "=m" (*(__r)))<br>
+<br>
+/*<br>
+ * The feclearexcept() function clears the supported floating-point exceptions<br>
+ * represented by `excepts'.<br>
+ */<br>
+int<br>
+feclearexcept(int excepts)<br>
+{<br>
+ fexcept_t r;<br>
+ int ex;<br>
+<br>
+ _DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);<br>
+<br>
+ ex = excepts & FE_ALL_EXCEPT;<br>
+<br>
+ __stfsr(&r);<br>
+ r &= ~ex;<br>
+ __ldfsr(r);<br>
+<br>
+ /* Success */<br>
+ return 0;<br>
+}<br>
+<br>
+/*<br>
+ * The fegetexceptflag() function stores an implementation-defined<br>
+ * representation of the states of the floating-point status flags indicated<br>
+ * by the argument excepts in the object pointed to by the argument flagp.<br>
+ */<br>
+int<br>
+fegetexceptflag(fexcept_t *flagp, int excepts)<br>
+{<br>
+ fexcept_t r;<br>
+ int ex;<br>
+<br>
+ _DIAGASSERT(flagp != NULL);<br>
+ _DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);<br>
+<br>
+ ex = excepts & FE_ALL_EXCEPT;<br>
+<br>
+ __stfsr(&r);<br>
+ *flagp = r & ex;<br>
+<br>
+ /* Success */<br>
+ return 0;<br>
+}<br>
+<br>
+<br>
+/*<br>
+ * This function sets the floating-point status flags indicated by the argument<br>
+ * `excepts' to the states stored in the object pointed to by `flagp'. It does<br>
+ * NOT raise any floating-point exceptions, but only sets the state of the flags.<br>
+ */<br>
+int<br>
+fesetexceptflag(const fexcept_t *flagp, int excepts)<br>
+{<br>
+ fexcept_t r;<br>
+ int ex;<br>
+<br>
+ _DIAGASSERT(flagp != NULL);<br>
+ _DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);<br>
+<br>
+ ex = excepts & FE_ALL_EXCEPT;<br>
+<br>
+ __stfsr(&r);<br>
+ r &= ~ex;<br>
+ r |= *flagp & ex;<br>
+ __ldfsr(r);<br>
+<br>
+ /* Success */<br>
+ return 0;<br>
+}<br>
+<br>
+/*<br>
+ * The feraiseexcept() function raises the supported floating-point exceptions<br>
+ * represented by the argument `excepts'.<br>
+ *<br>
+ * The order in which these floating-point exceptions are raised is unspecified<br>
+ * (by the standard).<br>
+ */<br>
+int<br>
+feraiseexcept(int excepts)<br>
+{<br>
+ volatile double d;<br>
+ int ex;<br>
+<br>
+ _DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);<br>
+<br>
+ ex = excepts & FE_ALL_EXCEPT;<br>
+<br>
+ /*<br>
+ * With a compiler that supports the FENV_ACCESS pragma properly, simple<br>
+ * expressions like '0.0 / 0.0' should be sufficient to generate traps.<br>
+ * Unfortunately, we need to bring a volatile variable into the equation<br>
+ * to prevent incorrect optimizations.<br>
+ */<br>
+ if (ex & FE_INVALID) {<br>
+ d = 0.0;<br>
+ d = 0.0 / d;<br>
+ }<br>
+ if (ex & FE_DIVBYZERO) {<br>
+ d = 0.0;<br>
+ d = 1.0 / d;<br>
+ }<br>
+ if (ex & FE_OVERFLOW) {<br>
+ d = 0x1.ffp1023;<br>
+ d *= 2.0;<br>
+ }<br>
+ if (ex & FE_UNDERFLOW) {<br>
+ d = 0x1p-1022;<br>
+ d /= 0x1p1023;<br>
+ }<br>
+ if (ex & FE_INEXACT) {<br>
+ d = 0x1p-1022;<br>
+ d += 1.0;<br>
+ }<br>
+<br>
+ /* Success */<br>
+ return 0;<br>
+}<br>
+<br>
+/*<br>
+ * The fetestexcept() function determines which of a specified subset of the<br>
+ * floating-point exception flags are currently set. The `excepts' argument<br>
+ * specifies the floating-point status flags to be queried.<br>
+ */<br>
+int<br>
+fetestexcept(int excepts)<br>
+{<br>
+ fexcept_t r;<br>
+<br>
+ _DIAGASSERT((excepts & ~FE_ALL_EXCEPT) == 0);<br>
+<br>
+ __stfsr(&r);<br>
+<br>
+ return r & (excepts & FE_ALL_EXCEPT);<br>
+}<br>
+<br>
+/*<br>
+ * The fegetround() function gets the current rounding direction.<br>
+ */<br>
+int<br>
+fegetround(void)<br>
+{<br>
+ fenv_t r;<br>
+<br>
+ __stfsr(&r);<br>
+<br>
+ return (r >> _ROUND_SHIFT) & _ROUND_MASK;<br>
+}<br>
+<br>
+/*<br>
+ * The fesetround() function establishes the rounding direction represented by<br>
+ * its argument `round'. If the argument is not equal to the value of a rounding<br>
+ * direction macro, the rounding direction is not changed.<br>
+ */<br>
+int<br>
+fesetround(int round)<br>
+{<br>
+ fenv_t r;<br>
+<br>
+ _DIAGASSERT((round & ~_ROUND_MASK) == 0);<br>
+ if (round & ~_ROUND_MASK)<br>
+ return -1;<br>
+<br>
+ __stfsr(&r);<br>
+ r &= ~(_ROUND_MASK << _ROUND_SHIFT);<br>
+ r |= round << _ROUND_SHIFT;<br>
+ __ldfsr(r);<br>
+<br>
+ /* Success */<br>
+ return 0;<br>
+}<br>
+<br>
+/*<br>
+ * The fegetenv() function attempts to store the current floating-point<br>
+ * environment in the object pointed to by envp.<br>
+ */<br>
+int<br>
+fegetenv(fenv_t *envp)<br>
+{<br>
+ _DIAGASSERT(envp != NULL);<br>
+<br>
+ __stfsr(envp);<br>
+<br>
+ /* Success */<br>
+ return 0;<br>
+}<br>
+<br>
+<br>
+/*<br>
+ * The feholdexcept() function saves the current floating-point environment<br>
+ * in the object pointed to by envp, clears the floating-point status flags, and<br>
+ * then installs a non-stop (continue on floating-point exceptions) mode, if<br>
+ * available, for all floating-point exceptions.<br>
+ */<br>
+int<br>
+feholdexcept(fenv_t *envp)<br>
+{<br>
+ fenv_t r;<br>
+<br>
+ _DIAGASSERT(envp != NULL);<br>
+<br>
+ __stfsr(&r);<br>
+ *envp = r;<br>
+ r &= ~(FE_ALL_EXCEPT | _ENABLE_MASK);<br>
+ __ldfsr(r);<br>
+<br>
+ /* Success */<br>
+ return 0;<br>
+}<br>
+<br>
+/*<br>
+ * The fesetenv() function attempts to establish the floating-point environment<br>
+ * represented by the object pointed to by envp. The argument `envp' points<br>
+ * to an object set by a call to fegetenv() or feholdexcept(), or equal a<br>
+ * floating-point environment macro. The fesetenv() function does not raise<br>
+ * floating-point exceptions, but only installs the state of the floating-point<br>
+ * status flags represented through its argument.<br>
+ */<br>
+int<br>
+fesetenv(const fenv_t *envp)<br>
+{<br>
+ _DIAGASSERT(envp != NULL);<br>
+<br>
+ __ldfsr(*envp);<br>
+<br>
+ /* Success */<br>
+ return 0;<br>
+}<br>
+<br>
+<br>
+/*<br>
+ * The feupdateenv() function saves the currently raised floating-point<br>
+ * exceptions in its automatic storage, installs the floating-point environment<br>
+ * represented by the object pointed to by `envp', and then raises the saved<br>
+ * floating-point exceptions. The argument `envp' shall point to an object set<br>
+ * by a call to feholdexcept() or fegetenv(), or equal a floating-point<br>
+ * environment macro.<br>
+ */<br>
+int<br>
+feupdateenv(const fenv_t *envp)<br>
+{<br>
+ fexcept_t r;<br>
+<br>
+ _DIAGASSERT(envp != NULL);<br>
+<br>
+ __stfsr(&r);<br>
+ __ldfsr(*envp);<br>
+<br>
+ _DIAGASSERT((r & ~FE_ALL_EXCEPT) == 0);<br>
+ feraiseexcept(r & FE_ALL_EXCEPT);<br>
+<br>
+ /* Success */<br>
+ return 0;<br>
+}<br>
+<br>
+/*<br>
+ * The following functions are extentions to the standard<br>
+ */<br>
+int<br>
+feenableexcept(int mask)<br>
+{<br>
+ fenv_t old_r, new_r;<br>
+<br>
+ __stfsr(&old_r);<br>
+ new_r = old_r | ((mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);<br>
+ __ldfsr(new_r);<br>
+<br>
+ return (old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT;<br>
+}<br>
+<br>
+int<br>
+fedisableexcept(int mask)<br>
+{<br>
+ fenv_t old_r, new_r;<br>
+<br>
+ __stfsr(&old_r);<br>
+ new_r = old_r & ~((mask & FE_ALL_EXCEPT) << _FPUSW_SHIFT);<br>
+ __ldfsr(new_r);<br>
+<br>
+ return (old_r >> _FPUSW_SHIFT) & FE_ALL_EXCEPT;<br>
+}<br>
+<br>
+int<br>
+fegetexcept(void)<br>
+{<br>
+ fenv_t r;<br>
+<br>
+ __stfsr(&r);<br>
+ return (r & _ENABLE_MASK) >> _FPUSW_SHIFT;<br>
+}<br>
diff --git a/newlib/libm/machine/sparc/feraiseexcept.c b/newlib/libm/machine/sparc/feraiseexcept.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/feraiseexcept.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/fesetenv.c b/newlib/libm/machine/sparc/fesetenv.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/fesetenv.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/fesetexceptflag.c b/newlib/libm/machine/sparc/fesetexceptflag.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/fesetexceptflag.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/fesetround.c b/newlib/libm/machine/sparc/fesetround.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/fesetround.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/fetestexcept.c b/newlib/libm/machine/sparc/fetestexcept.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/fetestexcept.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
diff --git a/newlib/libm/machine/sparc/feupdateenv.c b/newlib/libm/machine/sparc/feupdateenv.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/sparc/feupdateenv.c<br>
@@ -0,0 +1,7 @@<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * (c) Copyright 2019 Joel Sherrill <<a href="mailto:joel@rtems.org" target="_blank">joel@rtems.org</a>><br>
+ */<br>
+<br>
+#include "../../fenv/fenv_stub.c"<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div>