#ifdef __SOFTFP__
-#include <ieeefp.h>
-#include <sys/signal.h>
-#include <sys/siginfo.h>
-#else
-#include <arm/armreg.h>
+#error This fenv implementation is only for hardfloat.
#endif
+#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
+
/*
* The following constant represents the default floating-point environment
* (that is, the one installed at program startup) and has type pointer to
@@ -50,7 +69,7 @@ __RCSID("$NetBSD: fenv.c,v 1.1 2014/09/1
* that manage the floating-point environment, namely fesetenv() and
* feupdateenv().
*/
-fenv_t __fe_dfl_env = __SHIFTIN(FCSR_FRM_RNE, FCSR_FRM);
+const fenv_t __fe_dfl_env = __SHIFTIN(FCSR_FRM_RNE, FCSR_FRM);
+#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
+
/* Load x87 Control Word */
#define __fldcw(__cw) __asm__ __volatile__ \
("fldcw %0" : : "m" (__cw))
Index: src/lib/libm/softfloat/feclearexcept.c
===================================================================
RCS file: src/lib/libm/softfloat/feclearexcept.c
diff -N src/lib/libm/softfloat/feclearexcept.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/feclearexcept.c 17 Mar 2017 15:51:15 -0000
@@ -0,0 +1,51 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(feclearexcept,_feclearexcept)
+#endif
+
+int
+feclearexcept(int excepts)
+{
+ fp_except flags = __FPE(excepts);
+
+ fpsetsticky(fpgetsticky() & ~flags);
+ return 0;
+}
Index: src/lib/libm/softfloat/fedisableexcept.c
===================================================================
RCS file: src/lib/libm/softfloat/fedisableexcept.c
diff -N src/lib/libm/softfloat/fedisableexcept.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/fedisableexcept.c 11 Mar 2017 14:50:37 -0000
@@ -0,0 +1,52 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(fedisableexcept,_fedisableexcept)
+#endif
+
+int
+fedisableexcept(int excepts)
+{
+ fp_except omask;
+
+ omask = fpgetmask();
+ fpsetmask(omask & ~__FPE(excepts));
+ return __FEE(omask);
+}
Index: src/lib/libm/softfloat/feenableexcept.c
===================================================================
RCS file: src/lib/libm/softfloat/feenableexcept.c
diff -N src/lib/libm/softfloat/feenableexcept.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/feenableexcept.c 11 Mar 2017 14:50:18 -0000
@@ -0,0 +1,52 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(feenableexcept,_feenableexcept)
+#endif
+
+int
+feenableexcept(int excepts)
+{
+ fp_except omask;
+
+ omask = fpgetmask();
+ fpsetmask(omask | __FPE(excepts));
+ return __FEE(omask);
+}
Index: src/lib/libm/softfloat/fegetenv.c
===================================================================
RCS file: src/lib/libm/softfloat/fegetenv.c
diff -N src/lib/libm/softfloat/fegetenv.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/fegetenv.c 11 Mar 2017 14:41:18 -0000
@@ -0,0 +1,52 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(fegetenv,_fegetenv)
+#endif
+
+int
+fegetenv(fenv_t *envp)
+{
+
+ __FENV_SET_FLAGS(envp, fpgetsticky());
+ __FENV_SET_MASK(envp, fpgetmask());
+ __FENV_SET_ROUND(envp, fpgetround());
+ return 0;
+}
Index: src/lib/libm/softfloat/fegetexcept.c
===================================================================
RCS file: src/lib/libm/softfloat/fegetexcept.c
diff -N src/lib/libm/softfloat/fegetexcept.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/fegetexcept.c 11 Mar 2017 14:57:32 -0000
@@ -0,0 +1,49 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(fegetexcept,_fegetexcept)
+#endif
+
+int
+fegetexcept(void)
+{
+
+ return __FEE(fpgetmask());
+}
Index: src/lib/libm/softfloat/fegetexceptflag.c
===================================================================
RCS file: src/lib/libm/softfloat/fegetexceptflag.c
diff -N src/lib/libm/softfloat/fegetexceptflag.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/fegetexceptflag.c 11 Mar 2017 14:52:18 -0000
@@ -0,0 +1,50 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(fegetexceptflag,_fegetexceptflag)
+#endif
+
+int
+fegetexceptflag(fexcept_t *flagp, int excepts)
+{
+
+ *flagp = __FEE(fpgetsticky()) & excepts;
+ return 0;
+}
Index: src/lib/libm/softfloat/fegetround.c
===================================================================
RCS file: src/lib/libm/softfloat/fegetround.c
diff -N src/lib/libm/softfloat/fegetround.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/fegetround.c 11 Mar 2017 14:41:53 -0000
@@ -0,0 +1,49 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(fegetround,_fegetround)
+#endif
+
+int
+fegetround(void)
+{
+
+ return __FER(fpgetround());
+}
Index: src/lib/libm/softfloat/feholdexcept.c
===================================================================
RCS file: src/lib/libm/softfloat/feholdexcept.c
diff -N src/lib/libm/softfloat/feholdexcept.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/feholdexcept.c 11 Mar 2017 14:43:23 -0000
@@ -0,0 +1,54 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(feholdexcept,_feholdexcept)
+#endif
+
+int
+feholdexcept(fenv_t *envp)
+{
+
+ __FENV_SET_FLAGS(envp, fpgetsticky());
+ __FENV_SET_MASK(envp, fpgetmask());
+ __FENV_SET_ROUND(envp, fpgetround());
+ fpsetsticky(0);
+ fpsetmask(0);
+ return 0;
+}
Index: src/lib/libm/softfloat/feraiseexcept.c
===================================================================
RCS file: src/lib/libm/softfloat/feraiseexcept.c
diff -N src/lib/libm/softfloat/feraiseexcept.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/feraiseexcept.c 12 Mar 2017 19:05:08 -0000
@@ -0,0 +1,74 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+#include <signal.h>
+#include <string.h>
+#include <unistd.h>
+
+#ifdef __weak_alias
+__weak_alias(feraiseexcept,_feraiseexcept)
+#endif
+
+#include <stdio.h>
+
+int
+feraiseexcept(int excepts)
+{
+
+ fpsetsticky(fpgetsticky() | __FPE(excepts));
+ excepts &= __FEE(fpgetmask());
+ 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)
+ info.si_code = FPE_FLTUND;
+ else if (excepts & FE_OVERFLOW)
+ info.si_code = FPE_FLTOVF;
+ else if (excepts & FE_DIVBYZERO)
+ info.si_code = FPE_FLTDIV;
+ else if (excepts & FE_INVALID)
+ info.si_code = FPE_FLTINV;
+ else if (excepts & FE_INEXACT)
+ info.si_code = FPE_FLTRES;
+ sigqueueinfo(getpid(), &info);
+ }
+ return 0;
+}
Index: src/lib/libm/softfloat/fesetenv.c
===================================================================
RCS file: src/lib/libm/softfloat/fesetenv.c
diff -N src/lib/libm/softfloat/fesetenv.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/fesetenv.c 11 Mar 2017 14:44:36 -0000
@@ -0,0 +1,52 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(fesetenv,_fesetenv)
+#endif
+
+int
+fesetenv(const fenv_t *envp)
+{
+
+ fpsetsticky(__FENV_GET_FLAGS(envp));
+ fpsetmask(__FENV_GET_MASK(envp));
+ fpsetround(__FENV_GET_ROUND(envp));
+ return 0;
+}
Index: src/lib/libm/softfloat/fesetexceptflag.c
===================================================================
RCS file: src/lib/libm/softfloat/fesetexceptflag.c
diff -N src/lib/libm/softfloat/fesetexceptflag.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/fesetexceptflag.c 17 Mar 2017 15:58:05 -0000
@@ -0,0 +1,51 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(fesetexceptflag,_fesetexceptflag)
+#endif
+
+int
+fesetexceptflag(const fexcept_t *flagp, int excepts)
+{
+ int mask = __FPE(excepts);
+
+ fpsetsticky((fpgetsticky() & ~mask) | (__FPE(*flagp) & mask));
+ return 0;
+}
Index: src/lib/libm/softfloat/fesetround.c
===================================================================
RCS file: src/lib/libm/softfloat/fesetround.c
diff -N src/lib/libm/softfloat/fesetround.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/fesetround.c 11 Mar 2017 14:54:40 -0000
@@ -0,0 +1,50 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(fesetround,_fesetround)
+#endif
+
+int
+fesetround(int round)
+{
+
+ fpsetround(__FPR(round));
+ return 0;
+}
Index: src/lib/libm/softfloat/fetestexcept.c
===================================================================
RCS file: src/lib/libm/softfloat/fetestexcept.c
diff -N src/lib/libm/softfloat/fetestexcept.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/fetestexcept.c 11 Mar 2017 14:55:05 -0000
@@ -0,0 +1,54 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+#ifdef SOFTFLOAT_FOR_GCC
+#include "softfloat-for-gcc.h"
+#endif
+#include "milieu.h"
+#include "softfloat.h"
+
+#ifdef __weak_alias
+__weak_alias(fetestexcept,_fetestexcept)
+#endif
+
+int
+fetestexcept(int excepts)
+{
+
+ return __FEE(fpgetsticky()) & excepts;
+}
Index: src/lib/libm/softfloat/feupdateenv.c
===================================================================
RCS file: src/lib/libm/softfloat/feupdateenv.c
diff -N src/lib/libm/softfloat/feupdateenv.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/lib/libm/softfloat/feupdateenv.c 11 Mar 2017 14:41:27 -0000
@@ -0,0 +1,57 @@
+/* $NetBSD$ */
+
+/*-
+ * Copyright (c) 2017 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Chuck Silvers.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
+__RCSID("$NetBSD$");
+
+#include "namespace.h"
+
+#include <fenv.h>
+#include <ieeefp.h>
+
+#ifdef __weak_alias
+__weak_alias(feupdateenv,_feupdateenv)
+#endif
+
+int
+feupdateenv(const fenv_t *envp)
+{
+ fexcept_t oflag;
+
+ fegetexceptflag(&oflag, FE_ALL_EXCEPT);
+
+ fpsetround(__FENV_GET_ROUND(envp));
+ fpsetmask(__FENV_GET_MASK(envp));
+ fpsetsticky(__FENV_GET_MASK(envp));
+
+ feraiseexcept(oflag);
+ return 0;
+}
Index: src/lib/libm/src/namespace.h
===================================================================
RCS file: /home/chs/netbsd/cvs/src/lib/libm/src/namespace.h,v
retrieving revision 1.13
diff -u -p -r1.13 namespace.h
--- src/lib/libm/src/namespace.h 14 Nov 2014 14:53:17 -0000 1.13
+++ src/lib/libm/src/namespace.h 16 Mar 2017 11:19:33 -0000
@@ -73,3 +73,18 @@
-/* We currently provide no external definitions of the functions below. */
-
-static inline int
+__fenv_static inline int
feenableexcept(int __mask)
{
fexcept_t __fpcr, __oldmask;
@@ -276,7 +274,7 @@ feenableexcept(int __mask)
return __oldmask;
}
-/* We currently provide no external definitions of the functions below. */
-
-static inline int
+__fenv_static inline int
feenableexcept(int __excepts)
{
fenv_t __old_fpsr, __new_fpsr;
@@ -215,7 +216,7 @@ feenableexcept(int __excepts)
return __old_fpsr;
}
-/* We currently provide no external definitions of the functions below. */
-
-static inline int
+__fenv_static inline int
feenableexcept(int __mask)
{
union __fpscr __r;
@@ -289,7 +289,7 @@ feenableexcept(int __mask)
return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
}
-static inline int
+__fenv_static inline int
fedisableexcept(int __mask)
{
union __fpscr __r;
@@ -303,7 +303,7 @@ fedisableexcept(int __mask)
return ((__oldmask & _ENABLE_MASK) << _FPUSW_SHIFT);
}
-static inline int
+__fenv_static inline int
fegetexcept(void)
{
union __fpscr __r;
@@ -315,6 +315,8 @@ fegetexcept(void)
#endif /* _NETBSD_SOURCE || _GNU_SOURCE */