Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src provide a common softfloat fenv implemenation and use it for...



details:   https://anonhg.NetBSD.org/src/rev/09aa67f6382c
branches:  trunk
changeset: 822502:09aa67f6382c
user:      chs <chs%NetBSD.org@localhost>
date:      Wed Mar 22 23:11:07 2017 +0000

description:
provide a common softfloat fenv implemenation and use it for softfloat builds.
restore ABI compatibility with previous releases for ieeefp.h on sh3.
add namespace.h protection for all the fenv interfaces.
use MKSOFTFLOAT on sh3 instead of assuming softfloat.
standardize on comparing MKSOFTFLOAT with "no".
remove the arm-specific softfloat fenv code (which also had several bugs).
fix logic errors in the arm hardfloat feraiseexcept() and feupdateenv().

diffstat:

 external/gpl3/gcc/lib/libgcc/libgcc/Makefile |    4 +-
 include/fenv.h                               |   45 +++++++++-
 lib/libc/arch/m68k/gen/Makefile.inc          |    6 +-
 lib/libc/arch/sh3/Makefile.inc               |    6 +-
 lib/libm/Makefile                            |   49 +++++++++--
 lib/libm/arch/aarch64/fenv.c                 |   46 +++++------
 lib/libm/arch/alpha/fenv.c                   |   27 +++---
 lib/libm/arch/arm/fenv.c                     |  108 ++------------------------
 lib/libm/arch/hppa/fenv.c                    |   23 +++++-
 lib/libm/arch/i387/fenv.c                    |   23 +++++-
 lib/libm/arch/ia64/fenv.c                    |   25 +++++-
 lib/libm/arch/m68k/fenv.c                    |   28 ++++++-
 lib/libm/arch/mips/fenv.c                    |   28 ++++++-
 lib/libm/arch/powerpc/fenv.c                 |   28 ++++++-
 lib/libm/arch/riscv/fenv.c                   |   25 +++++-
 lib/libm/arch/sh3/fenv.c                     |   25 +++++-
 lib/libm/arch/sparc/fenv.c                   |   23 +++++-
 lib/libm/arch/sparc64/fenv.c                 |   23 +++++-
 lib/libm/arch/x86_64/fenv.c                  |   23 +++++-
 lib/libm/softfloat/feclearexcept.c           |   51 ++++++++++++
 lib/libm/softfloat/fedisableexcept.c         |   52 +++++++++++++
 lib/libm/softfloat/feenableexcept.c          |   52 +++++++++++++
 lib/libm/softfloat/fegetenv.c                |   52 +++++++++++++
 lib/libm/softfloat/fegetexcept.c             |   49 ++++++++++++
 lib/libm/softfloat/fegetexceptflag.c         |   50 ++++++++++++
 lib/libm/softfloat/fegetround.c              |   49 ++++++++++++
 lib/libm/softfloat/feholdexcept.c            |   54 +++++++++++++
 lib/libm/softfloat/feraiseexcept.c           |   74 ++++++++++++++++++
 lib/libm/softfloat/fesetenv.c                |   52 +++++++++++++
 lib/libm/softfloat/fesetexceptflag.c         |   51 ++++++++++++
 lib/libm/softfloat/fesetround.c              |   50 ++++++++++++
 lib/libm/softfloat/fetestexcept.c            |   54 +++++++++++++
 lib/libm/softfloat/feupdateenv.c             |   57 ++++++++++++++
 lib/libm/src/namespace.h                     |   17 ++++-
 share/mk/bsd.own.mk                          |   27 +++---
 share/mk/bsd.sys.mk                          |    5 +-
 sys/arch/arm/include/fenv.h                  |   25 ++++++-
 sys/arch/arm/include/ieeefp.h                |    8 +-
 sys/arch/m68k/include/fenv.h                 |   22 ++---
 sys/arch/m68k/include/ieeefp.h               |    4 +-
 sys/arch/mips/include/fenv.h                 |   31 ++++---
 sys/arch/mips/include/ieeefp.h               |    5 +-
 sys/arch/powerpc/include/fenv.h              |   28 +++---
 sys/arch/powerpc/include/ieeefp.h            |   13 ++-
 sys/arch/riscv/include/fenv.h                |    4 +-
 sys/arch/sh3/include/fenv.h                  |    6 +-
 sys/arch/sh3/include/ieeefp.h                |   99 ++++++++++++++++++++++++-
 tools/gcc/Makefile                           |    4 +-
 48 files changed, 1354 insertions(+), 256 deletions(-)

diffs (truncated from 2568 to 300 lines):

diff -r 7dc1b965257c -r 09aa67f6382c external/gpl3/gcc/lib/libgcc/libgcc/Makefile
--- a/external/gpl3/gcc/lib/libgcc/libgcc/Makefile      Wed Mar 22 22:53:06 2017 +0000
+++ b/external/gpl3/gcc/lib/libgcc/libgcc/Makefile      Wed Mar 22 23:11:07 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.26 2016/03/31 06:59:44 martin Exp $
+#      $NetBSD: Makefile,v 1.27 2017/03/22 23:11:07 chs Exp $
 
 REQUIRETOOLS=  yes
 NOLINT=                # defined
@@ -23,7 +23,7 @@
 .endif
 
 # XXXGCC5 GCC 5.3 has all these in libgcc and we have them in libc.
-.if ${MKSOFTFLOAT} == "yes"
+.if ${MKSOFTFLOAT} != "no"
 LIB2ADD_EDITED= 
${G_LIB2ADD:T:Nfloatsisf.c:Nfloatunsisf.c:Nfloatsidf.c:Nfloatunsidf.c:Nfixsfsi.c:Nextendsfdf2.c:Naddsf3.c:Nmulsf3.c:Ndivsf3.c:Nadddf3.c:Nsubdf3.c:Nmuldf3.c:Ndivdf3.c:Nfixdfsi.c:S/.asm/.S/}
 .else
 LIB2ADD_EDITED=        ${G_LIB2ADD:T:S/.asm/.S/}
diff -r 7dc1b965257c -r 09aa67f6382c include/fenv.h
--- a/include/fenv.h    Wed Mar 22 22:53:06 2017 +0000
+++ b/include/fenv.h    Wed Mar 22 23:11:07 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: fenv.h,v 1.24 2017/02/23 02:06:12 scole Exp $  */
+/*     $NetBSD: fenv.h,v 1.25 2017/03/22 23:11:07 chs Exp $    */
 /*
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -29,12 +29,7 @@
 
 #include <sys/featuretest.h>
 
-#if !defined(__aarch64__) && !defined(__arm__) && !defined(__i386__) \
-    && !defined(__ia64__) \
-    && !defined(__hppa__) && !defined(__powerpc__) && !defined(__mips__) \
-    && !defined(__or1k__) && !defined(__riscv__) && !defined(__sparc__) \
-    && !defined(__x86_64__) && !defined(__alpha__) && !defined(__sh__) \
-    && !(defined(__m68k__) && !(defined(__mc68010__) || defined(__mcoldfire__)))
+#if defined(__vax__)
 # ifndef __TEST_FENV
 #  error       "fenv.h is currently not supported for this architecture"
 # endif
@@ -45,6 +40,42 @@
 # include <machine/fenv.h>
 #endif
 
+#if \
+       (defined(__arm__) && defined(__SOFTFP__)) || \
+       (defined(__m68k__) && !defined(__HAVE_68881__)) || \
+       defined(__mips_soft_float) || \
+       (defined(__powerpc__) && defined(_SOFT_FLOAT)) || \
+       (defined(__sh__) && !defined(__SH_FPU_ANY__)) || \
+       0
+
+/*
+ * Common definitions for softfloat.
+ */
+
+typedef int fexcept_t;
+
+#ifndef __HAVE_FENV_SOFTFLOAT_DEFS
+
+typedef struct {
+       int     __flags;
+       int     __mask;
+       int     __round;
+} fenv_t;
+
+#define __FENV_GET_FLAGS(__envp)       (__envp)->__flags
+#define __FENV_GET_MASK(__envp)                (__envp)->__mask
+#define __FENV_GET_ROUND(__envp)       (__envp)->__round
+#define __FENV_SET_FLAGS(__envp, __val) \
+       (__envp)->__flags = (__val)
+#define __FENV_SET_MASK(__envp, __val) \
+       (__envp)->__mask = (__val)
+#define __FENV_SET_ROUND(__envp, __val) \
+       (__envp)->__round = (__val)
+
+#endif /* __FENV_GET_FLAGS */
+
+#endif /* softfloat */
+
 __BEGIN_DECLS
 
 /* Function prototypes */
diff -r 7dc1b965257c -r 09aa67f6382c lib/libc/arch/m68k/gen/Makefile.inc
--- a/lib/libc/arch/m68k/gen/Makefile.inc       Wed Mar 22 22:53:06 2017 +0000
+++ b/lib/libc/arch/m68k/gen/Makefile.inc       Wed Mar 22 23:11:07 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.34 2016/10/07 11:10:44 christos Exp $
+#      $NetBSD: Makefile.inc,v 1.35 2017/03/22 23:11:07 chs Exp $
 
 SRCS+= alloca.S fabs.S
 
@@ -31,10 +31,10 @@
 # 68000-based machines build with a libgcc that includes
 # much of the (soft)float and integer support that would 
 # otherwise be compiled here.
-.if    (${MACHINE_ARCH} == "m68000" || ${MKSOFTFLOAT} == "yes")
+.if    (${MACHINE_ARCH} == "m68000" || ${MKSOFTFLOAT} != "no")
 SRCS+= compat_modf_ieee754.c                   # generic ieee754 version
 SRCS+= flt_rounds_softfloat.S
-.if ${MKSOFTFLOAT} != "yes"
+.if ${MKSOFTFLOAT} == "no"
 SRCS+= fpfake.c
 .endif
 .endif
diff -r 7dc1b965257c -r 09aa67f6382c lib/libc/arch/sh3/Makefile.inc
--- a/lib/libc/arch/sh3/Makefile.inc    Wed Mar 22 22:53:06 2017 +0000
+++ b/lib/libc/arch/sh3/Makefile.inc    Wed Mar 22 23:11:07 2017 +0000
@@ -1,6 +1,10 @@
-#      $NetBSD: Makefile.inc,v 1.6 2006/06/17 18:04:23 uwe Exp $
+#      $NetBSD: Makefile.inc,v 1.7 2017/03/22 23:11:08 chs Exp $
 
 SRCS+= __sigaction14_sigtramp.c __sigtramp2.S
 
+.if ${MKSOFTFLOAT} != "no"
+
 CPPFLAGS+=      -DSOFTFLOAT # -DSOFTFLOAT_NEED_FIXUNS
 .include <softfloat/Makefile.inc>
+
+.endif
diff -r 7dc1b965257c -r 09aa67f6382c lib/libm/Makefile
--- a/lib/libm/Makefile Wed Mar 22 22:53:06 2017 +0000
+++ b/lib/libm/Makefile Wed Mar 22 23:11:07 2017 +0000
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.188 2017/02/23 02:05:30 scole Exp $
+#  $NetBSD: Makefile,v 1.189 2017/03/22 23:11:08 chs Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -57,7 +57,9 @@
 .PATH: ${.CURDIR}/arch/aarch64
 ARCH_SRCS = e_sqrt.S e_sqrtf.S s_fabsf.S
 ARCH_SRCS+= s_fma.S s_fmaf.S s_fmax.S s_fmaxf.S s_fmin.S s_fminf.S
+.if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS+= fenv.c
+.endif
 COMMON_SRCS+= e_sqrtl.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .elif (${LIBC_MACHINE_ARCH} == "alpha")
@@ -67,8 +69,10 @@
 COPTS+=        -mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i
 .elif (${LIBC_MACHINE_CPU} == "arm")
 .PATH.c: ${.CURDIR}/arch/arm
-COMMON_SRCS+= fenv.c s_nexttowardf.c \
-       s_nearbyint.c s_rintl.c
+.if ${MKSOFTFLOAT} == "no"
+COMMON_SRCS+= fenv.c
+.endif
+COMMON_SRCS+= s_nexttowardf.c s_nearbyint.c s_rintl.c
 .for f in fenv.c lrint.S lrintf.S s_fabsf.S s_fma.S s_fmaf.S
 COPTS.$f +=    -mfpu=vfp
 .endfor
@@ -82,16 +86,15 @@
 COMMON_SRCS += fenv.c
 .elif (${LIBC_MACHINE_ARCH} == "hppa")
 .PATH.c: ${.CURDIR}/arch/hppa
-COMMON_SRCS+= fenv.c s_nexttowardf.c \
-       s_nearbyint.c s_rintl.c
+COMMON_SRCS+= fenv.c s_nexttowardf.c s_nearbyint.c s_rintl.c
 .elif (${LIBC_MACHINE_ARCH} == "sparc")
 .PATH: ${.CURDIR}/arch/sparc
 COMMON_SRCS+= fenv.c
 COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .elif (${LIBC_MACHINE_ARCH} == "sparc64")
 .PATH: ${.CURDIR}/arch/sparc64
-COMMON_SRCS+= fenv.c s_nexttowardf.c \
-       s_nearbyint.c s_rintl.c
+COMMON_SRCS+= fenv.c
+COMMON_SRCS+= s_nexttowardf.c s_nearbyint.c s_rintl.c
 .ifndef _COMPAT_M32_MK_
 COMMON_SRCS+= s_nexttoward.c
 .endif
@@ -137,7 +140,7 @@
 COPTS+=-m68040
 ARCH_SRCS = s_copysign.S s_finite.S
 .else
-.if (${MKSOFTFLOAT} != "yes")
+.if (${MKSOFTFLOAT} == "no")
 .PATH: ${.CURDIR}/arch/mc68881 ${.CURDIR}/arch/m68k
 ARCH_SRCS = e_acos.S e_asin.S e_atanh.S e_cosh.S e_exp.S e_fmod.S e_log.S \
            e_log10.S e_remainder.S e_scalb.S e_sinh.S e_sqrt.S s_atan.S \
@@ -160,9 +163,8 @@
 .elif (${LIBC_MACHINE_CPU} == "riscv")
 .PATH: ${.CURDIR}/arch/riscv
 
+.if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
-
-.if ${MKSOFTFLOAT} == "no"
 ARCH_SRCS = e_sqrt.S e_sqrtf.S
 ARCH_SRCS += s_copysign.S s_copysignf.S
 ARCH_SRCS += s_fabs.S s_fabsf.S
@@ -172,14 +174,20 @@
 .endif
 .elif (${LIBC_MACHINE_ARCH} == "powerpc")
 .PATH: ${.CURDIR}/arch/powerpc
+.if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
+.endif
 .elif (${LIBC_MACHINE_CPU} == "mips")
 .PATH: ${.CURDIR}/arch/mips
+.if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
+.endif
 .elif (${LIBC_MACHINE_CPU} == "sh3")
 .PATH: ${.CURDIR}/arch/sh3
+.if ${MKSOFTFLOAT} == "no"
 COMMON_SRCS += fenv.c
 .endif
+.endif
 
 WARNS?=5
 
@@ -198,6 +206,27 @@
 .endif
 CPPFLAGS+=-DLIBM_SCCS
 
+.if ${MKSOFTFLOAT} != "no"
+.PATH: ${.CURDIR}/softfloat
+.include "${.CURDIR}/../libc/libcincludes.mk"
+CPPFLAGS+=     -I${ARCHDIR}/softfloat
+COMMON_SRCS += \
+       feclearexcept.c \
+       fedisableexcept.c \
+       feenableexcept.c \
+       fegetenv.c \
+       fegetexcept.c \
+       fegetexceptflag.c \
+       fegetround.c \
+       feholdexcept.c \
+       feraiseexcept.c \
+       fesetenv.c \
+       fesetexceptflag.c \
+       fesetround.c \
+       fetestexcept.c \
+       feupdateenv.c
+.endif
+
 LIB=   m
 COMMON_SRCS+= b_exp.c b_log.c b_tgamma.c \
        e_acos.c e_acosf.c e_acosh.c e_acoshf.c e_asin.c e_asinf.c \
diff -r 7dc1b965257c -r 09aa67f6382c lib/libm/arch/aarch64/fenv.c
--- a/lib/libm/arch/aarch64/fenv.c      Wed Mar 22 22:53:06 2017 +0000
+++ b/lib/libm/arch/aarch64/fenv.c      Wed Mar 22 23:11:07 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: fenv.c,v 1.2 2014/12/27 17:52:45 martin Exp $ */
+/* $NetBSD: fenv.c,v 1.3 2017/03/22 23:11:08 chs Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,9 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: fenv.c,v 1.2 2014/12/27 17:52:45 martin Exp $");
+__RCSID("$NetBSD: fenv.c,v 1.3 2017/03/22 23:11:08 chs Exp $");
+
+#include "namespace.h"
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -42,6 +44,23 @@
 
 #include <aarch64/armreg.h>
 
+#ifdef __weak_alias
+__weak_alias(feclearexcept,_feclearexcept)
+__weak_alias(fedisableexcept,_fedisableexcept)
+__weak_alias(feenableexcept,_feenableexcept)
+__weak_alias(fegetenv,_fegetenv)
+__weak_alias(fegetexcept,_fegetexcept)
+__weak_alias(fegetexceptflag,_fegetexceptflag)
+__weak_alias(fegetround,_fegetround)
+__weak_alias(feholdexcept,_feholdexcept)
+__weak_alias(feraiseexcept,_feraiseexcept)
+__weak_alias(fesetenv,_fesetenv)
+__weak_alias(fesetexceptflag,_fesetexceptflag)
+__weak_alias(fesetround,_fesetround)
+__weak_alias(fetestexcept,_fetestexcept)
+__weak_alias(feupdateenv,_feupdateenv)
+#endif
+
 const fenv_t __fe_dfl_env = {
        .__fpsr = 0,
        .__fpcr = FPCR_FZ|FPCR_DN|FPCR_RN,
@@ -87,35 +106,12 @@
 #ifndef lint
        _DIAGASSERT((except & ~FE_ALL_EXCEPT) == 0);
 #endif
-#ifdef __SOFTFP__
-       excepts &= fpgetsticky();
-
-       if (excepts) {
-               siginfo_t info;
-               memset(&info, 0, sizeof info);
-               info.si_signo = SIGFPE;
-               info.si_pid = getpid();
-               info.si_uid = geteuid();
-               if (excepts & FE_UNDERFLOW)



Home | Main Index | Thread Index | Old Index