From 497d7ca99d45055369ed6784cb46121c123bd038 Mon Sep 17 00:00:00 2001 From: jmcmullan Date: Sun, 28 Oct 2012 14:45:12 +0000 Subject: [PATCH] arch/m68k-all: Add a stub fenv.c implementation for softfloat Signed-off-by: Jason S. McMullan git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@45965 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- arch/m68k-all/mlib/fenv.c | 84 +++++++++++++++++++++++++++++++++++++++++++++++ compiler/mlib/math.h | 4 +++ 2 files changed, 88 insertions(+) diff --git a/arch/m68k-all/mlib/fenv.c b/arch/m68k-all/mlib/fenv.c index b3b5db9709..b3d25bdcaa 100644 --- a/arch/m68k-all/mlib/fenv.c +++ b/arch/m68k-all/mlib/fenv.c @@ -26,6 +26,7 @@ * $FreeBSD: src/lib/msun/arm/fenv.c,v 1.1.20.1 2009/04/15 03:14:26 kensmith Exp $ */ +#include #include /* @@ -33,3 +34,86 @@ * this as a default environment. */ const fenv_t __fe_dfl_env = { }; +static fenv_t fe_env; + +/* FIXME: These are just stubs for the moment for soft-float + * A new implemntation is needed for hard-float support + */ + +/* Clear the supported exceptions represented by EXCEPTS. */ +int feclearexcept (int __excepts) +{ + fe_env.__status_register &= ~__excepts; + return 0; +} + +/* Store implementation-defined representation of the exception flags + indicated by EXCEPTS in the object pointed to by FLAGP. */ +int fegetexceptflag (fexcept_t *__flagp, int __excepts) +{ + *__flagp = __excepts; + return 0; +} + +/* Raise the supported exceptions represented by EXCEPTS. */ +int feraiseexcept (int __excepts) +{ + if (__excepts & (FE_UNDERFLOW | FE_OVERFLOW)) { + errno = ERANGE; + } else if (__excepts) { + errno = EDOM; + } + return 0; +} + +/* Set complete status for exceptions indicated by EXCEPTS according to + the representation in the object pointed to by FLAGP. */ +int fesetexceptflag(const fexcept_t *flagp, int excepts) +{ + fe_env.__status_register &= ~excepts; + return 0; +} + +/* Determine which of subset of the exceptions specified by EXCEPTS are + currently set. */ +int fetestexcept (int __excepts) +{ + return (fe_env.__status_register & __excepts); +} + +/* Store the current floating-point environment in the object pointed + to by ENVP. */ +int fegetenv (fenv_t *envp) +{ + *envp = fe_env; + return 0; +} + +/* Save the current environment in the object pointed to by ENVP, clear + exception flags and install a non-stop mode (if available) for all + exceptions. */ +int feholdexcept (fenv_t *envp) +{ + *envp = fe_env; + errno = 0; + return 0; +} + +/* Establish the floating-point environment represented by the object + pointed to by ENVP. */ +int fesetenv(const fenv_t *envp) +{ + fe_env = *envp; + return 0; +} + +/* Save current exceptions in temporary storage, install environment + represented by object pointed to by ENVP and raise exceptions + according to saved exceptions. */ +int feupdateenv(const fenv_t *envp) +{ + int fexcept = fe_env.__status_register; + fesetenv(envp); + feraiseexcept(fexcept); + return 0; +} diff --git a/compiler/mlib/math.h b/compiler/mlib/math.h index f75d255c35..1877513719 100644 --- a/compiler/mlib/math.h +++ b/compiler/mlib/math.h @@ -68,7 +68,11 @@ extern const union __nan_un { #define MATH_ERRNO 1 #define MATH_ERREXCEPT 2 +#ifdef __mc68000__ +#define math_errhandling MATH_ERRNO +#else #define math_errhandling MATH_ERREXCEPT +#endif /* XXX We need a . */ #if defined(__ia64__) || defined(__sparc64__) -- 2.11.4.GIT