|
|
7c0489 |
From 2ab6ce8252a14e6ef0cfb33046dd565ae15085c2 Mon Sep 17 00:00:00 2001
|
|
|
7c0489 |
From: Stefan Liebler <stli@linux.ibm.com>
|
|
|
7c0489 |
Date: Wed, 11 Dec 2019 15:09:32 +0100
|
|
|
7c0489 |
Subject: [PATCH 28/28] S390: Use libc_fe* macros in fe* functions.
|
|
|
7c0489 |
|
|
|
7c0489 |
This patch updates the s390 specific functions fegetround,
|
|
|
7c0489 |
fesetround, feholdexcept, fesetenv, feupdateenv, fegetexceptflag,
|
|
|
7c0489 |
fetestexcept, fesetexceptflag, fetestexceptflag.
|
|
|
7c0489 |
Now those functions are using the libc_fe* macros if possible.
|
|
|
7c0489 |
|
|
|
7c0489 |
Furthermore fegetexceptflag is now returning the exception from
|
|
|
7c0489 |
dxc field shifted to the usual exception-flags.
|
|
|
7c0489 |
Thus a special fetestexceptflag implementation is not needed anymore.
|
|
|
7c0489 |
|
|
|
7c0489 |
(cherry picked from commit 238adf59db85646ebae47876819bd896dae597bc)
|
|
|
7c0489 |
---
|
|
|
7c0489 |
sysdeps/s390/fpu/fegetround.c | 9 ++-------
|
|
|
7c0489 |
sysdeps/s390/fpu/feholdexcpt.c | 12 ++---------
|
|
|
7c0489 |
sysdeps/s390/fpu/fesetenv.c | 21 +++----------------
|
|
|
7c0489 |
sysdeps/s390/fpu/fesetround.c | 9 +++------
|
|
|
7c0489 |
sysdeps/s390/fpu/fetestexceptflag.c | 31 -----------------------------
|
|
|
7c0489 |
sysdeps/s390/fpu/feupdateenv.c | 14 +++----------
|
|
|
7c0489 |
sysdeps/s390/fpu/fgetexcptflg.c | 16 ++-------------
|
|
|
7c0489 |
sysdeps/s390/fpu/fsetexcptflg.c | 23 ++++++++++-----------
|
|
|
7c0489 |
sysdeps/s390/fpu/ftestexcept.c | 16 ++-------------
|
|
|
7c0489 |
9 files changed, 27 insertions(+), 124 deletions(-)
|
|
|
7c0489 |
delete mode 100644 sysdeps/s390/fpu/fetestexceptflag.c
|
|
|
7c0489 |
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/fegetround.c b/sysdeps/s390/fpu/fegetround.c
|
|
|
7c0489 |
index 3c38bc9189..f1be1d12e1 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/fegetround.c
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/fegetround.c
|
|
|
7c0489 |
@@ -17,17 +17,12 @@
|
|
|
7c0489 |
License along with the GNU C Library; if not, see
|
|
|
7c0489 |
<http://www.gnu.org/licenses/>. */
|
|
|
7c0489 |
|
|
|
7c0489 |
-#include <fenv_libc.h>
|
|
|
7c0489 |
-#include <fpu_control.h>
|
|
|
7c0489 |
+#include <get-rounding-mode.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
int
|
|
|
7c0489 |
__fegetround (void)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- fexcept_t cw;
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- _FPU_GETCW (cw);
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- return cw & FPC_RM_MASK;
|
|
|
7c0489 |
+ return get_rounding_mode ();
|
|
|
7c0489 |
}
|
|
|
7c0489 |
libm_hidden_def (__fegetround)
|
|
|
7c0489 |
weak_alias (__fegetround, fegetround)
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/feholdexcpt.c b/sysdeps/s390/fpu/feholdexcpt.c
|
|
|
7c0489 |
index 5daee5675d..48af7ff51b 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/feholdexcpt.c
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/feholdexcpt.c
|
|
|
7c0489 |
@@ -17,19 +17,11 @@
|
|
|
7c0489 |
License along with the GNU C Library; if not, see
|
|
|
7c0489 |
<http://www.gnu.org/licenses/>. */
|
|
|
7c0489 |
|
|
|
7c0489 |
-#include <fenv_libc.h>
|
|
|
7c0489 |
-#include <fpu_control.h>
|
|
|
7c0489 |
+#include <fenv_private.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
int __feholdexcept (fenv_t *envp)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- fexcept_t fpc;
|
|
|
7c0489 |
- /* Store the environment. */
|
|
|
7c0489 |
- __fegetenv (envp);
|
|
|
7c0489 |
- /* Clear the current sticky bits as more than one exception
|
|
|
7c0489 |
- may be generated. */
|
|
|
7c0489 |
- fpc = envp->__fpc & ~(FPC_FLAGS_MASK | FPC_DXC_MASK);
|
|
|
7c0489 |
- /* Hold from generating fpu exceptions temporarily. */
|
|
|
7c0489 |
- _FPU_SETCW ((fpc & ~(FE_ALL_EXCEPT << FPC_EXCEPTION_MASK_SHIFT)));
|
|
|
7c0489 |
+ libc_feholdexcept_s390 (envp);
|
|
|
7c0489 |
return 0;
|
|
|
7c0489 |
}
|
|
|
7c0489 |
libm_hidden_def (__feholdexcept)
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/fesetenv.c b/sysdeps/s390/fpu/fesetenv.c
|
|
|
7c0489 |
index c6c275d79d..54ba2aa94a 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/fesetenv.c
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/fesetenv.c
|
|
|
7c0489 |
@@ -17,28 +17,13 @@
|
|
|
7c0489 |
License along with the GNU C Library; if not, see
|
|
|
7c0489 |
<http://www.gnu.org/licenses/>. */
|
|
|
7c0489 |
|
|
|
7c0489 |
-#include <fenv_libc.h>
|
|
|
7c0489 |
-#include <fpu_control.h>
|
|
|
7c0489 |
-#include <stddef.h>
|
|
|
7c0489 |
-#include <unistd.h>
|
|
|
7c0489 |
+#include <fenv_private.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
int
|
|
|
7c0489 |
__fesetenv (const fenv_t *envp)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- fenv_t env;
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- if (envp == FE_DFL_ENV)
|
|
|
7c0489 |
- {
|
|
|
7c0489 |
- env.__fpc = _FPU_DEFAULT;
|
|
|
7c0489 |
- }
|
|
|
7c0489 |
- else if (envp == FE_NOMASK_ENV)
|
|
|
7c0489 |
- {
|
|
|
7c0489 |
- env.__fpc = FPC_EXCEPTION_MASK;
|
|
|
7c0489 |
- }
|
|
|
7c0489 |
- else
|
|
|
7c0489 |
- env = (*envp);
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- _FPU_SETCW (env.__fpc);
|
|
|
7c0489 |
+ fenv_t env = libc_handle_user_fenv_s390 (envp);
|
|
|
7c0489 |
+ libc_fesetenv_s390 (&env;;
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Success. */
|
|
|
7c0489 |
return 0;
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/fesetround.c b/sysdeps/s390/fpu/fesetround.c
|
|
|
7c0489 |
index d8a84d2c96..0a7fe2635b 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/fesetround.c
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/fesetround.c
|
|
|
7c0489 |
@@ -17,21 +17,18 @@
|
|
|
7c0489 |
License along with the GNU C Library; if not, see
|
|
|
7c0489 |
<http://www.gnu.org/licenses/>. */
|
|
|
7c0489 |
|
|
|
7c0489 |
-#include <fenv_libc.h>
|
|
|
7c0489 |
-#include <fpu_control.h>
|
|
|
7c0489 |
+#include <fenv_private.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
int
|
|
|
7c0489 |
__fesetround (int round)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- if ((round|FPC_RM_MASK) != FPC_RM_MASK)
|
|
|
7c0489 |
+ if ((round | FPC_RM_MASK) != FPC_RM_MASK)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
/* ROUND is not a valid rounding mode. */
|
|
|
7c0489 |
return 1;
|
|
|
7c0489 |
}
|
|
|
7c0489 |
- __asm__ __volatile__ ("srnm 0(%0)"
|
|
|
7c0489 |
- :
|
|
|
7c0489 |
- : "a" (round));
|
|
|
7c0489 |
|
|
|
7c0489 |
+ libc_fesetround_s390 (round);
|
|
|
7c0489 |
return 0;
|
|
|
7c0489 |
}
|
|
|
7c0489 |
libm_hidden_def (__fesetround)
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/fetestexceptflag.c b/sysdeps/s390/fpu/fetestexceptflag.c
|
|
|
7c0489 |
deleted file mode 100644
|
|
|
7c0489 |
index 784d356f7b..0000000000
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/fetestexceptflag.c
|
|
|
7c0489 |
+++ /dev/null
|
|
|
7c0489 |
@@ -1,31 +0,0 @@
|
|
|
7c0489 |
-/* Test exception in saved exception state. S/390 version.
|
|
|
7c0489 |
- Copyright (C) 2016-2018 Free Software Foundation, Inc.
|
|
|
7c0489 |
- This file is part of the GNU C Library.
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- The GNU C Library is free software; you can redistribute it and/or
|
|
|
7c0489 |
- modify it under the terms of the GNU Lesser General Public
|
|
|
7c0489 |
- License as published by the Free Software Foundation; either
|
|
|
7c0489 |
- version 2.1 of the License, or (at your option) any later version.
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- The GNU C Library is distributed in the hope that it will be useful,
|
|
|
7c0489 |
- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
7c0489 |
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
7c0489 |
- Lesser General Public License for more details.
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- You should have received a copy of the GNU Lesser General Public
|
|
|
7c0489 |
- License along with the GNU C Library; if not, see
|
|
|
7c0489 |
- <http://www.gnu.org/licenses/>. */
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-#include <fenv.h>
|
|
|
7c0489 |
-#include <fenv_libc.h>
|
|
|
7c0489 |
-
|
|
|
7c0489 |
-int
|
|
|
7c0489 |
-fetestexceptflag (const fexcept_t *flagp, int excepts)
|
|
|
7c0489 |
-{
|
|
|
7c0489 |
- /* As *flagp is obtained by an earlier call of fegetexceptflag the
|
|
|
7c0489 |
- bits 0-5 of dxc-byte are either zero or correspond to the
|
|
|
7c0489 |
- flag-bits. Evaluate flags and last dxc-exception-code. */
|
|
|
7c0489 |
- return (((*flagp >> FPC_FLAGS_SHIFT) | (*flagp >> FPC_DXC_SHIFT))
|
|
|
7c0489 |
- & excepts
|
|
|
7c0489 |
- & FE_ALL_EXCEPT);
|
|
|
7c0489 |
-}
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/feupdateenv.c b/sysdeps/s390/fpu/feupdateenv.c
|
|
|
7c0489 |
index 4888e1a864..f6b3d7d2de 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/feupdateenv.c
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/feupdateenv.c
|
|
|
7c0489 |
@@ -18,21 +18,13 @@
|
|
|
7c0489 |
<http://www.gnu.org/licenses/>. */
|
|
|
7c0489 |
|
|
|
7c0489 |
|
|
|
7c0489 |
-#include <fenv_libc.h>
|
|
|
7c0489 |
-#include <fpu_control.h>
|
|
|
7c0489 |
+#include <fenv_private.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
int
|
|
|
7c0489 |
__feupdateenv (const fenv_t *envp)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- fexcept_t temp;
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- _FPU_GETCW (temp);
|
|
|
7c0489 |
- temp = (temp & FPC_FLAGS_MASK) >> FPC_FLAGS_SHIFT;
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- /* Raise the exceptions since the last call to feholdenv */
|
|
|
7c0489 |
- /* re install saved environment. */
|
|
|
7c0489 |
- __fesetenv (envp);
|
|
|
7c0489 |
- __feraiseexcept ((int) temp);
|
|
|
7c0489 |
+ fenv_t env = libc_handle_user_fenv_s390 (envp);
|
|
|
7c0489 |
+ libc_feupdateenv_s390 (&env;;
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Success. */
|
|
|
7c0489 |
return 0;
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/fgetexcptflg.c b/sysdeps/s390/fpu/fgetexcptflg.c
|
|
|
7c0489 |
index 2a0f6dc77c..1985b396c9 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/fgetexcptflg.c
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/fgetexcptflg.c
|
|
|
7c0489 |
@@ -17,24 +17,12 @@
|
|
|
7c0489 |
License along with the GNU C Library; if not, see
|
|
|
7c0489 |
<http://www.gnu.org/licenses/>. */
|
|
|
7c0489 |
|
|
|
7c0489 |
-#include <fenv_libc.h>
|
|
|
7c0489 |
-#include <fpu_control.h>
|
|
|
7c0489 |
+#include <fenv_private.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
int
|
|
|
7c0489 |
fegetexceptflag (fexcept_t *flagp, int excepts)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- fexcept_t temp, newexcepts;
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- /* Get the current exceptions. */
|
|
|
7c0489 |
- _FPU_GETCW (temp);
|
|
|
7c0489 |
- newexcepts = excepts << FPC_FLAGS_SHIFT;
|
|
|
7c0489 |
- if ((temp & FPC_NOT_FPU_EXCEPTION) == 0)
|
|
|
7c0489 |
- /* Bits 6, 7 of dxc-byte are zero,
|
|
|
7c0489 |
- thus bits 0-5 of dxc-byte correspond to the flag-bits.
|
|
|
7c0489 |
- Evaluate flags and last dxc-exception-code. */
|
|
|
7c0489 |
- newexcepts |= excepts << FPC_DXC_SHIFT;
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- *flagp = temp & newexcepts;
|
|
|
7c0489 |
+ *flagp = libc_fetestexcept_s390 (excepts);
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Success. */
|
|
|
7c0489 |
return 0;
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/fsetexcptflg.c b/sysdeps/s390/fpu/fsetexcptflg.c
|
|
|
7c0489 |
index e50684c574..51d258cf17 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/fsetexcptflg.c
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/fsetexcptflg.c
|
|
|
7c0489 |
@@ -24,29 +24,26 @@
|
|
|
7c0489 |
int
|
|
|
7c0489 |
fesetexceptflag (const fexcept_t *flagp, int excepts)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- fexcept_t temp, newexcepts;
|
|
|
7c0489 |
+ fexcept_t fpc, fpc_new;
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Get the current environment. We have to do this since we cannot
|
|
|
7c0489 |
separately set the status word. */
|
|
|
7c0489 |
- _FPU_GETCW (temp);
|
|
|
7c0489 |
- /* Install the new exception bits in the Accrued Exception Byte. */
|
|
|
7c0489 |
- excepts = excepts & FE_ALL_EXCEPT;
|
|
|
7c0489 |
- newexcepts = excepts << FPC_FLAGS_SHIFT;
|
|
|
7c0489 |
- temp &= ~newexcepts;
|
|
|
7c0489 |
- if ((temp & FPC_NOT_FPU_EXCEPTION) == 0)
|
|
|
7c0489 |
+ _FPU_GETCW (fpc);
|
|
|
7c0489 |
+
|
|
|
7c0489 |
+ /* Clear the current exception bits. */
|
|
|
7c0489 |
+ fpc_new = fpc & ~((excepts & FE_ALL_EXCEPT) << FPC_FLAGS_SHIFT);
|
|
|
7c0489 |
+ if ((fpc & FPC_NOT_FPU_EXCEPTION) == 0)
|
|
|
7c0489 |
/* Bits 6, 7 of dxc-byte are zero,
|
|
|
7c0489 |
thus bits 0-5 of dxc-byte correspond to the flag-bits.
|
|
|
7c0489 |
Clear given exceptions in dxc-field. */
|
|
|
7c0489 |
- temp &= ~(excepts << FPC_DXC_SHIFT);
|
|
|
7c0489 |
+ fpc_new &= ~((excepts & FE_ALL_EXCEPT) << FPC_DXC_SHIFT);
|
|
|
7c0489 |
|
|
|
7c0489 |
- /* Integrate dxc-byte of flagp into flags. The dxc-byte of flagp contains
|
|
|
7c0489 |
- either an ieee-exception or 0 (see fegetexceptflag). */
|
|
|
7c0489 |
- temp |= (*flagp | ((*flagp >> FPC_DXC_SHIFT) << FPC_FLAGS_SHIFT))
|
|
|
7c0489 |
- & newexcepts;
|
|
|
7c0489 |
+ /* Set exceptions from flagp in flags-field. */
|
|
|
7c0489 |
+ fpc_new |= (*flagp & excepts & FE_ALL_EXCEPT) << FPC_FLAGS_SHIFT;
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Store the new status word (along with the rest of the environment.
|
|
|
7c0489 |
Possibly new exceptions are set but they won't get executed. */
|
|
|
7c0489 |
- _FPU_SETCW (temp);
|
|
|
7c0489 |
+ _FPU_SETCW (fpc_new);
|
|
|
7c0489 |
|
|
|
7c0489 |
/* Success. */
|
|
|
7c0489 |
return 0;
|
|
|
7c0489 |
diff --git a/sysdeps/s390/fpu/ftestexcept.c b/sysdeps/s390/fpu/ftestexcept.c
|
|
|
7c0489 |
index 727b9b342d..f2acecc1af 100644
|
|
|
7c0489 |
--- a/sysdeps/s390/fpu/ftestexcept.c
|
|
|
7c0489 |
+++ b/sysdeps/s390/fpu/ftestexcept.c
|
|
|
7c0489 |
@@ -17,23 +17,11 @@
|
|
|
7c0489 |
License along with the GNU C Library; if not, see
|
|
|
7c0489 |
<http://www.gnu.org/licenses/>. */
|
|
|
7c0489 |
|
|
|
7c0489 |
-#include <fenv_libc.h>
|
|
|
7c0489 |
-#include <fpu_control.h>
|
|
|
7c0489 |
+#include <fenv_private.h>
|
|
|
7c0489 |
|
|
|
7c0489 |
int
|
|
|
7c0489 |
fetestexcept (int excepts)
|
|
|
7c0489 |
{
|
|
|
7c0489 |
- fexcept_t temp, res;
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- /* Get current exceptions. */
|
|
|
7c0489 |
- _FPU_GETCW (temp);
|
|
|
7c0489 |
- res = temp >> FPC_FLAGS_SHIFT;
|
|
|
7c0489 |
- if ((temp & FPC_NOT_FPU_EXCEPTION) == 0)
|
|
|
7c0489 |
- /* Bits 6, 7 of dxc-byte are zero,
|
|
|
7c0489 |
- thus bits 0-5 of dxc-byte correspond to the flag-bits.
|
|
|
7c0489 |
- Evaluate flags and last dxc-exception-code. */
|
|
|
7c0489 |
- res |= temp >> FPC_DXC_SHIFT;
|
|
|
7c0489 |
-
|
|
|
7c0489 |
- return res & excepts & FE_ALL_EXCEPT;
|
|
|
7c0489 |
+ return libc_fetestexcept_s390 (excepts);
|
|
|
7c0489 |
}
|
|
|
7c0489 |
libm_hidden_def (fetestexcept)
|
|
|
7c0489 |
--
|
|
|
7c0489 |
2.18.2
|
|
|
7c0489 |
|