<div dir="ltr"><div>Hello everyone,</div><div>This is the version 2 of the previous arm fenv patch <br></div><div>apologies, I forgot to add the -v2 in the git send mail <br><br></div><div>-Eshan<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jul 18, 2020 at 2:26 AM 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">All the extra files have been removed<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/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 | 19 +-<br>
newlib/libm/machine/arm/Makefile.am | 4 +-<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 | 315 +++++++-----------<br>
8 files changed, 127 insertions(+), 702 deletions(-)<br>
delete mode 100644 newlib/libc/machine/arm/machine/fenv-mangle.h<br>
delete mode 100644 newlib/libc/machine/arm/machine/fenv-softfloat.h<br>
delete mode 100644 newlib/libc/machine/arm/machine/fenv-vfp.h<br>
delete mode 100644 newlib/libm/machine/arm/fenv-softfp.c<br>
delete mode 100644 newlib/libm/machine/arm/fenv-vfp.c<br>
<br>
diff --git a/newlib/libc/machine/arm/machine/fenv-mangle.h b/newlib/libc/machine/arm/machine/fenv-mangle.h<br>
deleted file mode 100644<br>
index 476f7b20c..000000000<br>
--- a/newlib/libc/machine/arm/machine/fenv-mangle.h<br>
+++ /dev/null<br>
@@ -1,53 +0,0 @@<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>
deleted file mode 100644<br>
index 5d33e18d0..000000000<br>
--- a/newlib/libc/machine/arm/machine/fenv-softfloat.h<br>
+++ /dev/null<br>
@@ -1,187 +0,0 @@<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>
deleted file mode 100644<br>
index 25d71f3ab..000000000<br>
--- a/newlib/libc/machine/arm/machine/fenv-vfp.h<br>
+++ /dev/null<br>
@@ -1,187 +0,0 @@<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>
index 740995a1a..0224da38b 100644<br>
--- a/newlib/libc/machine/arm/sys/fenv.h<br>
+++ b/newlib/libc/machine/arm/sys/fenv.h<br>
@@ -63,22 +63,11 @@ typedef int fexcept_t;<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>
+#define FE_TONEAREST 0x00000000<br>
+#define FE_UPWARD 0x00400000<br>
+#define FE_DOWNWARD 0x00800000<br>
+#define 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>
diff --git a/newlib/libm/machine/arm/Makefile.am b/newlib/libm/machine/arm/Makefile.am<br>
index a64ee59d5..180a37f44 100644<br>
--- a/newlib/libm/machine/arm/Makefile.am<br>
+++ b/newlib/libm/machine/arm/Makefile.am<br>
@@ -32,9 +32,7 @@ LIB_SOURCES = \<br>
fesetexceptflag.c \<br>
fesetround.c \<br>
fetestexcept.c \<br>
- feupdateenv.c \<br>
- fenv-vfp.c \<br>
- fenv-softfp.c <br>
+ feupdateenv.c<br>
<br>
<br>
noinst_LIBRARIES = lib.a<br>
diff --git a/newlib/libm/machine/arm/fenv-softfp.c b/newlib/libm/machine/arm/fenv-softfp.c<br>
deleted file mode 100644<br>
index a576cc1b2..000000000<br>
--- a/newlib/libm/machine/arm/fenv-softfp.c<br>
+++ /dev/null<br>
@@ -1,32 +0,0 @@<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>
deleted file mode 100644<br>
index 297e81296..000000000<br>
--- a/newlib/libm/machine/arm/fenv-vfp.c<br>
+++ /dev/null<br>
@@ -1,32 +0,0 @@<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>
index 5b61ab81f..d5d488d10 100644<br>
--- a/newlib/libm/machine/arm/fenv.c<br>
+++ b/newlib/libm/machine/arm/fenv.c<br>
@@ -29,7 +29,6 @@<br>
* $FreeBSD$<br>
*/<br>
<br>
-#define __fenv_static<br>
#include <fenv.h><br>
<br>
#include <machine/acle-compat.h><br>
@@ -38,156 +37,40 @@<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>
+#ifdef __ARM_PCS_VFP<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>
#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>
+#define _FPU_MASK_SHIFT 8<br>
<br>
int feclearexcept(int excepts)<br>
{<br>
<br>
- if (_libc_arm_fpu_present)<br>
- __vfp_feclearexcept(excepts);<br>
- __softfp_feclearexcept(excepts);<br>
+#ifdef __ARM_PCS_VFP<br>
+ fexcept_t __fpsr;<br>
+ vmrs_fpscr(__fpsr);<br>
+ __fpsr &= ~excepts;<br>
+ vmsr_fpscr(__fpsr);<br>
+#endif<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>
+#ifdef __ARM_PCS_VFP<br>
+ fexcept_t __fpsr;<br>
+ vmrs_fpscr(__fpsr);<br>
+ __fpsr &= ~excepts;<br>
+ __fpsr |= *flagp & excepts;<br>
+ vmsr_fpscr(__fpsr);<br>
+#endif<br>
<br>
return (0);<br>
}<br>
@@ -195,9 +78,13 @@ int fegetexceptflag(fexcept_t *flagp, int excepts)<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>
+#ifdef __ARM_PCS_VFP<br>
+ fexcept_t __fpsr;<br>
+ vmrs_fpscr(__fpsr);<br>
+ __fpsr &= ~excepts;<br>
+ __fpsr |= *flagp & excepts;<br>
+ vmsr_fpscr(__fpsr);<br>
+#endif<br>
<br>
return (0);<br>
}<br>
@@ -205,65 +92,86 @@ int fesetexceptflag(const fexcept_t *flagp, int excepts)<br>
int feraiseexcept(int excepts)<br>
{<br>
<br>
- if (_libc_arm_fpu_present)<br>
- __vfp_feraiseexcept(excepts);<br>
- __softfp_feraiseexcept(excepts);<br>
+#ifdef __ARM_PCS_VFP<br>
+ fexcept_t __ex = excepts;<br>
+ fesetexceptflag(&__ex, excepts);<br>
+#endif<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>
+#ifdef __ARM_PCS_VFP<br>
+ fexcept_t __fpsr;<br>
+ vmrs_fpscr(__fpsr);<br>
+ return (__fpsr & excepts);<br>
+#endif<br>
<br>
- return (__got_excepts);<br>
+ return (0);<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>
+#ifdef __ARM_PCS_VFP<br>
+ fenv_t __fpsr;<br>
+ vmrs_fpscr(__fpsr);<br>
+ return (__fpsr & _ROUND_MASK);<br>
+<br>
+#else<br>
+/* For soft float */<br>
+<br>
+#ifdef FE_TONEAREST<br>
+ return FE_TONEAREST;<br>
+#else<br>
+ return 0;<br>
+#endif<br>
+<br>
+#endif<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>
+#ifdef __ARM_PCS_VFP<br>
+ fenv_t __fpsr;<br>
+ vmrs_fpscr(__fpsr);<br>
+ __fpsr &= ~(_ROUND_MASK);<br>
+ __fpsr |= round;<br>
+ vmsr_fpscr(__fpsr);<br>
+ return (0);<br>
+#endif<br>
<br>
return (0);<br>
}<br>
<br>
int fegetenv(fenv_t *envp)<br>
{<br>
- fenv_t __vfp_envp;<br>
+<br>
+#ifdef __ARM_PCS_VFP<br>
+ vmrs_fpscr(*envp);<br>
+ return 0;<br>
+#endif<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>
+ *envp |= 0;<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>
+#ifdef __ARM_PCS_VFP<br>
+ fenv_t __env;<br>
+ vmrs_fpscr(__env);<br>
+ *envp = __env;<br>
+ __env &= ~(FE_ALL_EXCEPT);<br>
+ vmsr_fpscr(__env);<br>
+ return (0);<br>
+<br>
+#endif<br>
+ *envp |= 0;<br>
<br>
return (0);<br>
}<br>
@@ -271,58 +179,79 @@ int feholdexcept(fenv_t *envp)<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>
+#ifdef __ARM_PCS_VFP<br>
+ vmsr_fpscr(*envp);<br>
+#endif<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>
+#ifdef __ARM_PCS_VFP<br>
+ fexcept_t __fpsr;<br>
+ vmrs_fpscr(__fpsr);<br>
+ vmsr_fpscr(*envp);<br>
+ feraiseexcept(__fpsr & FE_ALL_EXCEPT);<br>
+<br>
+ return 0;<br>
+#else<br>
+<br>
+#if defined FE_NOMASK_ENV && FE_ALL_EXCEPT != 0<br>
+<br>
+ if (envp == FE_NOMASK_ENV)<br>
+ return 1;<br>
+<br>
+#endif<br>
+<br>
+ return 0;<br>
+<br>
+#endif<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>
+#ifdef __ARM_PCS_VFP<br>
+ fenv_t __old_fpsr, __new_fpsr;<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>
+#endif<br>
<br>
- return (__unmasked);<br>
+ return (0);<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>
+#ifdef __ARM_PCS_VFP<br>
+ fenv_t __old_fpsr, __new_fpsr;<br>
<br>
- return (__unmasked);<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>
+#endif<br>
+<br>
+ return (0);<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>
+#ifdef __ARM_PCS_VFP<br>
+ fenv_t __fpsr;<br>
<br>
- return (__unmasked);<br>
+ vmrs_fpscr(__fpsr);<br>
+ return (__fpsr & FE_ALL_EXCEPT);<br>
+#endif<br>
+<br>
+ return (0);<br>
}<br>
<br>
-#endif<br>
<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div>