Add default implementation of fenv.h and all methods

The default implementation of the fenv.h methods return
	-EOPNOTSUP. Some of these have implementations appropriate
        for soft-float.

	The intention of the new fenv.h is that it be portable
	and that architectures provide their own implementation
	of sys/fenv.h.
This commit is contained in:
Joel Sherrill 2019-08-08 11:27:06 -05:00 committed by Corinna Vinschen
parent 03f802846f
commit eae68bfc87
18 changed files with 999 additions and 8 deletions

View File

@ -0,0 +1,42 @@
/* Copyright (c) 2017 SiFive Inc. All rights reserved.
This copyrighted material is made available to anyone wishing to use,
modify, copy, or redistribute it subject to the terms and conditions
of the FreeBSD License. This program is distributed in the hope that
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
including the implied warranties of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. A copy of this license is available at
http://www.opensource.org/licenses.
*/
#ifndef _FENV_H
#define _FENV_H
#include <sys/fenv.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Exception */
int feclearexcept(int excepts);
int fegetexceptflag(fexcept_t *flagp, int excepts);
int feraiseexcept(int excepts);
int fesetexceptflag(const fexcept_t *flagp, int excepts);
int fetestexcept(int excepts);
/* Rounding mode */
int fegetround(void);
int fesetround(int rounding_mode);
/* Float environment */
int fegetenv(fenv_t *envp);
int feholdexcept(fenv_t *envp);
int fesetenv(const fenv_t *envp);
int feupdateenv(const fenv_t *envp);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,113 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.org
(c) Copyright 2019 Craig Howlang <craig.howland@caci.com>
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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#ifndef _SYS_FENV_H_
#define _SYS_FENV_H_
/*******************************************************************************
* THIS FILE IS A TEMPLATE, INTENDED TO BE USED AS A STARTING POINT FOR
* TARGET-SPECIFIC FLOATING-POINT IMPLEMENTATIONS. NOTES BELOW HIGHLIGHT THE
* BASICS OF WHAT NEEDS TO BE DEFINED. THE DEFAULT IMPLEMTATION IS
* DEGENERATE, WITH ALL FUNCTIONS RETURNING ERROR AND NO EXCEPTIONS AND NO
* ROUNDING MODES DEFINED (SINCE NONE ARE SUPPORTED).
* THE MACRO VALUES ARE EXAMPLES ONLY, ALTHOUGH TAKEN FROM A WORKING
* IMPLEMENTATION.
* REMOVE THIS NOTICE WHEN COPYING TO A REAL IMPLEMENTATION, REPLACING IT WITH
* ANY TARGET-SPECIFIC NOTES OF INTEREST. THE FENV FUNCTION MAN PAGES POINT TO
* THIS FILE AS A MEANS OF DETERMINING A FUNCTIONAL VS. NON-FUNCTIONAL
* IMPLEMENTATION.
******************************************************************************/
/*
* The following macros are to be defined if the respective exception is
* supported by the implementation, each with a unique bit mask:
*
* FE_DIVBYZERO
* FE_INEXACT
* FE_INVALID
* FE_OVERFLOW
* FE_UNDERFLOW
*
* Other implementation-specific exceptions may be defined, and must start
* with FE_ followed by a capital letter.
*
* FE_ALL_EXCEPT must be defined as the logical OR of all exceptions.
*/
//#define FE_DIVBYZERO 0x00000001
//#define FE_INEXACT 0x00000002
//#define FE_INVALID 0x00000004
//#define FE_OVERFLOW 0x00000008
//#define FE_UNDERFLOW 0x00000010
//#define FE_ALL_EXCEPT \
//(FE_DIVBYZERO|FE_INEXACT|FE_INVALID|FE_OVERFLOW|FE_UNDERFLOW)
#define FE_ALL_EXCEPT 0 /* NONE SUPPORTED IN PLACEHOLDER TEMPLATE */
/*
* The following macros are to be defined if the respective rounding
* direction is supported by the implementation via the fegetround() and
* fesetround() functions, each with a unique positive value.
*
* FE_DOWNWARD
* FE_TONEAREST
* FE_TOWARDZERO
* FE_UPWARD
*
* Other implementation-specific rounding modes may be defined, and must start
* with FE_ followed by a capital letter.
*/
//#define FE_DOWNWARD 1
//#define FE_TONEAREST 2
//#define FE_TOWARDZERO 3
//#define FE_UPWARD 4
/*
* The following typedefs are required. These should be defined properly
* to support the architecture specific implementation. See the C and
* POSIX standards for details:
*
* fenv_t
* fexcept_t
*/
typedef int fenv_t;
typedef int fexcept_t;
/*
* Lastly, a FE_DFL_ENV macro must be defined, representing a pointer
* to const fenv_t that contains the value of the default floating point
* environment.
*
* NOTE: The extern'ed variable fe_default_env_p is an implementation
* detail of this stub. FE_DFL_ENV must point to an instance of
* fenv_t with the default fenv_t. The format of fenv_t and where
* FE_DFL_ENV is are implementation specific.
*/
extern const fenv_t *_fe_dfl_env;
#define FE_DFL_ENV _fe_dfl_env
#endif /* _SYS_FENV_H_ */

View File

@ -8,17 +8,17 @@ else
MATHDIR = math
endif
SUBDIRS = $(MATHDIR) common complex machine
SUBDIRS = $(MATHDIR) common complex fenv machine
libm_la_LDFLAGS = -Xcompiler -nostdlib
if USE_LIBTOOL
SUBLIBS = $(MATHDIR)/lib$(MATHDIR).$(aext) common/libcommon.$(aext) complex/libcomplex.$(aext) $(LIBM_MACHINE_LIB)
SUBLIBS = $(MATHDIR)/lib$(MATHDIR).$(aext) common/libcommon.$(aext) complex/libcomplex.$(aext) fenv/libfenv.$(aext) $(LIBM_MACHINE_LIB)
noinst_LTLIBRARIES = libm.la
libm_la_SOURCES =
libm_la_LIBADD = $(SUBLIBS)
else
SUBLIBS = $(MATHDIR)/lib.$(aext) common/lib.$(aext) complex/lib.$(aext) $(LIBM_MACHINE_LIB)
SUBLIBS = $(MATHDIR)/lib.$(aext) common/lib.$(aext) complex/lib.$(aext) fenv/lib.$(aext) $(LIBM_MACHINE_LIB)
noinst_LIBRARIES = libm.a
libm.a: $(SUBLIBS)
rm -f $@
@ -39,7 +39,7 @@ info_TEXINFOS = libm.texinfo
libm_TEXINFOS = targetdep.tex
libm.dvi: targetdep.tex math/stmp-def complex/stmp-def
libm.dvi: targetdep.tex math/stmp-def complex/stmp-def fenv/stmp-def
stmp-targetdep: force
rm -f tmp.texi
@ -58,6 +58,8 @@ math/stmp-def: stmp-targetdep ; @true
complex/stmp-def: stmp-targetdep ; @true
fenv/stmp-def: stmp-targetdep ; @true
docbook-recursive: force
for d in $(SUBDIRS); do \
if test "$$d" != "."; then \

View File

@ -62,5 +62,5 @@ fi
AC_SUBST(LIBM_MACHINE_LIB)
AC_CONFIG_FILES([Makefile math/Makefile mathfp/Makefile common/Makefile complex/Makefile])
AC_CONFIG_FILES([Makefile math/Makefile mathfp/Makefile common/Makefile complex/Makefile fenv/Makefile])
AC_OUTPUT

View File

@ -0,0 +1,36 @@
## Process this file with automake to generate Makefile.in
AUTOMAKE_OPTIONS = cygnus
INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
src = feclearexcept.c fe_dfl_env.c fegetenv.c fegetexceptflag.c \
fegetround.c feholdexcept.c feraiseexcept.c fesetenv.c \
fesetexceptflag.c fesetround.c fetestexcept.c feupdateenv.c
libcommon_la_LDFLAGS = -Xcompiler -nostdlib
lib_a_CFLAGS = -fbuiltin -fno-math-errno
if USE_LIBTOOL
noinst_LTLIBRARIES = libcommon.la
libcommon_la_SOURCES = $(src)
noinst_DATA = objectlist.awk.in
else
noinst_LIBRARIES = lib.a
lib_a_SOURCES = $(src)
lib_a_CFLAGS += $(AM_CFLAGS)
noinst_DATA =
endif # USE_LIBTOOL
include $(srcdir)/../../Makefile.shared
CHEWOUT_FILES = feclearexcept.def fe_dfl_env.def fegetenv.def \
fegetexceptflag.def fegetround.def feholdexcept.def \
feraiseexcept.def fesetenv.def fesetexceptflag.def fesetround.def \
fetestexcept.def feupdateenv.def
CHAPTERS =
# A partial dependency list.
$(lib_a_OBJECTS): $(srcdir)/../../libc/include/fenv.h

View File

@ -0,0 +1,42 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*
* The implementation must defined FE_DFL_ENV to point to a default
* environment of type fenv_t.
*/
/* Non-static and writable to allow initialization at startup. */
fenv_t __fe_dfl_env = { 0 };
const fenv_t *_fe_dfl_env = &__fe_dfl_env;

View File

@ -0,0 +1,67 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
/*
FUNCTION
<<feclearexcept>>---clear floating-point exception
INDEX
feclearexcept
SYNOPSIS
#include <fenv.h>
int feclearexcept(int <[except]>);
Link with -lm.
DESCRIPTION
This method attempts to clear the floating-point exceptions specified
in <[except]>.
RETURNS
If the <[except]> argument is zero or all requested exceptions were
successfully cleared, this method returns zero. Otherwise, a non-zero
value is returned.
PORTABILITY
ANSI C requires <<feclearexcept>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
#include <fenv.h>
#include <errno.h>
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int feclearexcept(int excepts)
{
return (excepts ? -ENOTSUP : 0);
}

View File

@ -0,0 +1,67 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<fegetenv>>---get current floating-point environment
INDEX
fegetenv
SYNOPSIS
#include <fenv.h>
int fegetenv(fenv_t *<[envp]>);
Link with -lm.
DESCRIPTION
This method attempts to return the floating-point environment
in the area specified by <[envp]>.
RETURNS
If floating-point environment was successfully returned, then
this method returns zero. Otherwise, a non-zero value is returned.
PORTABILITY
ANSI C requires <<fegetenv>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int fegetenv(fenv_t *envp)
{
return -ENOTSUP;
}

View File

@ -0,0 +1,68 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<fegetexceptflag>>---get floating-point status flags
INDEX
fegetexceptflag
SYNOPSIS
#include <fenv.h>
int fegetexceptflag(fexcept_t *<[flagp]>, int <[excepts]>);
Link with -lm.
DESCRIPTION
This method attempts to store an implementation-defined representation
of the states of the floating-point status flags specified by <[excepts]>
in the memory pointed to by <[flagp>].
RETURNS
If the information was successfully returned, this method returns
zero. Otherwise, a non-zero value is returned.
PORTABILITY
ANSI C requires <<fegetexceptflag>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int fegetexceptflag(fexcept_t *flagp, int excepts)
{
return -ENOTSUP;
}

View File

@ -0,0 +1,66 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<fegetround>>---get current rounding direction
INDEX
fegetround
SYNOPSIS
#include <fenv.h>
int fegetround(void);
Link with -lm.
DESCRIPTION
This method returns the current rounding direction.
RETURNS
This method returns the rounding direction, corresponding to the value
of the respective rouding macro. If the current rounding direction cannot
be determined, then a negative value is returned.
PORTABILITY
ANSI C requires <<fegetround>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int fegetround(void)
{
return -ENOTSUP;
}

View File

@ -0,0 +1,70 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<feholdexcept>>---save current floating-point environment
INDEX
feholdexcept
SYNOPSIS
#include <fenv.h>
int feholdexcept(fenv_t *<[envp]>);
Link with -lm.
DESCRIPTION
This method attempts to save the current floating-point environment
in the fenv_t instance pointed to by <[envp]>, clear the floating
point status flags, and then, if supported by the target architecture,
install a "non-stop" (e.g. continue on floating point exceptions) mode
for all floating-point exceptions.
RETURNS
This method will return zero if the non-stop floating-point exception
handler was installed. Otherwise, a non-zero value is returned.
PORTABILITY
ANSI C requires <<feholdexcept>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int feholdexcept(fenv_t *envp)
{
return -ENOTSUP;
}

View File

@ -0,0 +1,67 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<feraiseexcept>>---raise floating-point exception
INDEX
feraiseexcept
SYNOPSIS
#include <fenv.h>
int feraiseexcept(int <[excepts]>);
Link with -lm.
DESCRIPTION
This method attempts to raise the floating-point exceptions specified
in <[except]>.
RETURNS
If the <[excepts]> argument is zero or all requested exceptions were
successfully raised, this method returns zero. Otherwise, a non-zero
value is returned.
PORTABILITY
ANSI C requires <<feraiseexcept>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int feraiseexcept(int excepts)
{
return (excepts ? -ENOTSUP : 0);
}

View File

@ -0,0 +1,72 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<fesetenv>>---set current floating-point environment
INDEX
fesetenv
SYNOPSIS
#include <fenv.h>
int fesetenv(const fenv_t *[<envp>]);
Link with -lm.
DESCRIPTION
This method attempts to establish the floating-point environment
pointed to by <[envp]>. The argument [<envp>] must point to a
floating-point environment obtained via <<fegetenv>> or <<feholdexcept>>
or a floating-point environment macro such as <<FE_DFL_ENV>>.
It only sets the states of the flags as recorded in its argument, and
does not actually raise the associated floating-point exceptions.
RETURNS
If floating-point environment was successfully established, then
this method returns zero. Otherwise, a non-zero value is returned.
PORTABILITY
ANSI C requires <<fesetenv>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int fesetenv(const fenv_t *envp)
{
return -ENOTSUP;
}

View File

@ -0,0 +1,73 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<fesetexceptflag>>---set floating-point status flags
INDEX
fesetexceptflag
SYNOPSIS
#include <fenv.h>
int fesetexceptflag(const fexcept_t *<[flagp]>, int <[excepts]>);
Link with -lm.
DESCRIPTION
This method attempts to set the floating-point status flags specified
by <[excepts]> to the states indicated by <[flagp>]. The argument
[<flagp>] must point to an fexcept_t instance obtained via calling
<<fegetexceptflag>> with at least the floating-point exceptions specified
by the argument <[excepts]>.
This method does not raise any floating-point exceptions. It only
sets the state of the flags.
RETURNS
If the information was successfully returned, this method returns
zero. Otherwise, a non-zero value is returned.
PORTABILITY
ANSI C requires <<fesetexceptflag>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int fesetexceptflag(const fexcept_t *flagp, int excepts)
{
return -ENOTSUP;
}

View File

@ -0,0 +1,67 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<fesetround>>---set current rounding direction
INDEX
fesetround
SYNOPSIS
#include <fenv.h>
int fesetround(int <[round]>);
Link with -lm.
DESCRIPTION
This method attempts to set the current rounding direction represented
by <[round]>. <[round]> must be the value of one of the
rounding-direction macros.
RETURNS
If the rounding mode was successfully established, this method returns
zero. Otherwise, a non-zero value is returned.
PORTABILITY
ANSI C requires <<fesetround>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int fesetround(int round)
{
return -ENOTSUP;
}

View File

@ -0,0 +1,68 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<fetestexcept>>---test floating-point exception flags
INDEX
fetestexcept
SYNOPSIS
#include <fenv.h>
int fetestexcept(int <[except]>);
Link with -lm.
DESCRIPTION
This method test the current floating-point exceptions to determine
which of those specified in <[except]> are currently set.
RETURNS
This method returns the bitwise-inclusive OR of the floating point
exception macros which correspond to the currently set floating point
exceptions.
PORTABILITY
ANSI C requires <<fetestexcept>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int fetestexcept(int excepts)
{
return 0;
}

View File

@ -0,0 +1,72 @@
/*
(c) Copyright 2019 Joel Sherrill <joel@rtems.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 COPYRIGHT HOLDERS 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 COPYRIGHT
HOLDER 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.
*/
#include <fenv.h>
#include <errno.h>
/*
FUNCTION
<<feupdateenv>>---update current floating-point environment
INDEX
feupdateenv
SYNOPSIS
#include <fenv.h>
int feupdateenv(const fenv_t *[<envp>]);
Link with -lm.
DESCRIPTION
This method attempts to save the currently raised floating point
exceptions in its automatic storage, install the floating point
environment specified by [<envp]>, and raise the saved floating
point exceptions.
The argument [<envp>] must point to a floating-point environment
obtained via <<fegetenv>> or <<feholdexcept>>.
RETURNS
If all actions are completed successfully, then this method returns zero.
Otherwise, a non-zero value is returned.
PORTABILITY
ANSI C requires <<feupdateenv>>.
Not all Newlib targets have a working implementation. Refer to
the file <<sys/fenv.h>> to see the status for your target.
*/
/*
* This is a non-functional implementation that should be overridden
* by an architecture specific implementation in newlib/libm/machine/ARCH.
*/
int feupdateenv(const fenv_t *envp)
{
return -ENOTSUP;
}

View File

@ -37,11 +37,9 @@ details. */
#define FE_SSE_EXCEPT_MASK_SHIFT (7)
/* These are writable so we can initialise them at startup. */
static fenv_t fe_dfl_env;
static fenv_t fe_nomask_env;
/* These pointers provide the outside world with read-only access to them. */
const fenv_t *_fe_dfl_env = &fe_dfl_env;
const fenv_t *_fe_nomask_env = &fe_nomask_env;
/* Although Cygwin assumes i686 or above (hence SSE available) these
@ -435,6 +433,7 @@ void
_feinitialise (void)
{
unsigned int edx, eax;
extern fenv_t __fe_dfl_env;
/* Check for presence of SSE: invoke CPUID #1, check EDX bit 25. */
eax = 1;
@ -462,6 +461,6 @@ _feinitialise (void)
fedisableexcept (FE_ALL_EXCEPT);
/* Finally cache state as default environment. */
fegetenv (&fe_dfl_env);
fegetenv (&__fe_dfl_env);
}