<div dir="ltr">Unless someone comments in the next 24 hours, <div>I think this is ready to post to newlib's mailing list</div><div>and get merged.</div><div><br></div><div>It looks like a faithful adaptation of the FreeBSD code to </div><div>newlib's libm architecture.</div><div><br></div><div>--joel</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Jun 1, 2020 at 7:10 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">This patch adds support for ARM fenv to newlib<br>
<br>
the files are taken from FreeBSD<br>
<br>
Signed-off-by: Eshan dhawan <<a href="mailto:eshandhawan51@gmail.com" target="_blank">eshandhawan51@gmail.com</a>><br>
---<br>
newlib/libc/machine/arm/machine/acle-compat.h | 182 ++++++++++<br>
newlib/libc/machine/arm/machine/fenv-mangle.h | 53 +++<br>
.../libc/machine/arm/machine/fenv-softfloat.h | 187 ++++++++++<br>
newlib/libc/machine/arm/machine/fenv-vfp.h | 187 ++++++++++<br>
newlib/libc/machine/arm/sys/fenv.h | 122 +++++++<br>
newlib/libm/machine/arm/Makefile.am | 18 +-<br>
newlib/libm/machine/arm/fe_dfl_env.c | 7 +<br>
newlib/libm/machine/arm/feclearexcept.c | 7 +<br>
newlib/libm/machine/arm/fegetenv.c | 7 +<br>
newlib/libm/machine/arm/fegetexceptflag.c | 7 +<br>
newlib/libm/machine/arm/fegetround.c | 7 +<br>
newlib/libm/machine/arm/feholdexcept.c | 7 +<br>
newlib/libm/machine/arm/fenv-softfp.c | 32 ++<br>
newlib/libm/machine/arm/fenv-vfp.c | 32 ++<br>
newlib/libm/machine/arm/fenv.c | 328 ++++++++++++++++++<br>
newlib/libm/machine/arm/feraiseexcept.c | 7 +<br>
newlib/libm/machine/arm/fesetenv.c | 7 +<br>
newlib/libm/machine/arm/fesetexceptflag.c | 7 +<br>
newlib/libm/machine/arm/fesetround.c | 7 +<br>
newlib/libm/machine/arm/fetestexcept.c | 7 +<br>
newlib/libm/machine/arm/feupdateenv.c | 7 +<br>
21 files changed, 1224 insertions(+), 1 deletion(-)<br>
create mode 100644 newlib/libc/machine/arm/machine/acle-compat.h<br>
create mode 100644 newlib/libc/machine/arm/machine/fenv-mangle.h<br>
create mode 100644 newlib/libc/machine/arm/machine/fenv-softfloat.h<br>
create mode 100644 newlib/libc/machine/arm/machine/fenv-vfp.h<br>
create mode 100644 newlib/libc/machine/arm/sys/fenv.h<br>
create mode 100644 newlib/libm/machine/arm/fe_dfl_env.c<br>
create mode 100644 newlib/libm/machine/arm/feclearexcept.c<br>
create mode 100644 newlib/libm/machine/arm/fegetenv.c<br>
create mode 100644 newlib/libm/machine/arm/fegetexceptflag.c<br>
create mode 100644 newlib/libm/machine/arm/fegetround.c<br>
create mode 100644 newlib/libm/machine/arm/feholdexcept.c<br>
create mode 100644 newlib/libm/machine/arm/fenv-softfp.c<br>
create mode 100644 newlib/libm/machine/arm/fenv-vfp.c<br>
create mode 100644 newlib/libm/machine/arm/fenv.c<br>
create mode 100644 newlib/libm/machine/arm/feraiseexcept.c<br>
create mode 100644 newlib/libm/machine/arm/fesetenv.c<br>
create mode 100644 newlib/libm/machine/arm/fesetexceptflag.c<br>
create mode 100644 newlib/libm/machine/arm/fesetround.c<br>
create mode 100644 newlib/libm/machine/arm/fetestexcept.c<br>
create mode 100644 newlib/libm/machine/arm/feupdateenv.c<br>
<br>
diff --git a/newlib/libc/machine/arm/machine/acle-compat.h b/newlib/libc/machine/arm/machine/acle-compat.h<br>
new file mode 100644<br>
index 000000000..888ae2ea8<br>
--- /dev/null<br>
+++ b/newlib/libc/machine/arm/machine/acle-compat.h<br>
@@ -0,0 +1,182 @@<br>
+/*<br>
+ * Copyright (c) 2014 ARM Ltd<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>
+ * 3. The name of the company may not be used to endorse or promote<br>
+ * products derived from this software without specific prior written<br>
+ * permission.<br>
+ *<br>
+ * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED<br>
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF<br>
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.<br>
+ * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,<br>
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED<br>
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR<br>
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF<br>
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br>
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS<br>
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br>
+ */<br>
+<br>
+#ifndef __ARM_ARCH<br>
+<br>
+/* ACLE standardises a set of pre-defines that describe the ARM architecture.<br>
+ These were mostly implemented in GCC around GCC-4.8; older versions<br>
+ have no, or only partial support. To provide a level of backwards<br>
+ compatibility we try to work out what the definitions should be, given<br>
+ the older pre-defines that GCC did produce. This isn't complete, but<br>
+ it should be enough for use by routines that depend on this header. */<br>
+<br>
+/* No need to handle ARMv8, GCC had ACLE support before that. */<br>
+<br>
+# ifdef __ARM_ARCH_7__<br>
+/* The common subset of ARMv7 in all profiles. */<br>
+# define __ARM_ARCH 7<br>
+# define __ARM_ARCH_ISA_THUMB 2<br>
+# define __ARM_FEATURE_CLZ<br>
+# define __ARM_FEATURE_LDREX 7<br>
+# define __ARM_FEATURE_UNALIGNED<br>
+# endif<br>
+<br>
+# if defined (__ARM_ARCH_7A__) || defined (__ARM_ARCH_7R__)<br>
+# define __ARM_ARCH 7<br>
+# define __ARM_ARCH_ISA_THUMB 2<br>
+# define __ARM_ARCH_ISA_ARM<br>
+# define __ARM_FEATURE_CLZ<br>
+# define __ARM_FEATURE_SIMD32<br>
+# define __ARM_FEATURE_DSP<br>
+# define __ARM_FEATURE_QBIT<br>
+# define __ARM_FEATURE_SAT<br>
+# define __ARM_FEATURE_LDREX 15<br>
+# define __ARM_FEATURE_UNALIGNED<br>
+# ifdef __ARM_ARCH_7A__<br>
+# define __ARM_ARCH_PROFILE 'A'<br>
+# else<br>
+# define __ARM_ARCH_PROFILE 'R'<br>
+# endif<br>
+# endif<br>
+<br>
+# ifdef __ARM_ARCH_7EM__<br>
+# define __ARM_ARCH 7<br>
+# define __ARM_ARCH_ISA_THUMB 2<br>
+# define __ARM_FEATURE_CLZ<br>
+# define __ARM_FEATURE_SIMD32<br>
+# define __ARM_FEATURE_DSP<br>
+# define __ARM_FEATURE_QBIT<br>
+# define __ARM_FEATURE_SAT<br>
+# define __ARM_FEATURE_LDREX 7<br>
+# define __ARM_FEATURE_UNALIGNED<br>
+# define __ARM_ARCH_PROFILE 'M'<br>
+# endif<br>
+<br>
+# ifdef __ARM_ARCH_7M__<br>
+# define __ARM_ARCH 7<br>
+# define __ARM_ARCH_ISA_THUMB 2<br>
+# define __ARM_FEATURE_CLZ<br>
+# define __ARM_FEATURE_QBIT<br>
+# define __ARM_FEATURE_SAT<br>
+# define __ARM_FEATURE_LDREX 7<br>
+# define __ARM_FEATURE_UNALIGNED<br>
+# define __ARM_ARCH_PROFILE 'M'<br>
+# endif<br>
+<br>
+# ifdef __ARM_ARCH_6T2__<br>
+# define __ARM_ARCH 6<br>
+# define __ARM_ARCH_ISA_THUMB 2<br>
+# define __ARM_ARCH_ISA_ARM<br>
+# define __ARM_FEATURE_CLZ<br>
+# define __ARM_FEATURE_SIMD32<br>
+# define __ARM_FEATURE_DSP<br>
+# define __ARM_FEATURE_QBIT<br>
+# define __ARM_FEATURE_SAT<br>
+# define __ARM_FEATURE_LDREX 4<br>
+# define __ARM_FEATURE_UNALIGNED<br>
+# endif<br>
+<br>
+# ifdef __ARM_ARCH_6M__<br>
+# define __ARM_ARCH 6<br>
+# define __ARM_ARCH_ISA_THUMB 1<br>
+# define __ARM_ARCH_PROFILE 'M'<br>
+# endif<br>
+<br>
+# if defined (__ARM_ARCH_6__) || defined (__ARM_ARCH_6J__) \<br>
+ || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6Z__) \<br>
+ || defined (__ARM_ARCH_6ZK__)<br>
+# define __ARM_ARCH 6<br>
+# define __ARM_ARCH_ISA_THUMB 1<br>
+# define __ARM_ARCH_ISA_ARM<br>
+# define __ARM_FEATURE_CLZ<br>
+# define __ARM_FEATURE_SIMD32<br>
+# define __ARM_FEATURE_DSP<br>
+# define __ARM_FEATURE_QBIT<br>
+# define __ARM_FEATURE_SAT<br>
+# define __ARM_FEATURE_UNALIGNED<br>
+# ifndef __thumb__<br>
+# if defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__)<br>
+# define __ARM_FEATURE_LDREX 15<br>
+# else<br>
+# define __ARM_FEATURE_LDREX 4<br>
+# endif<br>
+# endif<br>
+# endif<br>
+<br>
+# if defined (__ARM_ARCH_5TE__) || defined (__ARM_ARCH_5E__)<br>
+# define __ARM_ARCH 5<br>
+# define __ARM_ARCH_ISA_ARM<br>
+# ifdef __ARM_ARCH_5TE__<br>
+# define __ARM_ARCH_ISA_THUMB 1<br>
+# endif<br>
+# define __ARM_FEATURE_CLZ<br>
+# define __ARM_FEATURE_DSP<br>
+# endif<br>
+<br>
+# if defined (__ARM_ARCH_5T__) || defined (__ARM_ARCH_5__)<br>
+# define __ARM_ARCH 5<br>
+# define __ARM_ARCH_ISA_ARM<br>
+# ifdef __ARM_ARCH_5TE__<br>
+# define __ARM_ARCH_ISA_THUMB 1<br>
+# endif<br>
+# define __ARM_FEATURE_CLZ<br>
+# endif<br>
+<br>
+# ifdef __ARM_ARCH_4T__<br>
+# define __ARM_ARCH 4<br>
+# define __ARM_ARCH_ISA_ARM<br>
+# define __ARM_ARCH_ISA_THUMB 1<br>
+# endif<br>
+<br>
+# ifdef __ARM_ARCH_4__<br>
+# define __ARM_ARCH 4<br>
+# define __ARM_ARCH_ISA_ARM<br>
+# endif<br>
+<br>
+# if defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)<br>
+# define __ARM_ARCH 3<br>
+# define __ARM_ARCH_ISA_ARM<br>
+# endif<br>
+<br>
+# ifdef __ARM_ARCH_2__<br>
+# define __ARM_ARCH 2<br>
+# define __ARM_ARCH_ISA_ARM<br>
+# endif<br>
+<br>
+# ifdef __ARMEB__<br>
+# define __ARM_BIG_ENDIAN<br>
+# endif<br>
+<br>
+/* If we still don't know what the target architecture is, then we're<br>
+ probably not using GCC. */<br>
+# ifndef __ARM_ARCH<br>
+# error Unable to determine architecture version.<br>
+# endif<br>
+<br>
+#endif /* __ARM_ARCH */<br>
+<br>
diff --git a/newlib/libc/machine/arm/machine/fenv-mangle.h b/newlib/libc/machine/arm/machine/fenv-mangle.h<br>
new file mode 100644<br>
index 000000000..476f7b20c<br>
--- /dev/null<br>
+++ b/newlib/libc/machine/arm/machine/fenv-mangle.h<br>
@@ -0,0 +1,53 @@<br>
+/*-<br>
+ * Copyright (c) 2013 Andrew Turner <andrew@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>
+#ifdef _FENV_MANGLE_H_<br>
+#error Only include fenv-mangle.h once<br>
+#endif<br>
+<br>
+#define _FENV_MANGLE_H_<br>
+<br>
+#ifndef FENV_MANGLE<br>
+#error FENV_MANGLE is undefined<br>
+#endif<br>
+<br>
+#define feclearexcept FENV_MANGLE(feclearexcept)<br>
+#define fegetexceptflag FENV_MANGLE(fegetexceptflag)<br>
+#define fesetexceptflag FENV_MANGLE(fesetexceptflag)<br>
+#define feraiseexcept FENV_MANGLE(feraiseexcept)<br>
+#define fetestexcept FENV_MANGLE(fetestexcept)<br>
+#define fegetround FENV_MANGLE(fegetround)<br>
+#define fesetround FENV_MANGLE(fesetround)<br>
+#define fegetenv FENV_MANGLE(fegetenv)<br>
+#define feholdexcept FENV_MANGLE(feholdexcept)<br>
+#define fesetenv FENV_MANGLE(fesetenv)<br>
+#define feupdateenv FENV_MANGLE(feupdateenv)<br>
+#define feenableexcept FENV_MANGLE(feenableexcept)<br>
+#define fedisableexcept FENV_MANGLE(fedisableexcept)<br>
+#define fegetexcept FENV_MANGLE(fegetexcept)<br>
+<br>
diff --git a/newlib/libc/machine/arm/machine/fenv-softfloat.h b/newlib/libc/machine/arm/machine/fenv-softfloat.h<br>
new file mode 100644<br>
index 000000000..b650437cc<br>
--- /dev/null<br>
+++ b/newlib/libc/machine/arm/machine/fenv-softfloat.h<br>
@@ -0,0 +1,187 @@<br>
+ /*-<br>
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD<br>
+ *<br>
+ * Copyright (c) 2004-2011 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>
+#error "This file is meant to be included only by <sys/fenv.h>."<br>
+#endif<br>
+/* the file can be added from architecture specific fenv.h file found in<br>
+ *libc/sys/arch/sys *<br>
+ *<br>
+ * This file implements the functionality of <fenv.h> on platforms that<br>
+ * lack an FPU and use softfloat in libc for floating point. To use it,<br>
+ * you must write an <fenv.h> that provides the following:<br>
+ *<br>
+ * - a typedef for fenv_t, which may be an integer or struct type<br>
+ * - a typedef for fexcept_t (XXX This file assumes fexcept_t is a<br>
+ * simple integer type containing the exception mask.)<br>
+ * - definitions of FE_* constants for the five exceptions and four<br>
+ * rounding modes in IEEE 754, as described in fenv(3)<br>
+ * - a definition, and the corresponding external symbol, for FE_DFL_ENV<br>
+ * - a macro __set_env(env, flags, mask, rnd), which sets the given fenv_t<br>
+ * from the exception flags, mask, and rounding mode<br>
+ * - macros __env_flags(env), __env_mask(env), and __env_round(env), which<br>
+ * extract fields from an fenv_t<br>
+ * - a definition of __fenv_static<br>
+ *<br>
+ * If the architecture supports an optional FPU, it's recommended that you<br>
+ * define fenv_t and fexcept_t to match the hardware ABI. Otherwise, it<br>
+ * doesn't matter how you define them.<br>
+ */<br>
+#include <errno.h><br>
+<br>
+int __softfloat_float_exception_flags;<br>
+int __softfloat_float_exception_mask;<br>
+int __softfloat_float_rounding_mode;<br>
+<br>
+<br>
+__fenv_static inline int<br>
+feclearexcept(int excepts)<br>
+{<br>
+<br>
+ __softfloat_float_exception_flags &= ~excepts;<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fegetexceptflag(fexcept_t *flagp, int excepts)<br>
+{<br>
+<br>
+ *flagp = __softfloat_float_exception_flags & excepts;<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fesetexceptflag(const fexcept_t *flagp, int excepts)<br>
+{<br>
+<br>
+ __softfloat_float_exception_flags &= ~excepts;<br>
+ __softfloat_float_exception_flags |= *flagp & excepts;<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+feraiseexcept(int excepts)<br>
+{<br>
+<br>
+ return (excepts ? -ENOTSUP : 0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fetestexcept(int excepts)<br>
+{<br>
+<br>
+ return (__softfloat_float_exception_flags & excepts);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fegetround(void)<br>
+{<br>
+<br>
+ return (__softfloat_float_rounding_mode);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fesetround(int round)<br>
+{<br>
+<br>
+ __softfloat_float_rounding_mode = round;<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fegetenv(fenv_t *envp)<br>
+{<br>
+<br>
+ __set_env(*envp, __softfloat_float_exception_flags,<br>
+ __softfloat_float_exception_mask, __softfloat_float_rounding_mode);<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+feholdexcept(fenv_t *envp)<br>
+{<br>
+ fenv_t __env;<br>
+<br>
+ fegetenv(envp);<br>
+ __softfloat_float_exception_flags = 0;<br>
+ __softfloat_float_exception_mask = 0;<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fesetenv(const fenv_t *envp)<br>
+{<br>
+<br>
+ __softfloat_float_exception_flags = __env_flags(*envp);<br>
+ __softfloat_float_exception_mask = __env_mask(*envp);<br>
+ __softfloat_float_rounding_mode = __env_round(*envp);<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+feupdateenv(const fenv_t *envp)<br>
+{<br>
+ int __oflags = __softfloat_float_exception_flags;<br>
+<br>
+ fesetenv(envp);<br>
+ feraiseexcept(__oflags);<br>
+ return (0);<br>
+}<br>
+<br>
+#if __BSD_VISIBLE<br>
+<br>
+/* We currently provide no external definitions of the functions below. */<br>
+<br>
+__fenv_static inline int<br>
+feenableexcept(int __mask)<br>
+{<br>
+ int __omask = __softfloat_float_exception_mask;<br>
+<br>
+ __softfloat_float_exception_mask |= __mask;<br>
+ return (__omask);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fedisableexcept(int __mask)<br>
+{<br>
+ int __omask = __softfloat_float_exception_mask;<br>
+<br>
+ __softfloat_float_exception_mask &= ~__mask;<br>
+ return (__omask);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fegetexcept(void)<br>
+{<br>
+<br>
+ return (__softfloat_float_exception_mask);<br>
+}<br>
+<br>
+#endif /* __BSD_VISIBLE */<br>
diff --git a/newlib/libc/machine/arm/machine/fenv-vfp.h b/newlib/libc/machine/arm/machine/fenv-vfp.h<br>
new file mode 100644<br>
index 000000000..25d71f3ab<br>
--- /dev/null<br>
+++ b/newlib/libc/machine/arm/machine/fenv-vfp.h<br>
@@ -0,0 +1,187 @@<br>
+/*-<br>
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD<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>
+<br>
+<br>
+#define vmrs_fpscr(__r) __asm __volatile("vmrs %0, fpscr" : "=&r"(__r))<br>
+#define vmsr_fpscr(__r) __asm __volatile("vmsr fpscr, %0" : : "r"(__r))<br>
+<br>
+<br>
+#define _FPU_MASK_SHIFT 8<br>
+<br>
+__fenv_static inline int feclearexcept(int excepts)<br>
+{<br>
+ fexcept_t __fpsr;<br>
+<br>
+ vmrs_fpscr(__fpsr);<br>
+ __fpsr &= ~excepts;<br>
+ vmsr_fpscr(__fpsr);<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fegetexceptflag(fexcept_t *flagp, int excepts)<br>
+{<br>
+ fexcept_t __fpsr;<br>
+<br>
+ vmrs_fpscr(__fpsr);<br>
+ *flagp = __fpsr & excepts;<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fesetexceptflag(const fexcept_t *flagp, int excepts)<br>
+{<br>
+ fexcept_t __fpsr;<br>
+<br>
+ vmrs_fpscr(__fpsr);<br>
+ __fpsr &= ~excepts;<br>
+ __fpsr |= *flagp & excepts;<br>
+ vmsr_fpscr(__fpsr);<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+feraiseexcept(int excepts)<br>
+{<br>
+ fexcept_t __ex = excepts;<br>
+<br>
+ fesetexceptflag(&__ex, excepts); /* XXX */<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fetestexcept(int excepts)<br>
+{<br>
+ fexcept_t __fpsr;<br>
+<br>
+ vmrs_fpscr(__fpsr);<br>
+ return (__fpsr & excepts);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fegetround(void)<br>
+{<br>
+ fenv_t __fpsr;<br>
+<br>
+ vmrs_fpscr(__fpsr);<br>
+ return (__fpsr & _ROUND_MASK);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fesetround(int round)<br>
+{<br>
+ fenv_t __fpsr;<br>
+<br>
+ vmrs_fpscr(__fpsr);<br>
+ __fpsr &= ~(_ROUND_MASK);<br>
+ __fpsr |= round;<br>
+ vmsr_fpscr(__fpsr);<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fegetenv(fenv_t *envp)<br>
+{<br>
+<br>
+ vmrs_fpscr(*envp);<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+feholdexcept(fenv_t *envp)<br>
+{<br>
+ fenv_t __env;<br>
+<br>
+ vmrs_fpscr(__env);<br>
+ *envp = __env;<br>
+ __env &= ~(FE_ALL_EXCEPT);<br>
+ vmsr_fpscr(__env);<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fesetenv(const fenv_t *envp)<br>
+{<br>
+<br>
+ vmsr_fpscr(*envp);<br>
+ return (0);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+feupdateenv(const fenv_t *envp)<br>
+{<br>
+ fexcept_t __fpsr;<br>
+<br>
+ vmrs_fpscr(__fpsr);<br>
+ vmsr_fpscr(*envp);<br>
+ feraiseexcept(__fpsr & FE_ALL_EXCEPT);<br>
+ return (0);<br>
+}<br>
+<br>
+#if __BSD_VISIBLE<br>
+<br>
+/* We currently provide no external definitions of the functions below. */<br>
+<br>
+__fenv_static inline int<br>
+feenableexcept(int __mask)<br>
+{<br>
+ fenv_t __old_fpsr, __new_fpsr;<br>
+<br>
+ vmrs_fpscr(__old_fpsr);<br>
+ __new_fpsr = __old_fpsr |<br>
+ ((__mask & FE_ALL_EXCEPT) << _FPU_MASK_SHIFT);<br>
+ vmsr_fpscr(__new_fpsr);<br>
+ return ((__old_fpsr >> _FPU_MASK_SHIFT) & FE_ALL_EXCEPT);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fedisableexcept(int __mask)<br>
+{<br>
+ fenv_t __old_fpsr, __new_fpsr;<br>
+<br>
+ vmrs_fpscr(__old_fpsr);<br>
+ __new_fpsr = __old_fpsr &<br>
+ ~((__mask & FE_ALL_EXCEPT) << _FPU_MASK_SHIFT);<br>
+ vmsr_fpscr(__new_fpsr);<br>
+ return ((__old_fpsr >> _FPU_MASK_SHIFT) & FE_ALL_EXCEPT);<br>
+}<br>
+<br>
+__fenv_static inline int<br>
+fegetexcept(void)<br>
+{<br>
+ fenv_t __fpsr;<br>
+<br>
+ vmrs_fpscr(__fpsr);<br>
+ return (__fpsr & FE_ALL_EXCEPT);<br>
+}<br>
+<br>
+#endif /* __BSD_VISIBLE */<br>
+<br>
diff --git a/newlib/libc/machine/arm/sys/fenv.h b/newlib/libc/machine/arm/sys/fenv.h<br>
new file mode 100644<br>
index 000000000..af74c5f47<br>
--- /dev/null<br>
+++ b/newlib/libc/machine/arm/sys/fenv.h<br>
@@ -0,0 +1,122 @@<br>
+/*-<br>
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD<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_ 1<br>
+<br>
+#include <sys/_types.h><br>
+#include <sys/cdefs.h><br>
+<br>
+#ifdef __cplusplus<br>
+extern "C" {<br>
+#endif<br>
+<br>
+#ifndef __fenv_static<br>
+#define __fenv_static static<br>
+#endif<br>
+<br>
+typedef int fenv_t;<br>
+typedef int fexcept_t;<br>
+<br>
+/* Exception flags */<br>
+#define FE_INVALID 0x0001<br>
+#define FE_DIVBYZERO 0x0002<br>
+#define FE_OVERFLOW 0x0004<br>
+#define FE_UNDERFLOW 0x0008<br>
+#define FE_INEXACT 0x0010<br>
+#ifdef __ARM_PCS_VFP<br>
+#define FE_DENORMAL 0x0080<br>
+#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \<br>
+ FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW | FE_DENORMAL)<br>
+#else<br>
+#define FE_ALL_EXCEPT (FE_DIVBYZERO | FE_INEXACT | \<br>
+ FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)<br>
+#endif<br>
+<br>
+<br>
+<br>
+/* Rounding modes */<br>
+#define VFP_FE_TONEAREST 0x00000000<br>
+#define VFP_FE_UPWARD 0x00400000<br>
+#define VFP_FE_DOWNWARD 0x00800000<br>
+#define VFP_FE_TOWARDZERO 0x00c00000<br>
+<br>
+#ifdef __ARM_PCS_VFP<br>
+#define FE_TONEAREST VFP_FE_TONEAREST<br>
+#define FE_UPWARD VFP_FE_UPWARD<br>
+#define FE_DOWNWARD VFP_FE_DOWNWARD<br>
+#define FE_TOWARDZERO VFP_FE_TOWARDZERO<br>
+#else<br>
+#define FE_TONEAREST 0x0000<br>
+#define FE_TOWARDZERO 0x0001<br>
+#define FE_UPWARD 0x0002<br>
+#define FE_DOWNWARD 0x0003<br>
+#endif<br>
+#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \<br>
+ FE_UPWARD | FE_TOWARDZERO)<br>
+<br>
+<br>
+/* Default floating-point environment */<br>
+<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>
+#ifndef __ARM_PCS_VFP<br>
+#define _FPUSW_SHIFT 16<br>
+#define _ENABLE_MASK (FE_ALL_EXCEPT << _FPUSW_SHIFT)<br>
+#endif<br>
+<br>
+#ifndef __ARM_PCS_VFP<br>
+<br>
+int feclearexcept(int excepts);<br>
+int fegetexceptflag(fexcept_t *flagp, int excepts);<br>
+int fesetexceptflag(const fexcept_t *flagp, int excepts);<br>
+int feraiseexcept(int excepts);<br>
+int fetestexcept(int excepts);<br>
+int fegetround(void);<br>
+int fesetround(int round);<br>
+int fegetenv(fenv_t *envp);<br>
+int feholdexcept(fenv_t *envp);<br>
+int fesetenv(const fenv_t *envp);<br>
+int feupdateenv(const fenv_t *envp);<br>
+#if __BSD_VISIBLE<br>
+int feenableexcept(int __mask);<br>
+int fedisableexcept(int __mask);<br>
+int fegetexcept(void);<br>
+#endif /* __BSD_VISIBLE */<br>
+<br>
+#endif /* __ARM_PCS_VFP */<br>
+<br>
+#ifdef __cplusplus<br>
+}<br>
+#endif<br>
+<br>
+#endif /* _SYS_FENV_H_ */<br>
diff --git a/newlib/libm/machine/arm/Makefile.am b/newlib/libm/machine/arm/Makefile.am<br>
index 1f10a7a40..a64ee59d5 100644<br>
--- a/newlib/libm/machine/arm/Makefile.am<br>
+++ b/newlib/libm/machine/arm/Makefile.am<br>
@@ -19,7 +19,23 @@ LIB_SOURCES = \<br>
sf_nearbyint.c \<br>
sf_rint.c \<br>
sf_round.c \<br>
- sf_trunc.c<br>
+ sf_trunc.c \<br>
+ feclearexcept.c \<br>
+ fe_dfl_env.c\<br>
+ fegetenv.c \<br>
+ fegetexceptflag.c \<br>
+ fegetround.c \<br>
+ feholdexcept.c \<br>
+ fenv.c \<br>
+ feraiseexcept.c \<br>
+ fesetenv.c \<br>
+ fesetexceptflag.c \<br>
+ fesetround.c \<br>
+ fetestexcept.c \<br>
+ feupdateenv.c \<br>
+ fenv-vfp.c \<br>
+ fenv-softfp.c <br>
+<br>
<br>
noinst_LIBRARIES = lib.a<br>
lib_a_SOURCES = $(LIB_SOURCES)<br>
diff --git a/newlib/libm/machine/arm/fe_dfl_env.c b/newlib/libm/machine/arm/fe_dfl_env.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/fe_dfl_env.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/arm/feclearexcept.c b/newlib/libm/machine/arm/feclearexcept.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/fegetenv.c b/newlib/libm/machine/arm/fegetenv.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/fegetexceptflag.c b/newlib/libm/machine/arm/fegetexceptflag.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/fegetround.c b/newlib/libm/machine/arm/fegetround.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/feholdexcept.c b/newlib/libm/machine/arm/feholdexcept.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/fenv-softfp.c b/newlib/libm/machine/arm/fenv-softfp.c<br>
new file mode 100644<br>
index 000000000..a576cc1b2<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/fenv-softfp.c<br>
@@ -0,0 +1,32 @@<br>
+/*-<br>
+ * Copyright (c) 2013 Andrew Turner <andrew@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>
+#define FENV_MANGLE(x) __softfp_ ##x<br>
+#include <machine/fenv-mangle.h><br>
+#include "fenv.c"<br>
+<br>
diff --git a/newlib/libm/machine/arm/fenv-vfp.c b/newlib/libm/machine/arm/fenv-vfp.c<br>
new file mode 100644<br>
index 000000000..297e81296<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/fenv-vfp.c<br>
@@ -0,0 +1,32 @@<br>
+/*-<br>
+ * Copyright (c) 2013 Andrew Turner <andrew@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>
+#define FENV_MANGLE(x) __vfp_ ##x<br>
+#include <machine/fenv-mangle.h><br>
+#include "fenv.c"<br>
+<br>
diff --git a/newlib/libm/machine/arm/fenv.c b/newlib/libm/machine/arm/fenv.c<br>
new file mode 100644<br>
index 000000000..5b61ab81f<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/fenv.c<br>
@@ -0,0 +1,328 @@<br>
+/*-<br>
+ * SPDX-License-Identifier: BSD-2-Clause-FreeBSD<br>
+ *<br>
+ * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG><br>
+ * Copyright (c) 2013 Andrew Turner <andrew@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>
+#define __fenv_static<br>
+#include <fenv.h><br>
+<br>
+#include <machine/acle-compat.h><br>
+<br>
+#if __ARM_ARCH >= 6<br>
+#define FENV_ARMv6<br>
+#endif<br>
+<br>
+/* When SOFTFP_ABI is defined we are using the softfp ABI. */<br>
+#if defined(__VFP_FP__) && !defined(__ARM_PCS_VFP)<br>
+#define SOFTFP_ABI<br>
+#endif<br>
+<br>
+<br>
+#ifndef FENV_MANGLE<br>
+/*<br>
+ * Hopefully the system ID byte is immutable, so it's valid to use<br>
+ * this as a default environment.<br>
+ */<br>
+fenv_t __fe_dfl_env = { 0 };<br>
+<br>
+const fenv_t *_fe_dfl_env = &__fe_dfl_env;<br>
+#endif<br>
+<br>
+<br>
+/* If this is a non-mangled softfp version special processing is required */<br>
+#if defined(FENV_MANGLE) || !defined(SOFTFP_ABI) || !defined(FENV_ARMv6)<br>
+<br>
+/*<br>
+ * The following macros map between the softfloat emulator's flags and<br>
+ * the hardware's FPSR. The hardware this file was written for doesn't<br>
+ * have rounding control bits, so we stick those in the system ID byte.<br>
+ */<br>
+#ifndef __ARM_PCS_VFP<br>
+#define __set_env(env, flags, mask, rnd) env = ((flags) \<br>
+ | (mask)<<_FPUSW_SHIFT \<br>
+ | (rnd) << 24)<br>
+#define __env_flags(env) ((env) & FE_ALL_EXCEPT)<br>
+#define __env_mask(env) (((env) >> _FPUSW_SHIFT) \<br>
+ & FE_ALL_EXCEPT)<br>
+#define __env_round(env) (((env) >> 24) & _ROUND_MASK)<br>
+<br>
+#include <machine/fenv-softfloat.h><br>
+<br>
+#else /* __ARM_PCS_VFP PRESENT */<br>
+<br>
+#include <machine/fenv-vfp.h><br>
+<br>
+#endif /* __ARM_PCS_VFP */<br>
+<br>
+#ifdef __GNUC_GNU_INLINE__<br>
+#error "This file must be compiled with C99 'inline' semantics"<br>
+#endif<br>
+<br>
+extern inline int feclearexcept(int excepts);<br>
+extern inline int fegetexceptflag(fexcept_t *flagp, int excepts);<br>
+extern inline int fesetexceptflag(const fexcept_t *flagp, int excepts);<br>
+extern inline int feraiseexcept(int excepts);<br>
+extern inline int fetestexcept(int excepts);<br>
+extern inline int fegetround(void);<br>
+extern inline int fesetround(int round);<br>
+extern inline int fegetenv(fenv_t *envp);<br>
+extern inline int feholdexcept(fenv_t *envp);<br>
+extern inline int fesetenv(const fenv_t *envp);<br>
+extern inline int feupdateenv(const fenv_t *envp);<br>
+extern inline int feenableexcept(int __mask);<br>
+extern inline int fedisableexcept(int __mask);<br>
+extern inline int fegetexcept(void);<br>
+<br>
+#else /* !FENV_MANGLE && SOFTFP_ABI */<br>
+/* Set by libc when the VFP unit is enabled */<br>
+<br>
+int _libc_arm_fpu_present;<br>
+<br>
+int __softfp_feclearexcept(int excepts);<br>
+int __softfp_fegetexceptflag(fexcept_t *flagp, int excepts);<br>
+int __softfp_fesetexceptflag(const fexcept_t *flagp, int excepts);<br>
+int __softfp_feraiseexcept(int excepts);<br>
+int __softfp_fetestexcept(int excepts);<br>
+int __softfp_fegetround(void);<br>
+int __softfp_fesetround(int round);<br>
+int __softfp_fegetenv(fenv_t *envp);<br>
+int __softfp_feholdexcept(fenv_t *envp);<br>
+int __softfp_fesetenv(const fenv_t *envp);<br>
+int __softfp_feupdateenv(const fenv_t *envp);<br>
+int __softfp_feenableexcept(int __mask);<br>
+int __softfp_fedisableexcept(int __mask);<br>
+int __softfp_fegetexcept(void);<br>
+<br>
+int __vfp_feclearexcept(int excepts);<br>
+int __vfp_fegetexceptflag(fexcept_t *flagp, int excepts);<br>
+int __vfp_fesetexceptflag(const fexcept_t *flagp, int excepts);<br>
+int __vfp_feraiseexcept(int excepts);<br>
+int __vfp_fetestexcept(int excepts);<br>
+int __vfp_fegetround(void);<br>
+int __vfp_fesetround(int round);<br>
+int __vfp_fegetenv(fenv_t *envp);<br>
+int __vfp_feholdexcept(fenv_t *envp);<br>
+int __vfp_fesetenv(const fenv_t *envp);<br>
+int __vfp_feupdateenv(const fenv_t *envp);<br>
+int __vfp_feenableexcept(int __mask);<br>
+int __vfp_fedisableexcept(int __mask);<br>
+int __vfp_fegetexcept(void);<br>
+<br>
+static int<br>
+__softfp_round_to_vfp(int round)<br>
+{<br>
+<br>
+ switch (round) {<br>
+ case FE_TONEAREST:<br>
+ default:<br>
+ return VFP_FE_TONEAREST;<br>
+ case FE_TOWARDZERO:<br>
+ return VFP_FE_TOWARDZERO;<br>
+ case FE_UPWARD:<br>
+ return VFP_FE_UPWARD;<br>
+ case FE_DOWNWARD:<br>
+ return VFP_FE_DOWNWARD;<br>
+ }<br>
+}<br>
+<br>
+static int<br>
+__softfp_round_from_vfp(int round)<br>
+{<br>
+<br>
+ switch (round) {<br>
+ case VFP_FE_TONEAREST:<br>
+ default:<br>
+ return FE_TONEAREST;<br>
+ case VFP_FE_TOWARDZERO:<br>
+ return FE_TOWARDZERO;<br>
+ case VFP_FE_UPWARD:<br>
+ return FE_UPWARD;<br>
+ case VFP_FE_DOWNWARD:<br>
+ return FE_DOWNWARD;<br>
+ }<br>
+}<br>
+<br>
+int feclearexcept(int excepts)<br>
+{<br>
+<br>
+ if (_libc_arm_fpu_present)<br>
+ __vfp_feclearexcept(excepts);<br>
+ __softfp_feclearexcept(excepts);<br>
+<br>
+ return (0);<br>
+}<br>
+<br>
+int fegetexceptflag(fexcept_t *flagp, int excepts)<br>
+{<br>
+ fexcept_t __vfp_flagp;<br>
+<br>
+ __vfp_flagp = 0;<br>
+ if (_libc_arm_fpu_present)<br>
+ __vfp_fegetexceptflag(&__vfp_flagp, excepts);<br>
+ __softfp_fegetexceptflag(flagp, excepts);<br>
+<br>
+ *flagp |= __vfp_flagp;<br>
+<br>
+ return (0);<br>
+}<br>
+<br>
+int fesetexceptflag(const fexcept_t *flagp, int excepts)<br>
+{<br>
+<br>
+ if (_libc_arm_fpu_present)<br>
+ __vfp_fesetexceptflag(flagp, excepts);<br>
+ __softfp_fesetexceptflag(flagp, excepts);<br>
+<br>
+ return (0);<br>
+}<br>
+<br>
+int feraiseexcept(int excepts)<br>
+{<br>
+<br>
+ if (_libc_arm_fpu_present)<br>
+ __vfp_feraiseexcept(excepts);<br>
+ __softfp_feraiseexcept(excepts);<br>
+<br>
+ return (0);<br>
+}<br>
+<br>
+int fetestexcept(int excepts)<br>
+{<br>
+ int __got_excepts;<br>
+<br>
+ __got_excepts = 0;<br>
+ if (_libc_arm_fpu_present)<br>
+ __got_excepts = __vfp_fetestexcept(excepts);<br>
+ __got_excepts |= __softfp_fetestexcept(excepts);<br>
+<br>
+ return (__got_excepts);<br>
+}<br>
+<br>
+int fegetround(void)<br>
+{<br>
+<br>
+ if (_libc_arm_fpu_present)<br>
+ return __softfp_round_from_vfp(__vfp_fegetround());<br>
+ return __softfp_fegetround();<br>
+}<br>
+<br>
+int fesetround(int round)<br>
+{<br>
+<br>
+ if (_libc_arm_fpu_present)<br>
+ __vfp_fesetround(__softfp_round_to_vfp(round));<br>
+ __softfp_fesetround(round);<br>
+<br>
+ return (0);<br>
+}<br>
+<br>
+int fegetenv(fenv_t *envp)<br>
+{<br>
+ fenv_t __vfp_envp;<br>
+<br>
+ __vfp_envp = 0;<br>
+ if (_libc_arm_fpu_present)<br>
+ __vfp_fegetenv(&__vfp_envp);<br>
+ __softfp_fegetenv(envp);<br>
+ *envp |= __vfp_envp;<br>
+<br>
+ return (0);<br>
+}<br>
+<br>
+int feholdexcept(fenv_t *envp)<br>
+{<br>
+ fenv_t __vfp_envp;<br>
+<br>
+ __vfp_envp = 0;<br>
+ if (_libc_arm_fpu_present)<br>
+ __vfp_feholdexcept(&__vfp_envp);<br>
+ __softfp_feholdexcept(envp);<br>
+ *envp |= __vfp_envp;<br>
+<br>
+ return (0);<br>
+}<br>
+<br>
+int fesetenv(const fenv_t *envp)<br>
+{<br>
+<br>
+ if (_libc_arm_fpu_present)<br>
+ __vfp_fesetenv(envp);<br>
+ __softfp_fesetenv(envp);<br>
+<br>
+ return (0);<br>
+}<br>
+<br>
+int feupdateenv(const fenv_t *envp)<br>
+{<br>
+<br>
+ if (_libc_arm_fpu_present)<br>
+ __vfp_feupdateenv(envp);<br>
+ __softfp_feupdateenv(envp);<br>
+<br>
+ return (0);<br>
+}<br>
+<br>
+int feenableexcept(int __mask)<br>
+{<br>
+ int __unmasked;<br>
+<br>
+ __unmasked = 0;<br>
+ if (_libc_arm_fpu_present)<br>
+ __unmasked = __vfp_feenableexcept(__mask);<br>
+ __unmasked |= __softfp_feenableexcept(__mask);<br>
+<br>
+ return (__unmasked);<br>
+}<br>
+<br>
+int fedisableexcept(int __mask)<br>
+{<br>
+ int __unmasked;<br>
+<br>
+ __unmasked = 0;<br>
+ if (_libc_arm_fpu_present)<br>
+ __unmasked = __vfp_fedisableexcept(__mask);<br>
+ __unmasked |= __softfp_fedisableexcept(__mask);<br>
+<br>
+ return (__unmasked);<br>
+}<br>
+<br>
+int fegetexcept(void)<br>
+{<br>
+ int __unmasked;<br>
+<br>
+ __unmasked = 0;<br>
+ if (_libc_arm_fpu_present)<br>
+ __unmasked = __vfp_fegetexcept();<br>
+ __unmasked |= __softfp_fegetexcept();<br>
+<br>
+ return (__unmasked);<br>
+}<br>
+<br>
+#endif<br>
+<br>
diff --git a/newlib/libm/machine/arm/feraiseexcept.c b/newlib/libm/machine/arm/feraiseexcept.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/fesetenv.c b/newlib/libm/machine/arm/fesetenv.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/fesetexceptflag.c b/newlib/libm/machine/arm/fesetexceptflag.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/fesetround.c b/newlib/libm/machine/arm/fesetround.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/fetestexcept.c b/newlib/libm/machine/arm/fetestexcept.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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/arm/feupdateenv.c b/newlib/libm/machine/arm/feupdateenv.c<br>
new file mode 100644<br>
index 000000000..8cbee7771<br>
--- /dev/null<br>
+++ b/newlib/libm/machine/arm/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>