Hello Eshan,
you produce a lot of extra work for me. Your patch applies now. But it
didn't build:
make[9]: *** No rule to make target 'fenv-vfp.c', needed by
'lib_a-fenv-vfp.o'. Stop.
make[9]: *** Waiting for unfinished jobs....
make[9]: Leaving directory
'/build/git-build/b-gcc-10.1.0-arm-rtems5/arm-rtems5/thumb/newlib/libm/machine/arm'
Why is x86_64 mentioned in the commit message? On the mailing list it
was discussed to use RISC-V as the model. Please improve the commit
message in general. It should reflect all the problems discussed on the
mailing list and how the commit addresses the issues.
Attached is a patch which fixes a couple of obvious things. Please apply
it, review it, test it, and make a v4 patch out of it with an improved
commit message.
>From 3398b5cb51ddc711a439e53df537b9d7bfe6e39c Mon Sep 17 00:00:00 2001
From: Sebastian Huber <sebastian.hu...@embedded-brains.de>
Date: Sat, 18 Jul 2020 10:33:35 +0200
Subject: [PATCH] arm/fenv.c: Fix use of defines and format
Fix the build. Remove superfluous code. Remove parameter names in
the header file. Move implementation details out of the header file.
---
newlib/libc/machine/arm/sys/fenv.h | 47 ++++--------
newlib/libm/machine/arm/Makefile.in | 19 +----
newlib/libm/machine/arm/fenv.c | 114 ++++++++++------------------
3 files changed, 55 insertions(+), 125 deletions(-)
diff --git a/newlib/libc/machine/arm/sys/fenv.h b/newlib/libc/machine/arm/sys/fenv.h
index 0224da38b..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,50 +56,33 @@ typedef int fexcept_t;
FE_INVALID | FE_OVERFLOW | FE_UNDERFLOW)
#endif
-
-
/* Rounding modes */
#define FE_TONEAREST 0x00000000
#define FE_UPWARD 0x00400000
#define FE_DOWNWARD 0x00800000
#define FE_TOWARDZERO 0x00c00000
-#define _ROUND_MASK (FE_TONEAREST | FE_DOWNWARD | \
- FE_UPWARD | FE_TOWARDZERO)
-
-
/* 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.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.c b/newlib/libm/machine/arm/fenv.c
index 457b3cd73..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 <d...@freebsd.org>
+ * Copyright (c) 2004-2005 David Schultz <d...@freebsd.org>
* Copyright (c) 2013 Andrew Turner <and...@freebsd.org>
* All rights reserved.
*
@@ -31,118 +31,104 @@
#include <fenv.h>
-#include <machine/acle-compat.h>
-
-#if __ARM_ARCH >= 6
-#define FENV_ARMv6
+#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
fenv_t __fe_dfl_env = { 0 };
const fenv_t *_fe_dfl_env = &__fe_dfl_env;
-#ifdef __ARM_PCS_VFP
-#define vmrs_fpscr(__r) __asm __volatile("vmrs %0, fpscr" : "=&r"(__r))
-#define vmsr_fpscr(__r) __asm __volatile("vmsr fpscr, %0" : : "r"(__r))
-#endif
-
-#define _FPU_MASK_SHIFT 8
-
int feclearexcept(int excepts)
{
-
-#ifdef __ARM_PCS_VFP
+#ifndef __SOFTFP__
fexcept_t __fpsr;
+
vmrs_fpscr(__fpsr);
__fpsr &= ~excepts;
vmsr_fpscr(__fpsr);
#endif
-
return (0);
}
int fegetexceptflag(fexcept_t *flagp, int excepts)
{
-
-#ifdef __ARM_PCS_VFP
+#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)
{
-
-#ifdef __ARM_PCS_VFP
+#ifndef __SOFTFP__
fexcept_t __fpsr;
+
vmrs_fpscr(__fpsr);
__fpsr &= ~excepts;
__fpsr |= *flagp & excepts;
vmsr_fpscr(__fpsr);
#endif
-
return (0);
}
int feraiseexcept(int excepts)
{
-
-#ifdef __ARM_PCS_VFP
+#ifndef __SOFTFP__
fexcept_t __ex = excepts;
+
fesetexceptflag(&__ex, excepts);
#endif
-
return (0);
}
int fetestexcept(int excepts)
{
-#ifdef __ARM_PCS_VFP
+#ifndef __SOFTFP__
fexcept_t __fpsr;
+
vmrs_fpscr(__fpsr);
return (__fpsr & excepts);
-#endif
-
+#else
return (0);
+#endif
}
int fegetround(void)
{
-
-#ifdef __ARM_PCS_VFP
+#ifndef __SOFTFP__
fenv_t __fpsr;
+
vmrs_fpscr(__fpsr);
return (__fpsr & _ROUND_MASK);
-
#else
-/* For soft float */
-
#ifdef FE_TONEAREST
- return FE_TONEAREST;
-#else
- return 0;
+ return (FE_TONEAREST);
+#else
+ return (0);
#endif
-
#endif
}
int fesetround(int round)
{
-
#ifndef __SOFTFP__
fenv_t __fpsr;
+
vmrs_fpscr(__fpsr);
__fpsr &= ~(_ROUND_MASK);
__fpsr |= round;
vmsr_fpscr(__fpsr);
- return (0);
#endif
-
return (0);
}
@@ -150,29 +136,21 @@ int fegetenv(fenv_t *envp)
{
#ifndef __SOFTFP__
- vmrs_fpscr(*envp);
- return 0;
+ vmrs_fpscr(*envp);
#endif
-
- *envp |= 0;
-
return (0);
}
int feholdexcept(fenv_t *envp)
{
-
#ifndef __SOFTFP__
fenv_t __env;
+
vmrs_fpscr(__env);
*envp = __env;
__env &= ~(FE_ALL_EXCEPT);
vmsr_fpscr(__env);
- return (0);
-
#endif
- *envp |= 0;
-
return (0);
}
@@ -180,54 +158,45 @@ int fesetenv(const fenv_t *envp)
{
#ifndef __SOFTFP__
- vmsr_fpscr(*envp);
+ vmsr_fpscr(*envp);
#endif
return (0);
}
int feupdateenv(const fenv_t *envp)
{
-
#ifndef __SOFTFP__
fexcept_t __fpsr;
+
vmrs_fpscr(__fpsr);
vmsr_fpscr(*envp);
feraiseexcept(__fpsr & FE_ALL_EXCEPT);
-
- return 0;
#else
-
-#if defined FE_NOMASK_ENV && FE_ALL_EXCEPT != 0
-
- if (envp == FE_NOMASK_ENV)
- return 1;
-
+#if defined(FE_NOMASK_ENV) && FE_ALL_EXCEPT != 0
+ if (envp == FE_NOMASK_ENV)
+ return (1);
#endif
-
- return 0;
-
#endif
-
+ return (0);
}
int feenableexcept(int __mask)
{
-
#ifndef __SOFTFP__
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);
-#endif
-
+#else
return (0);
+#endif
}
int fedisableexcept(int __mask)
{
-
#ifndef __SOFTFP__
fenv_t __old_fpsr, __new_fpsr;
@@ -236,22 +205,19 @@ int fedisableexcept(int __mask)
~((__mask & FE_ALL_EXCEPT) << _FPU_MASK_SHIFT);
vmsr_fpscr(__new_fpsr);
return ((__old_fpsr >> _FPU_MASK_SHIFT) & FE_ALL_EXCEPT);
-#endif
-
+#else
return (0);
+#endif
}
int fegetexcept(void)
{
-
#ifndef __SOFTFP__
fenv_t __fpsr;
vmrs_fpscr(__fpsr);
return (__fpsr & FE_ALL_EXCEPT);
-#endif
-
+#else
return (0);
+#endif
}
-
-
--
2.26.2
_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel