public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* [PATCH 0/2] Fix fenv support for ARM
@ 2020-07-19 11:01 Sebastian Huber
  2020-07-19 11:01 ` [PATCH 1/2] arm: Fix fenv support Sebastian Huber
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Sebastian Huber @ 2020-07-19 11:01 UTC (permalink / raw)
  To: newlib

This patch set addresses some issues which popped up while building Newlib for
ARM with GCC 10 which enables -fno-common by default.

Eshan dhawan (1):
  arm: Fix fenv support

Sebastian Huber (1):
  arm: Remove superfluous fenv stub files

 newlib/libc/machine/arm/machine/fenv-mangle.h |  53 ---
 .../libc/machine/arm/machine/fenv-softfloat.h | 187 ----------
 newlib/libc/machine/arm/machine/fenv-vfp.h    | 187 ----------
 newlib/libc/machine/arm/sys/fenv.h            |  66 +---
 newlib/libm/machine/arm/Makefile.am           |  17 +-
 newlib/libm/machine/arm/Makefile.in           | 109 +-----
 newlib/libm/machine/arm/fe_dfl_env.c          |   7 -
 newlib/libm/machine/arm/feclearexcept.c       |   7 -
 newlib/libm/machine/arm/fegetenv.c            |   7 -
 newlib/libm/machine/arm/fegetexceptflag.c     |   7 -
 newlib/libm/machine/arm/fegetround.c          |   7 -
 newlib/libm/machine/arm/feholdexcept.c        |   7 -
 newlib/libm/machine/arm/fenv-softfp.c         |  32 --
 newlib/libm/machine/arm/fenv-vfp.c            |  32 --
 newlib/libm/machine/arm/fenv.c                | 319 ++++++------------
 newlib/libm/machine/arm/feraiseexcept.c       |   7 -
 newlib/libm/machine/arm/fesetenv.c            |   7 -
 newlib/libm/machine/arm/fesetexceptflag.c     |   7 -
 newlib/libm/machine/arm/fesetround.c          |   7 -
 newlib/libm/machine/arm/fetestexcept.c        |   7 -
 newlib/libm/machine/arm/feupdateenv.c         |   7 -
 21 files changed, 127 insertions(+), 959 deletions(-)
 delete mode 100644 newlib/libc/machine/arm/machine/fenv-mangle.h
 delete mode 100644 newlib/libc/machine/arm/machine/fenv-softfloat.h
 delete mode 100644 newlib/libc/machine/arm/machine/fenv-vfp.h
 delete mode 100644 newlib/libm/machine/arm/fe_dfl_env.c
 delete mode 100644 newlib/libm/machine/arm/feclearexcept.c
 delete mode 100644 newlib/libm/machine/arm/fegetenv.c
 delete mode 100644 newlib/libm/machine/arm/fegetexceptflag.c
 delete mode 100644 newlib/libm/machine/arm/fegetround.c
 delete mode 100644 newlib/libm/machine/arm/feholdexcept.c
 delete mode 100644 newlib/libm/machine/arm/fenv-softfp.c
 delete mode 100644 newlib/libm/machine/arm/fenv-vfp.c
 delete mode 100644 newlib/libm/machine/arm/feraiseexcept.c
 delete mode 100644 newlib/libm/machine/arm/fesetenv.c
 delete mode 100644 newlib/libm/machine/arm/fesetexceptflag.c
 delete mode 100644 newlib/libm/machine/arm/fesetround.c
 delete mode 100644 newlib/libm/machine/arm/fetestexcept.c
 delete mode 100644 newlib/libm/machine/arm/feupdateenv.c

-- 
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/2] arm: Fix fenv support
  2020-07-19 11:01 [PATCH 0/2] Fix fenv support for ARM Sebastian Huber
@ 2020-07-19 11:01 ` Sebastian Huber
  2020-07-23  5:16   ` Sebastian Huber
  2020-07-30 22:51   ` Keith Packard
  2020-07-19 11:01 ` [PATCH 2/2] arm: Remove superfluous fenv stub files Sebastian Huber
  2020-07-23  5:13 ` [PATCH 0/2] Fix fenv support for ARM Sebastian Huber
  2 siblings, 2 replies; 9+ messages in thread
From: Sebastian Huber @ 2020-07-19 11:01 UTC (permalink / raw)
  To: newlib

From: Eshan dhawan <eshandhawan51@gmail.com>

The previous fenv support for ARM used the soft-float implementation of
FreeBSD.  Newlib uses the one from libgcc by default.  They are not
compatible.  Having an GCC incompatible soft-float fenv support in
Newlib makes no sense.  A long-term solution could be to provide a
libgcc compatible soft-float support.  This likely requires changes in
the GCC configuration.  For now, provide a stub implementation for
soft-float multilibs similar to RISC-V.

Move implementation to one file and delete now unused files.  Hide
implementation details.  Remove function parameter names from header
file to avoid name conflicts.

Provide VFP support if __SOFTFP__ is not defined like glibc.

Reviewed-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
Signed-off-by: Eshan dhawan <eshandhawan51@gmail.com>
---
 newlib/libc/machine/arm/machine/fenv-mangle.h |  53 ---
 .../libc/machine/arm/machine/fenv-softfloat.h | 187 ----------
 newlib/libc/machine/arm/machine/fenv-vfp.h    | 187 ----------
 newlib/libc/machine/arm/sys/fenv.h            |  66 +---
 newlib/libm/machine/arm/Makefile.am           |   4 +-
 newlib/libm/machine/arm/Makefile.in           |  19 +-
 newlib/libm/machine/arm/fenv-softfp.c         |  32 --
 newlib/libm/machine/arm/fenv-vfp.c            |  32 --
 newlib/libm/machine/arm/fenv.c                | 319 ++++++------------
 9 files changed, 127 insertions(+), 772 deletions(-)
 delete mode 100644 newlib/libc/machine/arm/machine/fenv-mangle.h
 delete mode 100644 newlib/libc/machine/arm/machine/fenv-softfloat.h
 delete mode 100644 newlib/libc/machine/arm/machine/fenv-vfp.h
 delete mode 100644 newlib/libm/machine/arm/fenv-softfp.c
 delete mode 100644 newlib/libm/machine/arm/fenv-vfp.c

diff --git a/newlib/libc/machine/arm/machine/fenv-mangle.h b/newlib/libc/machine/arm/machine/fenv-mangle.h
deleted file mode 100644
index 476f7b20c..000000000
--- a/newlib/libc/machine/arm/machine/fenv-mangle.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * Copyright (c) 2013 Andrew Turner <andrew@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifdef _FENV_MANGLE_H_
-#error Only include fenv-mangle.h once
-#endif
-
-#define	_FENV_MANGLE_H_
-
-#ifndef FENV_MANGLE
-#error FENV_MANGLE is undefined
-#endif
-
-#define	feclearexcept	FENV_MANGLE(feclearexcept)
-#define	fegetexceptflag	FENV_MANGLE(fegetexceptflag)
-#define	fesetexceptflag	FENV_MANGLE(fesetexceptflag)
-#define	feraiseexcept	FENV_MANGLE(feraiseexcept)
-#define	fetestexcept	FENV_MANGLE(fetestexcept)
-#define	fegetround	FENV_MANGLE(fegetround)
-#define	fesetround	FENV_MANGLE(fesetround)
-#define	fegetenv	FENV_MANGLE(fegetenv)
-#define	feholdexcept	FENV_MANGLE(feholdexcept)
-#define	fesetenv	FENV_MANGLE(fesetenv)
-#define	feupdateenv	FENV_MANGLE(feupdateenv)
-#define	feenableexcept	FENV_MANGLE(feenableexcept)
-#define	fedisableexcept	FENV_MANGLE(fedisableexcept)
-#define	fegetexcept	FENV_MANGLE(fegetexcept)
-
diff --git a/newlib/libc/machine/arm/machine/fenv-softfloat.h b/newlib/libc/machine/arm/machine/fenv-softfloat.h
deleted file mode 100644
index 5d33e18d0..000000000
--- a/newlib/libc/machine/arm/machine/fenv-softfloat.h
+++ /dev/null
@@ -1,187 +0,0 @@
- /*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2004-2011 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#ifndef	_SYS_FENV_H_
-#error "This file is meant to be included only by <sys/fenv.h>."
-#endif
-/* the file can be added from architecture specific fenv.h file found in
- *libc/sys/arch/sys *
- *
- * This file implements the functionality of <fenv.h> on platforms that
- * lack an FPU and use softfloat in libc for floating point.  To use it,
- * you must write an <fenv.h> that provides the following:
- *
- *   - a typedef for fenv_t, which may be an integer or struct type
- *   - a typedef for fexcept_t (XXX This file assumes fexcept_t is a
- *     simple integer type containing the exception mask.)
- *   - definitions of FE_* constants for the five exceptions and four
- *     rounding modes in IEEE 754, as described in fenv(3)
- *   - a definition, and the corresponding external symbol, for FE_DFL_ENV
- *   - a macro __set_env(env, flags, mask, rnd), which sets the given fenv_t
- *     from the exception flags, mask, and rounding mode
- *   - macros __env_flags(env), __env_mask(env), and __env_round(env), which
- *     extract fields from an fenv_t
- *   - a definition of __fenv_static
- *
- * If the architecture supports an optional FPU, it's recommended that you
- * define fenv_t and fexcept_t to match the hardware ABI.  Otherwise, it
- * doesn't matter how you define them.
- */
-#include <errno.h>
-
-int __softfloat_float_exception_flags;
-int __softfloat_float_exception_mask;
-int __softfloat_float_rounding_mode;
-
-
-__fenv_static inline int
-feclearexcept(int excepts)
-{
-
-	__softfloat_float_exception_flags &= ~excepts;
-	return (0);
-}
-
-__fenv_static inline int
-fegetexceptflag(fexcept_t *flagp, int excepts)
-{
-
-	*flagp = __softfloat_float_exception_flags & excepts;
-	return (0);
-}
-
-__fenv_static inline int
-fesetexceptflag(const fexcept_t *flagp, int excepts)
-{
-
-	__softfloat_float_exception_flags &= ~excepts;
-	__softfloat_float_exception_flags |= *flagp & excepts;
-	return (0);
-}
-
-__fenv_static inline int
-feraiseexcept(int excepts)
-{
-
-	return (excepts  ?  -ENOTSUP : 0);
-}
-
-__fenv_static inline int
-fetestexcept(int excepts)
-{
-
-	return (__softfloat_float_exception_flags & excepts);
-}
-
-__fenv_static inline int
-fegetround(void)
-{
-
-	return (__softfloat_float_rounding_mode);
-}
-
-__fenv_static inline int
-fesetround(int round)
-{
-
-	__softfloat_float_rounding_mode = round;
-	return (0);
-}
-
-__fenv_static inline int
-fegetenv(fenv_t *envp)
-{
-
-	__set_env(*envp, __softfloat_float_exception_flags,
-	    __softfloat_float_exception_mask, __softfloat_float_rounding_mode);
-	return (0);
-}
-
-__fenv_static inline int
-feholdexcept(fenv_t *envp)
-{
-	fenv_t __env;
-
-	fegetenv(envp);
-	__softfloat_float_exception_flags = 0;
-	__softfloat_float_exception_mask = 0;
-	return (0);
-}
-
-__fenv_static inline int
-fesetenv(const fenv_t *envp)
-{
-
-	__softfloat_float_exception_flags = __env_flags(*envp);
-	__softfloat_float_exception_mask = __env_mask(*envp);
-	__softfloat_float_rounding_mode = __env_round(*envp);
-	return (0);
-}
-
-__fenv_static inline int
-feupdateenv(const fenv_t *envp)
-{
-	int __oflags = __softfloat_float_exception_flags;
-
-	fesetenv(envp);
-	feraiseexcept(__oflags);
-	return (0);
-}
-
-#if __BSD_VISIBLE
-
-/* We currently provide no external definitions of the functions below. */
-
-__fenv_static inline int
-feenableexcept(int __mask)
-{
-	int __omask = __softfloat_float_exception_mask;
-
-	__softfloat_float_exception_mask |= __mask;
-	return (__omask);
-}
-
-__fenv_static inline int
-fedisableexcept(int __mask)
-{
-	int __omask = __softfloat_float_exception_mask;
-
-	__softfloat_float_exception_mask &= ~__mask;
-	return (__omask);
-}
-
-__fenv_static inline int
-fegetexcept(void)
-{
-
-	return (__softfloat_float_exception_mask);
-}
-
-#endif /* __BSD_VISIBLE */
diff --git a/newlib/libc/machine/arm/machine/fenv-vfp.h b/newlib/libc/machine/arm/machine/fenv-vfp.h
deleted file mode 100644
index 25d71f3ab..000000000
--- a/newlib/libc/machine/arm/machine/fenv-vfp.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
- *
- * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-
-
-#define	vmrs_fpscr(__r)	__asm __volatile("vmrs %0, fpscr" : "=&r"(__r))
-#define	vmsr_fpscr(__r)	__asm __volatile("vmsr fpscr, %0" : : "r"(__r))
-
-
-#define _FPU_MASK_SHIFT	8
-
-__fenv_static inline int feclearexcept(int excepts)
-{
-	fexcept_t __fpsr;
-
-	vmrs_fpscr(__fpsr);
-	__fpsr &= ~excepts;
-	vmsr_fpscr(__fpsr);
-	return (0);
-}
-
-__fenv_static inline int
-fegetexceptflag(fexcept_t *flagp, int excepts)
-{
-	fexcept_t __fpsr;
-
-	vmrs_fpscr(__fpsr);
-	*flagp = __fpsr & excepts;
-	return (0);
-}
-
-__fenv_static inline int
-fesetexceptflag(const fexcept_t *flagp, int excepts)
-{
-	fexcept_t __fpsr;
-
-	vmrs_fpscr(__fpsr);
-	__fpsr &= ~excepts;
-	__fpsr |= *flagp & excepts;
-	vmsr_fpscr(__fpsr);
-	return (0);
-}
-
-__fenv_static inline int
-feraiseexcept(int excepts)
-{
-	fexcept_t __ex = excepts;
-
-	fesetexceptflag(&__ex, excepts);	/* XXX */
-	return (0);
-}
-
-__fenv_static inline int
-fetestexcept(int excepts)
-{
-	fexcept_t __fpsr;
-
-	vmrs_fpscr(__fpsr);
-	return (__fpsr & excepts);
-}
-
-__fenv_static inline int
-fegetround(void)
-{
-	fenv_t __fpsr;
-
-	vmrs_fpscr(__fpsr);
-	return (__fpsr & _ROUND_MASK);
-}
-
-__fenv_static inline int
-fesetround(int round)
-{
-	fenv_t __fpsr;
-
-	vmrs_fpscr(__fpsr);
-	__fpsr &= ~(_ROUND_MASK);
-	__fpsr |= round;
-	vmsr_fpscr(__fpsr);
-	return (0);
-}
-
-__fenv_static inline int
-fegetenv(fenv_t *envp)
-{
-
-	vmrs_fpscr(*envp);
-	return (0);
-}
-
-__fenv_static inline int
-feholdexcept(fenv_t *envp)
-{
-	fenv_t __env;
-
-	vmrs_fpscr(__env);
-	*envp = __env;
-	__env &= ~(FE_ALL_EXCEPT);
-	vmsr_fpscr(__env);
-	return (0);
-}
-
-__fenv_static inline int
-fesetenv(const fenv_t *envp)
-{
-
-	vmsr_fpscr(*envp);
-	return (0);
-}
-
-__fenv_static inline int
-feupdateenv(const fenv_t *envp)
-{
-	fexcept_t __fpsr;
-
-	vmrs_fpscr(__fpsr);
-	vmsr_fpscr(*envp);
-	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
-	return (0);
-}
-
-#if __BSD_VISIBLE
-
-/* We currently provide no external definitions of the functions below. */
-
-__fenv_static inline int
-feenableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	vmrs_fpscr(__old_fpsr);
-	__new_fpsr = __old_fpsr |
-	    ((__mask & FE_ALL_EXCEPT) << _FPU_MASK_SHIFT);
-	vmsr_fpscr(__new_fpsr);
-	return ((__old_fpsr >> _FPU_MASK_SHIFT) & FE_ALL_EXCEPT);
-}
-
-__fenv_static inline int
-fedisableexcept(int __mask)
-{
-	fenv_t __old_fpsr, __new_fpsr;
-
-	vmrs_fpscr(__old_fpsr);
-	__new_fpsr = __old_fpsr &
-	    ~((__mask & FE_ALL_EXCEPT) << _FPU_MASK_SHIFT);
-	vmsr_fpscr(__new_fpsr);
-	return ((__old_fpsr >> _FPU_MASK_SHIFT) & FE_ALL_EXCEPT);
-}
-
-__fenv_static inline int
-fegetexcept(void)
-{
-	fenv_t __fpsr;
-
-	vmrs_fpscr(__fpsr);
-	return (__fpsr & FE_ALL_EXCEPT);
-}
-
-#endif /* __BSD_VISIBLE */
-
diff --git a/newlib/libc/machine/arm/sys/fenv.h b/newlib/libc/machine/arm/sys/fenv.h
index 740995a1a..70bd57be4 100644
--- a/newlib/libc/machine/arm/sys/fenv.h
+++ b/newlib/libc/machine/arm/sys/fenv.h
@@ -38,10 +38,6 @@
 extern "C" {
 #endif
 
-#ifndef	__fenv_static
-#define	__fenv_static static
-#endif
-
 typedef int fenv_t;
 typedef int fexcept_t;
 
@@ -51,7 +47,7 @@ typedef int fexcept_t;
 #define	FE_OVERFLOW	0x0004
 #define	FE_UNDERFLOW	0x0008
 #define	FE_INEXACT	0x0010
-#ifdef __ARM_PCS_VFP
+#ifndef __SOFTFP__
 #define	FE_DENORMAL	0x0080
 #define	FE_ALL_EXCEPT	(FE_DIVBYZERO | FE_INEXACT | \
 			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW | FE_DENORMAL)
@@ -60,61 +56,33 @@ typedef int fexcept_t;
 			 FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
 #endif
 
-
-
 /* Rounding modes */
-#define	VFP_FE_TONEAREST	0x00000000
-#define	VFP_FE_UPWARD		0x00400000
-#define	VFP_FE_DOWNWARD		0x00800000
-#define	VFP_FE_TOWARDZERO	0x00c00000
-
-#ifdef __ARM_PCS_VFP
-#define	FE_TONEAREST	VFP_FE_TONEAREST
-#define	FE_UPWARD	VFP_FE_UPWARD
-#define	FE_DOWNWARD	VFP_FE_DOWNWARD
-#define	FE_TOWARDZERO	VFP_FE_TOWARDZERO
-#else
-#define	FE_TONEAREST	0x0000
-#define	FE_TOWARDZERO	0x0001
-#define	FE_UPWARD	0x0002
-#define	FE_DOWNWARD	0x0003
-#endif
-#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
-			 FE_UPWARD | FE_TOWARDZERO)
-
+#define	FE_TONEAREST		0x00000000
+#define	FE_UPWARD		0x00400000
+#define	FE_DOWNWARD		0x00800000
+#define	FE_TOWARDZERO		0x00c00000
 
 /* Default floating-point environment */
-
 extern const fenv_t	*_fe_dfl_env;
 #define	FE_DFL_ENV	(_fe_dfl_env)
 
-/* We need to be able to map status flag positions to mask flag positions */
-#ifndef __ARM_PCS_VFP
-#define	_FPUSW_SHIFT	16
-#define	_ENABLE_MASK	(FE_ALL_EXCEPT << _FPUSW_SHIFT)
-#endif
-
-
-
-int feclearexcept(int excepts);
-int fegetexceptflag(fexcept_t *flagp, int excepts);
-int fesetexceptflag(const fexcept_t *flagp, int excepts);
-int feraiseexcept(int excepts);
-int fetestexcept(int excepts);
+int feclearexcept(int);
+int fegetexceptflag(fexcept_t *, int);
+int fesetexceptflag(const fexcept_t *, int);
+int feraiseexcept(int);
+int fetestexcept(int);
 int fegetround(void);
-int fesetround(int round);
-int fegetenv(fenv_t *envp);
-int feholdexcept(fenv_t *envp);
-int fesetenv(const fenv_t *envp);
-int feupdateenv(const fenv_t *envp);
+int fesetround(int);
+int fegetenv(fenv_t *);
+int feholdexcept(fenv_t *);
+int fesetenv(const fenv_t *);
+int feupdateenv(const fenv_t *);
 #if __BSD_VISIBLE
-int feenableexcept(int __mask);
-int fedisableexcept(int __mask);
+int feenableexcept(int);
+int fedisableexcept(int);
 int fegetexcept(void);
 #endif /* __BSD_VISIBLE */
 
-
-
 #ifdef __cplusplus
 }
 #endif
diff --git a/newlib/libm/machine/arm/Makefile.am b/newlib/libm/machine/arm/Makefile.am
index a64ee59d5..180a37f44 100644
--- a/newlib/libm/machine/arm/Makefile.am
+++ b/newlib/libm/machine/arm/Makefile.am
@@ -32,9 +32,7 @@ LIB_SOURCES = \
 	fesetexceptflag.c \
 	fesetround.c \
 	fetestexcept.c \
-	feupdateenv.c \
-	fenv-vfp.c \
-	fenv-softfp.c 
+	feupdateenv.c
 
 
 noinst_LIBRARIES = lib.a
diff --git a/newlib/libm/machine/arm/Makefile.in b/newlib/libm/machine/arm/Makefile.in
index ecfa684e7..aa23dd4d5 100644
--- a/newlib/libm/machine/arm/Makefile.in
+++ b/newlib/libm/machine/arm/Makefile.in
@@ -83,8 +83,7 @@ am__objects_1 = lib_a-e_sqrt.$(OBJEXT) lib_a-ef_sqrt.$(OBJEXT) \
 	lib_a-fenv.$(OBJEXT) lib_a-feraiseexcept.$(OBJEXT) \
 	lib_a-fesetenv.$(OBJEXT) lib_a-fesetexceptflag.$(OBJEXT) \
 	lib_a-fesetround.$(OBJEXT) lib_a-fetestexcept.$(OBJEXT) \
-	lib_a-feupdateenv.$(OBJEXT) lib_a-fenv-vfp.$(OBJEXT) \
-	lib_a-fenv-softfp.$(OBJEXT)
+	lib_a-feupdateenv.$(OBJEXT)
 am_lib_a_OBJECTS = $(am__objects_1)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
@@ -237,9 +236,7 @@ LIB_SOURCES = \
 	fesetexceptflag.c \
 	fesetround.c \
 	fetestexcept.c \
-	feupdateenv.c \
-	fenv-vfp.c \
-	fenv-softfp.c 
+	feupdateenv.c
 
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(LIB_SOURCES)
@@ -479,18 +476,6 @@ lib_a-feupdateenv.o: feupdateenv.c
 lib_a-feupdateenv.obj: feupdateenv.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feupdateenv.obj `if test -f 'feupdateenv.c'; then $(CYGPATH_W) 'feupdateenv.c'; else $(CYGPATH_W) '$(srcdir)/feupdateenv.c'; fi`
 
-lib_a-fenv-vfp.o: fenv-vfp.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fenv-vfp.o `test -f 'fenv-vfp.c' || echo '$(srcdir)/'`fenv-vfp.c
-
-lib_a-fenv-vfp.obj: fenv-vfp.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fenv-vfp.obj `if test -f 'fenv-vfp.c'; then $(CYGPATH_W) 'fenv-vfp.c'; else $(CYGPATH_W) '$(srcdir)/fenv-vfp.c'; fi`
-
-lib_a-fenv-softfp.o: fenv-softfp.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fenv-softfp.o `test -f 'fenv-softfp.c' || echo '$(srcdir)/'`fenv-softfp.c
-
-lib_a-fenv-softfp.obj: fenv-softfp.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fenv-softfp.obj `if test -f 'fenv-softfp.c'; then $(CYGPATH_W) 'fenv-softfp.c'; else $(CYGPATH_W) '$(srcdir)/fenv-softfp.c'; fi`
-
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
diff --git a/newlib/libm/machine/arm/fenv-softfp.c b/newlib/libm/machine/arm/fenv-softfp.c
deleted file mode 100644
index a576cc1b2..000000000
--- a/newlib/libm/machine/arm/fenv-softfp.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * Copyright (c) 2013 Andrew Turner <andrew@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#define	FENV_MANGLE(x)	__softfp_ ##x
-#include <machine/fenv-mangle.h>
-#include "fenv.c"
-
diff --git a/newlib/libm/machine/arm/fenv-vfp.c b/newlib/libm/machine/arm/fenv-vfp.c
deleted file mode 100644
index 297e81296..000000000
--- a/newlib/libm/machine/arm/fenv-vfp.c
+++ /dev/null
@@ -1,32 +0,0 @@
-/*-
- * Copyright (c) 2013 Andrew Turner <andrew@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * $FreeBSD$
- */
-
-#define	FENV_MANGLE(x)	__vfp_ ##x
-#include <machine/fenv-mangle.h>
-#include "fenv.c"
-
diff --git a/newlib/libm/machine/arm/fenv.c b/newlib/libm/machine/arm/fenv.c
index 5b61ab81f..0735cd1c5 100644
--- a/newlib/libm/machine/arm/fenv.c
+++ b/newlib/libm/machine/arm/fenv.c
@@ -1,7 +1,7 @@
 /*-
  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
  *
- * Copyright (c) 2004 David Schultz <das@FreeBSD.ORG>
+ * Copyright (c) 2004-2005 David Schultz <das@FreeBSD.ORG>
  * Copyright (c) 2013 Andrew Turner <andrew@FreeBSD.ORG>
  * All rights reserved.
  *
@@ -29,300 +29,195 @@
  * $FreeBSD$
  */
 
-#define	__fenv_static
 #include <fenv.h>
 
-#include <machine/acle-compat.h>
-
-#if __ARM_ARCH >= 6
-#define FENV_ARMv6
-#endif
-
-/* When SOFTFP_ABI is defined we are using the softfp ABI. */
-#if defined(__VFP_FP__) && !defined(__ARM_PCS_VFP)
-#define SOFTFP_ABI
+#ifndef __SOFTFP__
+#define	vmrs_fpscr(__r)	__asm __volatile("vmrs %0, fpscr" : "=&r"(__r))
+#define	vmsr_fpscr(__r)	__asm __volatile("vmsr fpscr, %0" : : "r"(__r))
+#define	_FPU_MASK_SHIFT	8
+#define	_ROUND_MASK	(FE_TONEAREST | FE_DOWNWARD | \
+			 FE_UPWARD | FE_TOWARDZERO)
 #endif
 
-
-#ifndef FENV_MANGLE
-/*
- * Hopefully the system ID byte is immutable, so it's valid to use
- * this as a default environment.
- */
 fenv_t __fe_dfl_env = { 0 };
 
 const fenv_t *_fe_dfl_env = &__fe_dfl_env;
-#endif
-
-
-/* If this is a non-mangled softfp version special processing is required */
-#if defined(FENV_MANGLE) || !defined(SOFTFP_ABI) || !defined(FENV_ARMv6)
-
-/*
- * The following macros map between the softfloat emulator's flags and
- * the hardware's FPSR.  The hardware this file was written for doesn't
- * have rounding control bits, so we stick those in the system ID byte.
- */
-#ifndef __ARM_PCS_VFP
-#define	__set_env(env, flags, mask, rnd) env = ((flags)			\
-						| (mask)<<_FPUSW_SHIFT	\
-						| (rnd) << 24)
-#define	__env_flags(env)		((env) & FE_ALL_EXCEPT)
-#define	__env_mask(env)			(((env) >> _FPUSW_SHIFT)	\
-						& FE_ALL_EXCEPT)
-#define	__env_round(env)		(((env) >> 24) & _ROUND_MASK)
-
-#include <machine/fenv-softfloat.h>
-
-#else /* __ARM_PCS_VFP PRESENT */
-
-#include <machine/fenv-vfp.h>
-
-#endif /* __ARM_PCS_VFP */
-
-#ifdef __GNUC_GNU_INLINE__
-#error "This file must be compiled with C99 'inline' semantics"
-#endif
-
-extern inline int feclearexcept(int excepts);
-extern inline int fegetexceptflag(fexcept_t *flagp, int excepts);
-extern inline int fesetexceptflag(const fexcept_t *flagp, int excepts);
-extern inline int feraiseexcept(int excepts);
-extern inline int fetestexcept(int excepts);
-extern inline int fegetround(void);
-extern inline int fesetround(int round);
-extern inline int fegetenv(fenv_t *envp);
-extern inline int feholdexcept(fenv_t *envp);
-extern inline int fesetenv(const fenv_t *envp);
-extern inline int feupdateenv(const fenv_t *envp);
-extern inline int feenableexcept(int __mask);
-extern inline int fedisableexcept(int __mask);
-extern inline int fegetexcept(void);
-
-#else /* !FENV_MANGLE && SOFTFP_ABI */
-/* Set by libc when the VFP unit is enabled */
-
-int _libc_arm_fpu_present;
-
-int __softfp_feclearexcept(int excepts);
-int __softfp_fegetexceptflag(fexcept_t *flagp, int excepts);
-int __softfp_fesetexceptflag(const fexcept_t *flagp, int excepts);
-int __softfp_feraiseexcept(int excepts);
-int __softfp_fetestexcept(int excepts);
-int __softfp_fegetround(void);
-int __softfp_fesetround(int round);
-int __softfp_fegetenv(fenv_t *envp);
-int __softfp_feholdexcept(fenv_t *envp);
-int __softfp_fesetenv(const fenv_t *envp);
-int __softfp_feupdateenv(const fenv_t *envp);
-int __softfp_feenableexcept(int __mask);
-int __softfp_fedisableexcept(int __mask);
-int __softfp_fegetexcept(void);
-
-int __vfp_feclearexcept(int excepts);
-int __vfp_fegetexceptflag(fexcept_t *flagp, int excepts);
-int __vfp_fesetexceptflag(const fexcept_t *flagp, int excepts);
-int __vfp_feraiseexcept(int excepts);
-int __vfp_fetestexcept(int excepts);
-int __vfp_fegetround(void);
-int __vfp_fesetround(int round);
-int __vfp_fegetenv(fenv_t *envp);
-int __vfp_feholdexcept(fenv_t *envp);
-int __vfp_fesetenv(const fenv_t *envp);
-int __vfp_feupdateenv(const fenv_t *envp);
-int __vfp_feenableexcept(int __mask);
-int __vfp_fedisableexcept(int __mask);
-int __vfp_fegetexcept(void);
-
-static int
-__softfp_round_to_vfp(int round)
-{
-
-	switch (round) {
-	case FE_TONEAREST:
-	default:
-		return VFP_FE_TONEAREST;
-	case FE_TOWARDZERO:
-		return VFP_FE_TOWARDZERO;
-	case FE_UPWARD:
-		return VFP_FE_UPWARD;
-	case FE_DOWNWARD:
-		return VFP_FE_DOWNWARD;
-	}
-}
-
-static int
-__softfp_round_from_vfp(int round)
-{
-
-	switch (round) {
-	case VFP_FE_TONEAREST:
-	default:
-		return FE_TONEAREST;
-	case VFP_FE_TOWARDZERO:
-		return FE_TOWARDZERO;
-	case VFP_FE_UPWARD:
-		return FE_UPWARD;
-	case VFP_FE_DOWNWARD:
-		return FE_DOWNWARD;
-	}
-}
 
 int feclearexcept(int excepts)
 {
+#ifndef __SOFTFP__
+	fexcept_t __fpsr;
 
-	if (_libc_arm_fpu_present)
-		__vfp_feclearexcept(excepts);
-	__softfp_feclearexcept(excepts);
-
+	vmrs_fpscr(__fpsr);
+	__fpsr &= ~excepts;
+	vmsr_fpscr(__fpsr);
+#endif
 	return (0);
 }
 
 int fegetexceptflag(fexcept_t *flagp, int excepts)
 {
-	fexcept_t __vfp_flagp;
-
-	__vfp_flagp = 0;
-	if (_libc_arm_fpu_present)
-		__vfp_fegetexceptflag(&__vfp_flagp, excepts);
-	__softfp_fegetexceptflag(flagp, excepts);
-
-	*flagp |= __vfp_flagp;
+#ifndef __SOFTFP__
+	fexcept_t __fpsr;
 
+	vmrs_fpscr(__fpsr);
+	__fpsr &= ~excepts;
+	__fpsr |= *flagp & excepts;
+	vmsr_fpscr(__fpsr);
+#endif
 	return (0);
 }
 
 int fesetexceptflag(const fexcept_t *flagp, int excepts)
 {
+#ifndef __SOFTFP__
+	fexcept_t __fpsr;
 
-	if (_libc_arm_fpu_present)
-		__vfp_fesetexceptflag(flagp, excepts);
-	__softfp_fesetexceptflag(flagp, excepts);
-
+	vmrs_fpscr(__fpsr);
+	__fpsr &= ~excepts;
+	__fpsr |= *flagp & excepts;
+	vmsr_fpscr(__fpsr);
+#endif
 	return (0);
 }
 
 int feraiseexcept(int excepts)
 {
+#ifndef __SOFTFP__
+	fexcept_t __ex = excepts;
 
-	if (_libc_arm_fpu_present)
-		__vfp_feraiseexcept(excepts);
-	__softfp_feraiseexcept(excepts);
-
+	fesetexceptflag(&__ex, excepts);
+#endif
 	return (0);
 }
 
 int fetestexcept(int excepts)
 {
-	int __got_excepts;
+#ifndef __SOFTFP__
+	fexcept_t __fpsr;
 
-	__got_excepts = 0;
-	if (_libc_arm_fpu_present)
-		__got_excepts = __vfp_fetestexcept(excepts);
-	__got_excepts |= __softfp_fetestexcept(excepts);
-
-	return (__got_excepts);
+	vmrs_fpscr(__fpsr);
+	return (__fpsr & excepts);
+#else
+	return (0);
+#endif
 }
 
 int fegetround(void)
 {
+#ifndef __SOFTFP__
+	fenv_t __fpsr;
 
-	if (_libc_arm_fpu_present)
-		return __softfp_round_from_vfp(__vfp_fegetround());
-	return __softfp_fegetround();
+	vmrs_fpscr(__fpsr);
+	return (__fpsr & _ROUND_MASK);
+#else
+#ifdef FE_TONEAREST
+	return (FE_TONEAREST);
+#else
+	return (0);
+#endif
+#endif
 }
 
 int fesetround(int round)
 {
+#ifndef __SOFTFP__
+	fenv_t __fpsr;
 
-	if (_libc_arm_fpu_present)
-		__vfp_fesetround(__softfp_round_to_vfp(round));
-	__softfp_fesetround(round);
-
+	vmrs_fpscr(__fpsr);
+	__fpsr &= ~(_ROUND_MASK);
+	__fpsr |= round;
+	vmsr_fpscr(__fpsr);
+#endif
 	return (0);
 }
 
 int fegetenv(fenv_t *envp)
 {
-	fenv_t __vfp_envp;
-
-	__vfp_envp = 0;
-	if (_libc_arm_fpu_present)
-		__vfp_fegetenv(&__vfp_envp);
-	__softfp_fegetenv(envp);
-	*envp |= __vfp_envp;
 
+#ifndef __SOFTFP__
+	vmrs_fpscr(*envp);
+#endif
 	return (0);
 }
 
 int feholdexcept(fenv_t *envp)
 {
-	fenv_t __vfp_envp;
-
-	__vfp_envp = 0;
-	if (_libc_arm_fpu_present)
-		__vfp_feholdexcept(&__vfp_envp);
-	__softfp_feholdexcept(envp);
-	*envp |= __vfp_envp;
+#ifndef __SOFTFP__
+	fenv_t __env;
 
+	vmrs_fpscr(__env);
+	*envp = __env;
+	__env &= ~(FE_ALL_EXCEPT);
+	vmsr_fpscr(__env);
+#endif
 	return (0);
 }
 
 int fesetenv(const fenv_t *envp)
 {
 
-	if (_libc_arm_fpu_present)
-		__vfp_fesetenv(envp);
-	__softfp_fesetenv(envp);
-
+#ifndef __SOFTFP__
+	vmsr_fpscr(*envp);
+#endif
 	return (0);
 }
 
 int feupdateenv(const fenv_t *envp)
 {
+#ifndef __SOFTFP__
+	fexcept_t __fpsr;
 
-	if (_libc_arm_fpu_present)
-		__vfp_feupdateenv(envp);
-	__softfp_feupdateenv(envp);
-
+	vmrs_fpscr(__fpsr);
+	vmsr_fpscr(*envp);
+	feraiseexcept(__fpsr & FE_ALL_EXCEPT);
+#else
+#if defined(FE_NOMASK_ENV) && FE_ALL_EXCEPT != 0
+	if (envp == FE_NOMASK_ENV)
+		return (1);
+#endif
+#endif
 	return (0);
 }
 
 int feenableexcept(int __mask)
 {
-	int __unmasked;
-
-	__unmasked = 0;
-	if (_libc_arm_fpu_present)
-		__unmasked = __vfp_feenableexcept(__mask);
-	__unmasked |= __softfp_feenableexcept(__mask);
+#ifndef __SOFTFP__
+	fenv_t __old_fpsr, __new_fpsr;
 
-	return (__unmasked);
+	vmrs_fpscr(__old_fpsr);
+	__new_fpsr = __old_fpsr |
+	    ((__mask & FE_ALL_EXCEPT) << _FPU_MASK_SHIFT);
+	vmsr_fpscr(__new_fpsr);
+	return ((__old_fpsr >> _FPU_MASK_SHIFT) & FE_ALL_EXCEPT);
+#else
+	return (0);
+#endif
 }
 
 int fedisableexcept(int __mask)
 {
-	int __unmasked;
+#ifndef __SOFTFP__
+	fenv_t __old_fpsr, __new_fpsr;
 
-	__unmasked = 0;
-	if (_libc_arm_fpu_present)
-		__unmasked = __vfp_fedisableexcept(__mask);
-	__unmasked |= __softfp_fedisableexcept(__mask);
-
-	return (__unmasked);
+	vmrs_fpscr(__old_fpsr);
+	__new_fpsr = __old_fpsr &
+	    ~((__mask & FE_ALL_EXCEPT) << _FPU_MASK_SHIFT);
+	vmsr_fpscr(__new_fpsr);
+	return ((__old_fpsr >> _FPU_MASK_SHIFT) & FE_ALL_EXCEPT);
+#else
+	return (0);
+#endif
 }
 
 int fegetexcept(void)
 {
-	int __unmasked;
-
-	__unmasked = 0;
-	if (_libc_arm_fpu_present)
-		__unmasked = __vfp_fegetexcept();
-	__unmasked |= __softfp_fegetexcept();
-
-	return (__unmasked);
-}
+#ifndef __SOFTFP__
+	fenv_t __fpsr;
 
+	vmrs_fpscr(__fpsr);
+	return (__fpsr & FE_ALL_EXCEPT);
+#else
+	return (0);
 #endif
-
+}
-- 
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 2/2] arm: Remove superfluous fenv stub files
  2020-07-19 11:01 [PATCH 0/2] Fix fenv support for ARM Sebastian Huber
  2020-07-19 11:01 ` [PATCH 1/2] arm: Fix fenv support Sebastian Huber
@ 2020-07-19 11:01 ` Sebastian Huber
  2020-07-23  5:13 ` [PATCH 0/2] Fix fenv support for ARM Sebastian Huber
  2 siblings, 0 replies; 9+ messages in thread
From: Sebastian Huber @ 2020-07-19 11:01 UTC (permalink / raw)
  To: newlib

Signed-off-by: Sebastian Huber <sebastian.huber@embedded-brains.de>
---
 newlib/libm/machine/arm/Makefile.am       | 15 +---
 newlib/libm/machine/arm/Makefile.in       | 94 +----------------------
 newlib/libm/machine/arm/fe_dfl_env.c      |  7 --
 newlib/libm/machine/arm/feclearexcept.c   |  7 --
 newlib/libm/machine/arm/fegetenv.c        |  7 --
 newlib/libm/machine/arm/fegetexceptflag.c |  7 --
 newlib/libm/machine/arm/fegetround.c      |  7 --
 newlib/libm/machine/arm/feholdexcept.c    |  7 --
 newlib/libm/machine/arm/feraiseexcept.c   |  7 --
 newlib/libm/machine/arm/fesetenv.c        |  7 --
 newlib/libm/machine/arm/fesetexceptflag.c |  7 --
 newlib/libm/machine/arm/fesetround.c      |  7 --
 newlib/libm/machine/arm/fetestexcept.c    |  7 --
 newlib/libm/machine/arm/feupdateenv.c     |  7 --
 14 files changed, 3 insertions(+), 190 deletions(-)
 delete mode 100644 newlib/libm/machine/arm/fe_dfl_env.c
 delete mode 100644 newlib/libm/machine/arm/feclearexcept.c
 delete mode 100644 newlib/libm/machine/arm/fegetenv.c
 delete mode 100644 newlib/libm/machine/arm/fegetexceptflag.c
 delete mode 100644 newlib/libm/machine/arm/fegetround.c
 delete mode 100644 newlib/libm/machine/arm/feholdexcept.c
 delete mode 100644 newlib/libm/machine/arm/feraiseexcept.c
 delete mode 100644 newlib/libm/machine/arm/fesetenv.c
 delete mode 100644 newlib/libm/machine/arm/fesetexceptflag.c
 delete mode 100644 newlib/libm/machine/arm/fesetround.c
 delete mode 100644 newlib/libm/machine/arm/fetestexcept.c
 delete mode 100644 newlib/libm/machine/arm/feupdateenv.c

diff --git a/newlib/libm/machine/arm/Makefile.am b/newlib/libm/machine/arm/Makefile.am
index 180a37f44..50b29a063 100644
--- a/newlib/libm/machine/arm/Makefile.am
+++ b/newlib/libm/machine/arm/Makefile.am
@@ -20,20 +20,7 @@ LIB_SOURCES = \
 	sf_rint.c \
 	sf_round.c \
 	sf_trunc.c \
-	feclearexcept.c \
-	fe_dfl_env.c\
-	fegetenv.c \
-	fegetexceptflag.c \
-	fegetround.c \
-	feholdexcept.c \
-	fenv.c \
-	feraiseexcept.c \
-	fesetenv.c \
-	fesetexceptflag.c \
-	fesetround.c \
-	fetestexcept.c \
-	feupdateenv.c
-
+	fenv.c
 
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(LIB_SOURCES)
diff --git a/newlib/libm/machine/arm/Makefile.in b/newlib/libm/machine/arm/Makefile.in
index aa23dd4d5..2b831f232 100644
--- a/newlib/libm/machine/arm/Makefile.in
+++ b/newlib/libm/machine/arm/Makefile.in
@@ -77,13 +77,7 @@ am__objects_1 = lib_a-e_sqrt.$(OBJEXT) lib_a-ef_sqrt.$(OBJEXT) \
 	lib_a-sf_ceil.$(OBJEXT) lib_a-sf_floor.$(OBJEXT) \
 	lib_a-sf_nearbyint.$(OBJEXT) lib_a-sf_rint.$(OBJEXT) \
 	lib_a-sf_round.$(OBJEXT) lib_a-sf_trunc.$(OBJEXT) \
-	lib_a-feclearexcept.$(OBJEXT) lib_a-fe_dfl_env.$(OBJEXT) \
-	lib_a-fegetenv.$(OBJEXT) lib_a-fegetexceptflag.$(OBJEXT) \
-	lib_a-fegetround.$(OBJEXT) lib_a-feholdexcept.$(OBJEXT) \
-	lib_a-fenv.$(OBJEXT) lib_a-feraiseexcept.$(OBJEXT) \
-	lib_a-fesetenv.$(OBJEXT) lib_a-fesetexceptflag.$(OBJEXT) \
-	lib_a-fesetround.$(OBJEXT) lib_a-fetestexcept.$(OBJEXT) \
-	lib_a-feupdateenv.$(OBJEXT)
+	lib_a-fenv.$(OBJEXT)
 am_lib_a_OBJECTS = $(am__objects_1)
 lib_a_OBJECTS = $(am_lib_a_OBJECTS)
 DEFAULT_INCLUDES = -I.@am__isrc@
@@ -224,19 +218,7 @@ LIB_SOURCES = \
 	sf_rint.c \
 	sf_round.c \
 	sf_trunc.c \
-	feclearexcept.c \
-	fe_dfl_env.c\
-	fegetenv.c \
-	fegetexceptflag.c \
-	fegetround.c \
-	feholdexcept.c \
-	fenv.c \
-	feraiseexcept.c \
-	fesetenv.c \
-	fesetexceptflag.c \
-	fesetround.c \
-	fetestexcept.c \
-	feupdateenv.c
+	fenv.c
 
 noinst_LIBRARIES = lib.a
 lib_a_SOURCES = $(LIB_SOURCES)
@@ -398,84 +380,12 @@ lib_a-sf_trunc.o: sf_trunc.c
 lib_a-sf_trunc.obj: sf_trunc.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-sf_trunc.obj `if test -f 'sf_trunc.c'; then $(CYGPATH_W) 'sf_trunc.c'; else $(CYGPATH_W) '$(srcdir)/sf_trunc.c'; fi`
 
-lib_a-feclearexcept.o: feclearexcept.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feclearexcept.o `test -f 'feclearexcept.c' || echo '$(srcdir)/'`feclearexcept.c
-
-lib_a-feclearexcept.obj: feclearexcept.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feclearexcept.obj `if test -f 'feclearexcept.c'; then $(CYGPATH_W) 'feclearexcept.c'; else $(CYGPATH_W) '$(srcdir)/feclearexcept.c'; fi`
-
-lib_a-fe_dfl_env.o: fe_dfl_env.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fe_dfl_env.o `test -f 'fe_dfl_env.c' || echo '$(srcdir)/'`fe_dfl_env.c
-
-lib_a-fe_dfl_env.obj: fe_dfl_env.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fe_dfl_env.obj `if test -f 'fe_dfl_env.c'; then $(CYGPATH_W) 'fe_dfl_env.c'; else $(CYGPATH_W) '$(srcdir)/fe_dfl_env.c'; fi`
-
-lib_a-fegetenv.o: fegetenv.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fegetenv.o `test -f 'fegetenv.c' || echo '$(srcdir)/'`fegetenv.c
-
-lib_a-fegetenv.obj: fegetenv.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fegetenv.obj `if test -f 'fegetenv.c'; then $(CYGPATH_W) 'fegetenv.c'; else $(CYGPATH_W) '$(srcdir)/fegetenv.c'; fi`
-
-lib_a-fegetexceptflag.o: fegetexceptflag.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fegetexceptflag.o `test -f 'fegetexceptflag.c' || echo '$(srcdir)/'`fegetexceptflag.c
-
-lib_a-fegetexceptflag.obj: fegetexceptflag.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fegetexceptflag.obj `if test -f 'fegetexceptflag.c'; then $(CYGPATH_W) 'fegetexceptflag.c'; else $(CYGPATH_W) '$(srcdir)/fegetexceptflag.c'; fi`
-
-lib_a-fegetround.o: fegetround.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fegetround.o `test -f 'fegetround.c' || echo '$(srcdir)/'`fegetround.c
-
-lib_a-fegetround.obj: fegetround.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fegetround.obj `if test -f 'fegetround.c'; then $(CYGPATH_W) 'fegetround.c'; else $(CYGPATH_W) '$(srcdir)/fegetround.c'; fi`
-
-lib_a-feholdexcept.o: feholdexcept.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feholdexcept.o `test -f 'feholdexcept.c' || echo '$(srcdir)/'`feholdexcept.c
-
-lib_a-feholdexcept.obj: feholdexcept.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feholdexcept.obj `if test -f 'feholdexcept.c'; then $(CYGPATH_W) 'feholdexcept.c'; else $(CYGPATH_W) '$(srcdir)/feholdexcept.c'; fi`
-
 lib_a-fenv.o: fenv.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fenv.o `test -f 'fenv.c' || echo '$(srcdir)/'`fenv.c
 
 lib_a-fenv.obj: fenv.c
 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fenv.obj `if test -f 'fenv.c'; then $(CYGPATH_W) 'fenv.c'; else $(CYGPATH_W) '$(srcdir)/fenv.c'; fi`
 
-lib_a-feraiseexcept.o: feraiseexcept.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feraiseexcept.o `test -f 'feraiseexcept.c' || echo '$(srcdir)/'`feraiseexcept.c
-
-lib_a-feraiseexcept.obj: feraiseexcept.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feraiseexcept.obj `if test -f 'feraiseexcept.c'; then $(CYGPATH_W) 'feraiseexcept.c'; else $(CYGPATH_W) '$(srcdir)/feraiseexcept.c'; fi`
-
-lib_a-fesetenv.o: fesetenv.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fesetenv.o `test -f 'fesetenv.c' || echo '$(srcdir)/'`fesetenv.c
-
-lib_a-fesetenv.obj: fesetenv.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fesetenv.obj `if test -f 'fesetenv.c'; then $(CYGPATH_W) 'fesetenv.c'; else $(CYGPATH_W) '$(srcdir)/fesetenv.c'; fi`
-
-lib_a-fesetexceptflag.o: fesetexceptflag.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fesetexceptflag.o `test -f 'fesetexceptflag.c' || echo '$(srcdir)/'`fesetexceptflag.c
-
-lib_a-fesetexceptflag.obj: fesetexceptflag.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fesetexceptflag.obj `if test -f 'fesetexceptflag.c'; then $(CYGPATH_W) 'fesetexceptflag.c'; else $(CYGPATH_W) '$(srcdir)/fesetexceptflag.c'; fi`
-
-lib_a-fesetround.o: fesetround.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fesetround.o `test -f 'fesetround.c' || echo '$(srcdir)/'`fesetround.c
-
-lib_a-fesetround.obj: fesetround.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fesetround.obj `if test -f 'fesetround.c'; then $(CYGPATH_W) 'fesetround.c'; else $(CYGPATH_W) '$(srcdir)/fesetround.c'; fi`
-
-lib_a-fetestexcept.o: fetestexcept.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fetestexcept.o `test -f 'fetestexcept.c' || echo '$(srcdir)/'`fetestexcept.c
-
-lib_a-fetestexcept.obj: fetestexcept.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-fetestexcept.obj `if test -f 'fetestexcept.c'; then $(CYGPATH_W) 'fetestexcept.c'; else $(CYGPATH_W) '$(srcdir)/fetestexcept.c'; fi`
-
-lib_a-feupdateenv.o: feupdateenv.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feupdateenv.o `test -f 'feupdateenv.c' || echo '$(srcdir)/'`feupdateenv.c
-
-lib_a-feupdateenv.obj: feupdateenv.c
-	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-feupdateenv.obj `if test -f 'feupdateenv.c'; then $(CYGPATH_W) 'feupdateenv.c'; else $(CYGPATH_W) '$(srcdir)/feupdateenv.c'; fi`
-
 ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
 	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
 	unique=`for i in $$list; do \
diff --git a/newlib/libm/machine/arm/fe_dfl_env.c b/newlib/libm/machine/arm/fe_dfl_env.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/fe_dfl_env.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/feclearexcept.c b/newlib/libm/machine/arm/feclearexcept.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/feclearexcept.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/fegetenv.c b/newlib/libm/machine/arm/fegetenv.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/fegetenv.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/fegetexceptflag.c b/newlib/libm/machine/arm/fegetexceptflag.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/fegetexceptflag.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/fegetround.c b/newlib/libm/machine/arm/fegetround.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/fegetround.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/feholdexcept.c b/newlib/libm/machine/arm/feholdexcept.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/feholdexcept.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/feraiseexcept.c b/newlib/libm/machine/arm/feraiseexcept.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/feraiseexcept.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/fesetenv.c b/newlib/libm/machine/arm/fesetenv.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/fesetenv.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/fesetexceptflag.c b/newlib/libm/machine/arm/fesetexceptflag.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/fesetexceptflag.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/fesetround.c b/newlib/libm/machine/arm/fesetround.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/fesetround.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/fetestexcept.c b/newlib/libm/machine/arm/fetestexcept.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/fetestexcept.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
diff --git a/newlib/libm/machine/arm/feupdateenv.c b/newlib/libm/machine/arm/feupdateenv.c
deleted file mode 100644
index 8cbee7771..000000000
--- a/newlib/libm/machine/arm/feupdateenv.c
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * (c) Copyright 2019 Joel Sherrill <joel@rtems.org>
- */
-
-#include "../../fenv/fenv_stub.c"
-- 
2.26.2


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] Fix fenv support for ARM
  2020-07-19 11:01 [PATCH 0/2] Fix fenv support for ARM Sebastian Huber
  2020-07-19 11:01 ` [PATCH 1/2] arm: Fix fenv support Sebastian Huber
  2020-07-19 11:01 ` [PATCH 2/2] arm: Remove superfluous fenv stub files Sebastian Huber
@ 2020-07-23  5:13 ` Sebastian Huber
  2020-07-27  8:07   ` Corinna Vinschen
  2 siblings, 1 reply; 9+ messages in thread
From: Sebastian Huber @ 2020-07-23  5:13 UTC (permalink / raw)
  To: newlib, Eshan Dhawan, Joel Sherrill

On 19/07/2020 13:01, Sebastian Huber wrote:

> This patch set addresses some issues which popped up while building Newlib for
> ARM with GCC 10 which enables -fno-common by default.
>
> Eshan dhawan (1):
>    arm: Fix fenv support
>
> Sebastian Huber (1):
>    arm: Remove superfluous fenv stub files

I just noticed that the stub files I removed are not superfluous. Its 
seems they are necessary to somehow overwrite the default 
implementations in:

newlib/libm/fenv

There seems to be some build system magic involved here. I guess we have 
to split up fenv.c and move all the functions to individual files 
matching the ones in newlib/libm/fenv?


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] arm: Fix fenv support
  2020-07-19 11:01 ` [PATCH 1/2] arm: Fix fenv support Sebastian Huber
@ 2020-07-23  5:16   ` Sebastian Huber
  2020-07-30 22:51   ` Keith Packard
  1 sibling, 0 replies; 9+ messages in thread
From: Sebastian Huber @ 2020-07-23  5:16 UTC (permalink / raw)
  To: newlib

On 19/07/2020 13:01, Sebastian Huber wrote:

> From: Eshan dhawan<eshandhawan51@gmail.com>
>
> The previous fenv support for ARM used the soft-float implementation of
> FreeBSD.  Newlib uses the one from libgcc by default.  They are not
> compatible.  Having an GCC incompatible soft-float fenv support in
> Newlib makes no sense.  A long-term solution could be to provide a
> libgcc compatible soft-float support.  This likely requires changes in
> the GCC configuration.  For now, provide a stub implementation for
> soft-float multilibs similar to RISC-V.
>
> Move implementation to one file and delete now unused files.  Hide
> implementation details.  Remove function parameter names from header
> file to avoid name conflicts.
>
> Provide VFP support if __SOFTFP__ is not defined like glibc.
>
> Reviewed-by: Sebastian Huber<sebastian.huber@embedded-brains.de>
> Signed-off-by: Eshan dhawan<eshandhawan51@gmail.com>
This patch is still an improvement and fixes the ARM support of Newlib. 
It would be nice to commit it and then in a second step split it up into 
individual files.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] Fix fenv support for ARM
  2020-07-23  5:13 ` [PATCH 0/2] Fix fenv support for ARM Sebastian Huber
@ 2020-07-27  8:07   ` Corinna Vinschen
  2020-07-29  5:07     ` Sebastian Huber
  0 siblings, 1 reply; 9+ messages in thread
From: Corinna Vinschen @ 2020-07-27  8:07 UTC (permalink / raw)
  To: newlib

On Jul 23 07:13, Sebastian Huber wrote:
> On 19/07/2020 13:01, Sebastian Huber wrote:
> 
> > This patch set addresses some issues which popped up while building Newlib for
> > ARM with GCC 10 which enables -fno-common by default.
> > 
> > Eshan dhawan (1):
> >    arm: Fix fenv support
> > 
> > Sebastian Huber (1):
> >    arm: Remove superfluous fenv stub files
> 
> I just noticed that the stub files I removed are not superfluous. Its seems
> they are necessary to somehow overwrite the default implementations in:
> 
> newlib/libm/fenv
> 
> There seems to be some build system magic involved here. I guess we have to
> split up fenv.c and move all the functions to individual files matching the
> ones in newlib/libm/fenv?

Splitting is probably better.  When you created and tested a new patchset,
feel free to push it.


Thanks,
Corinna

-- 
Corinna Vinschen
Cygwin Maintainer
Red Hat


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] Fix fenv support for ARM
  2020-07-27  8:07   ` Corinna Vinschen
@ 2020-07-29  5:07     ` Sebastian Huber
  2020-07-29 15:07       ` Sebastian Huber
  0 siblings, 1 reply; 9+ messages in thread
From: Sebastian Huber @ 2020-07-29  5:07 UTC (permalink / raw)
  To: newlib

On 27/07/2020 10:07, Corinna Vinschen via Newlib wrote:

> On Jul 23 07:13, Sebastian Huber wrote:
>> On 19/07/2020 13:01, Sebastian Huber wrote:
>>
>>> This patch set addresses some issues which popped up while building Newlib for
>>> ARM with GCC 10 which enables -fno-common by default.
>>>
>>> Eshan dhawan (1):
>>>     arm: Fix fenv support
>>>
>>> Sebastian Huber (1):
>>>     arm: Remove superfluous fenv stub files
>> I just noticed that the stub files I removed are not superfluous. Its seems
>> they are necessary to somehow overwrite the default implementations in:
>>
>> newlib/libm/fenv
>>
>> There seems to be some build system magic involved here. I guess we have to
>> split up fenv.c and move all the functions to individual files matching the
>> ones in newlib/libm/fenv?
> Splitting is probably better.  When you created and tested a new patchset,
> feel free to push it.

I checked in two patches:

https://sourceware.org/git?p=newlib-cygwin.git;a=commit;h=b7a6e02dc6a5289bfa489c0e7b6539abd281e2c6

https://sourceware.org/git?p=newlib-cygwin.git;a=commit;h=3ca43259686187e081d317e2b406724a849c9d7b

I hope the ARM fenv support issues are now fixed.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 0/2] Fix fenv support for ARM
  2020-07-29  5:07     ` Sebastian Huber
@ 2020-07-29 15:07       ` Sebastian Huber
  0 siblings, 0 replies; 9+ messages in thread
From: Sebastian Huber @ 2020-07-29 15:07 UTC (permalink / raw)
  To: newlib

On 29/07/2020 07:07, Sebastian Huber wrote:

> On 27/07/2020 10:07, Corinna Vinschen via Newlib wrote:
>
>> On Jul 23 07:13, Sebastian Huber wrote:
>>> On 19/07/2020 13:01, Sebastian Huber wrote:
>>>
>>>> This patch set addresses some issues which popped up while building 
>>>> Newlib for
>>>> ARM with GCC 10 which enables -fno-common by default.
>>>>
>>>> Eshan dhawan (1):
>>>>     arm: Fix fenv support
>>>>
>>>> Sebastian Huber (1):
>>>>     arm: Remove superfluous fenv stub files
>>> I just noticed that the stub files I removed are not superfluous. 
>>> Its seems
>>> they are necessary to somehow overwrite the default implementations in:
>>>
>>> newlib/libm/fenv
>>>
>>> There seems to be some build system magic involved here. I guess we 
>>> have to
>>> split up fenv.c and move all the functions to individual files 
>>> matching the
>>> ones in newlib/libm/fenv?
>> Splitting is probably better.  When you created and tested a new 
>> patchset,
>> feel free to push it.
>
> I checked in two patches:
>
> https://sourceware.org/git?p=newlib-cygwin.git;a=commit;h=b7a6e02dc6a5289bfa489c0e7b6539abd281e2c6 
>
>
> https://sourceware.org/git?p=newlib-cygwin.git;a=commit;h=3ca43259686187e081d317e2b406724a849c9d7b 
>
>
> I hope the ARM fenv support issues are now fixed.

No, it was not fixed. I checked in an additional patch:

https://sourceware.org/git?p=newlib-cygwin.git;a=commit;h=ba283d8777b617696342cad1f973e22b03bc7c74

Now at least all the linker issues are resolved.


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 1/2] arm: Fix fenv support
  2020-07-19 11:01 ` [PATCH 1/2] arm: Fix fenv support Sebastian Huber
  2020-07-23  5:16   ` Sebastian Huber
@ 2020-07-30 22:51   ` Keith Packard
  1 sibling, 0 replies; 9+ messages in thread
From: Keith Packard @ 2020-07-30 22:51 UTC (permalink / raw)
  To: Sebastian Huber, newlib

[-- Attachment #1: Type: text/plain, Size: 1456 bytes --]

Sebastian Huber <sebastian.huber@embedded-brains.de> writes:

> The previous fenv support for ARM used the soft-float implementation of
> FreeBSD.  Newlib uses the one from libgcc by default.  They are not
> compatible.  Having an GCC incompatible soft-float fenv support in
> Newlib makes no sense.  A long-term solution could be to provide a
> libgcc compatible soft-float support.  This likely requires changes in
> the GCC configuration.  For now, provide a stub implementation for
> soft-float multilibs similar to RISC-V.

Thanks for cleaning this up.

One thing I think we're still missing is the setting of
math_errhandling. That value is currently set to MATH_ERRNO in math.h,
which indicates that the underlying system will set errno, but that it
won't raise any exceptions. I think we should figure out when exceptions
will be raised and set math_errhandling to match. That can be decided at
compile time -- platforms with HW floats and exception support should
make math_errhandling include MATH_ERREXCEPT.

This does leave me a bit confused about how this should work on a
processor with HW float and SW double support though. In that case,
operations involving single-precision arithmetic may offer exceptions
and rounding mode support while double-precision operations will
not. The C99 spec doesn't appear to have any guidance for this case,
which means we need to come up with some kind of answer.

-- 
-keith

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-07-30 22:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-19 11:01 [PATCH 0/2] Fix fenv support for ARM Sebastian Huber
2020-07-19 11:01 ` [PATCH 1/2] arm: Fix fenv support Sebastian Huber
2020-07-23  5:16   ` Sebastian Huber
2020-07-30 22:51   ` Keith Packard
2020-07-19 11:01 ` [PATCH 2/2] arm: Remove superfluous fenv stub files Sebastian Huber
2020-07-23  5:13 ` [PATCH 0/2] Fix fenv support for ARM Sebastian Huber
2020-07-27  8:07   ` Corinna Vinschen
2020-07-29  5:07     ` Sebastian Huber
2020-07-29 15:07       ` Sebastian Huber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).