aboutsummaryrefslogtreecommitdiff
path: root/newlib/libm
diff options
context:
space:
mode:
authorJoel Sherrill <joel@rtems.org>2019-08-08 11:27:06 -0500
committerCorinna Vinschen <corinna@vinschen.de>2019-08-09 17:49:16 +0200
commiteae68bfc877ef245b3a1550f70eb2c039d3c4fb0 (patch)
treeb61a8b8a1e2e64f01bb382fac55b731817b67d1b /newlib/libm
parent03f802846fdf72e102fa6bbbac8c5d713cdb129c (diff)
downloadnewlib-eae68bfc877ef245b3a1550f70eb2c039d3c4fb0.zip
newlib-eae68bfc877ef245b3a1550f70eb2c039d3c4fb0.tar.gz
newlib-eae68bfc877ef245b3a1550f70eb2c039d3c4fb0.tar.bz2
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.
Diffstat (limited to 'newlib/libm')
-rw-r--r--newlib/libm/Makefile.am10
-rw-r--r--newlib/libm/configure.in2
-rw-r--r--newlib/libm/fenv/Makefile.am36
-rw-r--r--newlib/libm/fenv/fe_dfl_env.c42
-rw-r--r--newlib/libm/fenv/feclearexcept.c67
-rw-r--r--newlib/libm/fenv/fegetenv.c67
-rw-r--r--newlib/libm/fenv/fegetexceptflag.c68
-rw-r--r--newlib/libm/fenv/fegetround.c66
-rw-r--r--newlib/libm/fenv/feholdexcept.c70
-rw-r--r--newlib/libm/fenv/feraiseexcept.c67
-rw-r--r--newlib/libm/fenv/fesetenv.c72
-rw-r--r--newlib/libm/fenv/fesetexceptflag.c73
-rw-r--r--newlib/libm/fenv/fesetround.c67
-rw-r--r--newlib/libm/fenv/fetestexcept.c68
-rw-r--r--newlib/libm/fenv/feupdateenv.c72
15 files changed, 842 insertions, 5 deletions
diff --git a/newlib/libm/Makefile.am b/newlib/libm/Makefile.am
index 8bc2c2c..05afcbf 100644
--- a/newlib/libm/Makefile.am
+++ b/newlib/libm/Makefile.am
@@ -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 \
diff --git a/newlib/libm/configure.in b/newlib/libm/configure.in
index 9bd107c..aec22bd 100644
--- a/newlib/libm/configure.in
+++ b/newlib/libm/configure.in
@@ -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
diff --git a/newlib/libm/fenv/Makefile.am b/newlib/libm/fenv/Makefile.am
new file mode 100644
index 0000000..fef5c36
--- /dev/null
+++ b/newlib/libm/fenv/Makefile.am
@@ -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
diff --git a/newlib/libm/fenv/fe_dfl_env.c b/newlib/libm/fenv/fe_dfl_env.c
new file mode 100644
index 0000000..0606327
--- /dev/null
+++ b/newlib/libm/fenv/fe_dfl_env.c
@@ -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;
diff --git a/newlib/libm/fenv/feclearexcept.c b/newlib/libm/fenv/feclearexcept.c
new file mode 100644
index 0000000..534da63
--- /dev/null
+++ b/newlib/libm/fenv/feclearexcept.c
@@ -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);
+}
diff --git a/newlib/libm/fenv/fegetenv.c b/newlib/libm/fenv/fegetenv.c
new file mode 100644
index 0000000..67ebb3f
--- /dev/null
+++ b/newlib/libm/fenv/fegetenv.c
@@ -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;
+}
diff --git a/newlib/libm/fenv/fegetexceptflag.c b/newlib/libm/fenv/fegetexceptflag.c
new file mode 100644
index 0000000..e0e20b9
--- /dev/null
+++ b/newlib/libm/fenv/fegetexceptflag.c
@@ -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;
+}
diff --git a/newlib/libm/fenv/fegetround.c b/newlib/libm/fenv/fegetround.c
new file mode 100644
index 0000000..1a7c2fd
--- /dev/null
+++ b/newlib/libm/fenv/fegetround.c
@@ -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;
+}
diff --git a/newlib/libm/fenv/feholdexcept.c b/newlib/libm/fenv/feholdexcept.c
new file mode 100644
index 0000000..7d066a7
--- /dev/null
+++ b/newlib/libm/fenv/feholdexcept.c
@@ -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;
+}
diff --git a/newlib/libm/fenv/feraiseexcept.c b/newlib/libm/fenv/feraiseexcept.c
new file mode 100644
index 0000000..c8f4b2e
--- /dev/null
+++ b/newlib/libm/fenv/feraiseexcept.c
@@ -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);
+}
diff --git a/newlib/libm/fenv/fesetenv.c b/newlib/libm/fenv/fesetenv.c
new file mode 100644
index 0000000..410abcc
--- /dev/null
+++ b/newlib/libm/fenv/fesetenv.c
@@ -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;
+}
diff --git a/newlib/libm/fenv/fesetexceptflag.c b/newlib/libm/fenv/fesetexceptflag.c
new file mode 100644
index 0000000..1f35093
--- /dev/null
+++ b/newlib/libm/fenv/fesetexceptflag.c
@@ -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;
+}
diff --git a/newlib/libm/fenv/fesetround.c b/newlib/libm/fenv/fesetround.c
new file mode 100644
index 0000000..d07efe8
--- /dev/null
+++ b/newlib/libm/fenv/fesetround.c
@@ -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;
+}
diff --git a/newlib/libm/fenv/fetestexcept.c b/newlib/libm/fenv/fetestexcept.c
new file mode 100644
index 0000000..d81fb3f
--- /dev/null
+++ b/newlib/libm/fenv/fetestexcept.c
@@ -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;
+}
diff --git a/newlib/libm/fenv/feupdateenv.c b/newlib/libm/fenv/feupdateenv.c
new file mode 100644
index 0000000..e1dd965
--- /dev/null
+++ b/newlib/libm/fenv/feupdateenv.c
@@ -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;
+}