Blame SOURCES/glibc-rh1302086-2.patch

147e83
commit 7e0b6763e96ef9706ea9ecc7fad83fc97b837913
147e83
Author: Ian Bolton <ian.bolton@arm.com>
147e83
Date:   Wed Apr 16 14:41:52 2014 +0000
147e83
147e83
    [AArch64] Provide initial implementation of math_private.h.
147e83
147e83
diff --git a/ports/sysdeps/aarch64/fpu/math_private.h b/ports/sysdeps/aarch64/fpu/math_private.h
147e83
new file mode 100644
147e83
index 0000000..dbf203d
147e83
--- /dev/null
147e83
+++ b/ports/sysdeps/aarch64/fpu/math_private.h
147e83
@@ -0,0 +1,214 @@
147e83
+/* Private floating point rounding and exceptions handling.  AArch64 version.
147e83
+   Copyright (C) 2014 Free Software Foundation, Inc.
147e83
+   This file is part of the GNU C Library.
147e83
+
147e83
+   The GNU C Library is free software; you can redistribute it and/or
147e83
+   modify it under the terms of the GNU Lesser General Public
147e83
+   License as published by the Free Software Foundation; either
147e83
+   version 2.1 of the License, or (at your option) any later version.
147e83
+
147e83
+   The GNU C Library is distributed in the hope that it will be useful,
147e83
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
147e83
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
147e83
+   Lesser General Public License for more details.
147e83
+
147e83
+   You should have received a copy of the GNU Lesser General Public
147e83
+   License along with the GNU C Library; if not, see
147e83
+   <http://www.gnu.org/licenses/>.  */
147e83
+
147e83
+#ifndef AARCH64_MATH_PRIVATE_H
147e83
+#define AARCH64_MATH_PRIVATE_H 1
147e83
+
147e83
+#include <fenv.h>
147e83
+#include <fpu_control.h>
147e83
+
147e83
+static __always_inline void
147e83
+libc_feholdexcept_aarch64 (fenv_t *envp)
147e83
+{
147e83
+  fpu_control_t fpcr, new_fpcr, fpsr, new_fpsr;
147e83
+
147e83
+  _FPU_GETCW (fpcr);
147e83
+  _FPU_GETFPSR (fpsr);
147e83
+  envp->__fpcr = fpcr;
147e83
+  envp->__fpsr = fpsr;
147e83
+
147e83
+  /* Clear exception flags and set all exceptions to non-stop.  */
147e83
+  new_fpcr = fpcr & ~(FE_ALL_EXCEPT << FE_EXCEPT_SHIFT);
147e83
+  new_fpsr = fpsr & ~FE_ALL_EXCEPT;
147e83
+
147e83
+  if (__glibc_unlikely (new_fpcr != fpcr))
147e83
+    _FPU_SETCW (new_fpcr);
147e83
+
147e83
+  if (new_fpsr != fpsr)
147e83
+    _FPU_SETFPSR (new_fpsr);
147e83
+}
147e83
+
147e83
+#define libc_feholdexcept  libc_feholdexcept_aarch64
147e83
+#define libc_feholdexceptf libc_feholdexcept_aarch64
147e83
+#define libc_feholdexceptl libc_feholdexcept_aarch64
147e83
+
147e83
+static __always_inline void
147e83
+libc_fesetround_aarch64 (int round)
147e83
+{
147e83
+  fpu_control_t fpcr;
147e83
+
147e83
+  _FPU_GETCW (fpcr);
147e83
+
147e83
+  /* Check whether rounding modes are different.  */
147e83
+  round = (fpcr ^ round) & FE_TOWARDZERO;
147e83
+
147e83
+  /* Set new rounding mode if different.  */
147e83
+  if (__glibc_unlikely (round != 0))
147e83
+    _FPU_SETCW (fpcr ^ round);
147e83
+}
147e83
+
147e83
+#define libc_fesetround  libc_fesetround_aarch64
147e83
+#define libc_fesetroundf libc_fesetround_aarch64
147e83
+#define libc_fesetroundl libc_fesetround_aarch64
147e83
+
147e83
+static __always_inline void
147e83
+libc_feholdexcept_setround_aarch64 (fenv_t *envp, int round)
147e83
+{
147e83
+  fpu_control_t fpcr, new_fpcr, fpsr, new_fpsr;
147e83
+
147e83
+  _FPU_GETCW (fpcr);
147e83
+  _FPU_GETFPSR (fpsr);
147e83
+  envp->__fpcr = fpcr;
147e83
+  envp->__fpsr = fpsr;
147e83
+
147e83
+  /* Clear exception flags, set all exceptions to non-stop,
147e83
+     and set new rounding mode.  */
147e83
+  new_fpcr = fpcr & ~((FE_ALL_EXCEPT << FE_EXCEPT_SHIFT) | FE_TOWARDZERO);
147e83
+  new_fpcr |= round;
147e83
+  new_fpsr = fpsr & ~FE_ALL_EXCEPT;
147e83
+
147e83
+  if (__glibc_unlikely (new_fpcr != fpcr))
147e83
+    _FPU_SETCW (new_fpcr);
147e83
+
147e83
+  if (new_fpsr != fpsr)
147e83
+    _FPU_SETFPSR (new_fpsr);
147e83
+}
147e83
+
147e83
+#define libc_feholdexcept_setround  libc_feholdexcept_setround_aarch64
147e83
+#define libc_feholdexcept_setroundf libc_feholdexcept_setround_aarch64
147e83
+#define libc_feholdexcept_setroundl libc_feholdexcept_setround_aarch64
147e83
+
147e83
+static __always_inline int
147e83
+libc_fetestexcept_aarch64 (int ex)
147e83
+{
147e83
+  fpu_control_t fpsr;
147e83
+
147e83
+  _FPU_GETFPSR (fpsr);
147e83
+  return fpsr & ex & FE_ALL_EXCEPT;
147e83
+}
147e83
+
147e83
+#define libc_fetestexcept  libc_fetestexcept_aarch64
147e83
+#define libc_fetestexceptf libc_fetestexcept_aarch64
147e83
+#define libc_fetestexceptl libc_fetestexcept_aarch64
147e83
+
147e83
+static __always_inline void
147e83
+libc_fesetenv_aarch64 (const fenv_t *envp)
147e83
+{
147e83
+  fpu_control_t fpcr, new_fpcr;
147e83
+
147e83
+  _FPU_GETCW (fpcr);
147e83
+  new_fpcr = envp->__fpcr;
147e83
+
147e83
+  if (__glibc_unlikely (fpcr != new_fpcr))
147e83
+    _FPU_SETCW (new_fpcr);
147e83
+
147e83
+  _FPU_SETFPSR (envp->__fpsr);
147e83
+}
147e83
+
147e83
+#define libc_fesetenv  libc_fesetenv_aarch64
147e83
+#define libc_fesetenvf libc_fesetenv_aarch64
147e83
+#define libc_fesetenvl libc_fesetenv_aarch64
147e83
+#define libc_feresetround_noex  libc_fesetenv_aarch64
147e83
+#define libc_feresetround_noexf libc_fesetenv_aarch64
147e83
+#define libc_feresetround_noexl libc_fesetenv_aarch64
147e83
+
147e83
+static __always_inline int
147e83
+libc_feupdateenv_test_aarch64 (const fenv_t *envp, int ex)
147e83
+{
147e83
+  fpu_control_t fpcr, new_fpcr, fpsr, new_fpsr;
147e83
+  int excepts;
147e83
+
147e83
+  _FPU_GETCW (fpcr);
147e83
+  _FPU_GETFPSR (fpsr);
147e83
+
147e83
+  /* Merge current exception flags with the saved fenv.  */
147e83
+  excepts = fpsr & FE_ALL_EXCEPT;
147e83
+  new_fpcr = envp->__fpcr;
147e83
+  new_fpsr = envp->__fpsr | excepts;
147e83
+
147e83
+  if (__glibc_unlikely (fpcr != new_fpcr))
147e83
+    _FPU_SETCW (new_fpcr);
147e83
+
147e83
+  if (fpsr != new_fpsr)
147e83
+    _FPU_SETFPSR (new_fpsr);
147e83
+
147e83
+  /* Raise the exceptions if enabled in the new FP state.  */
147e83
+  if (__glibc_unlikely (excepts & (new_fpcr >> FE_EXCEPT_SHIFT)))
147e83
+    feraiseexcept (excepts);
147e83
+
147e83
+  return excepts & ex;
147e83
+}
147e83
+
147e83
+#define libc_feupdateenv_test  libc_feupdateenv_test_aarch64
147e83
+#define libc_feupdateenv_testf libc_feupdateenv_test_aarch64
147e83
+#define libc_feupdateenv_testl libc_feupdateenv_test_aarch64
147e83
+
147e83
+static __always_inline void
147e83
+libc_feupdateenv_aarch64 (const fenv_t *envp)
147e83
+{
147e83
+  libc_feupdateenv_test_aarch64 (envp, 0);
147e83
+}
147e83
+
147e83
+#define libc_feupdateenv  libc_feupdateenv_aarch64
147e83
+#define libc_feupdateenvf libc_feupdateenv_aarch64
147e83
+#define libc_feupdateenvl libc_feupdateenv_aarch64
147e83
+
147e83
+static __always_inline void
147e83
+libc_feholdsetround_aarch64 (fenv_t *envp, int round)
147e83
+{
147e83
+  fpu_control_t fpcr, fpsr;
147e83
+
147e83
+  _FPU_GETCW (fpcr);
147e83
+  _FPU_GETFPSR (fpsr);
147e83
+  envp->__fpcr = fpcr;
147e83
+  envp->__fpsr = fpsr;
147e83
+
147e83
+  /* Check whether rounding modes are different.  */
147e83
+  round = (fpcr ^ round) & FE_TOWARDZERO;
147e83
+
147e83
+  /* Set new rounding mode if different.  */
147e83
+  if (__glibc_unlikely (round != 0))
147e83
+    _FPU_SETCW (fpcr ^ round);
147e83
+}
147e83
+
147e83
+#define libc_feholdsetround  libc_feholdsetround_aarch64
147e83
+#define libc_feholdsetroundf libc_feholdsetround_aarch64
147e83
+#define libc_feholdsetroundl libc_feholdsetround_aarch64
147e83
+
147e83
+static __always_inline void
147e83
+libc_feresetround_aarch64 (fenv_t *envp)
147e83
+{
147e83
+  fpu_control_t fpcr, round;
147e83
+
147e83
+  _FPU_GETCW (fpcr);
147e83
+
147e83
+  /* Check whether rounding modes are different.  */
147e83
+  round = (envp->__fpcr ^ fpcr) & FE_TOWARDZERO;
147e83
+
147e83
+  /* Restore the rounding mode if it was changed.  */
147e83
+  if (__glibc_unlikely (round != 0))
147e83
+    _FPU_SETCW (fpcr ^ round);
147e83
+}
147e83
+
147e83
+#define libc_feresetround  libc_feresetround_aarch64
147e83
+#define libc_feresetroundf libc_feresetround_aarch64
147e83
+#define libc_feresetroundl libc_feresetround_aarch64
147e83
+
147e83
+#include_next <math_private.h>
147e83
+
147e83
+#endif