arrfab / rpms / glibc

Forked from rpms/glibc 4 years ago
Clone

Blame SOURCES/glibc-rh1302086-3.patch

147e83
commit bc93ab2946efe008bb0ce2d4d3c212bd01384fca
147e83
Author: Ian Bolton <ian.bolton@arm.com>
147e83
Date:   Wed Apr 16 23:41:04 2014 +0100
147e83
147e83
    [AArch64] Define HAVE_RM_CTX and related hooks.
147e83
147e83
diff --git a/ports/sysdeps/aarch64/fpu/math_private.h b/ports/sysdeps/aarch64/fpu/math_private.h
147e83
index dbf203d..7424952 100644
147e83
--- a/ports/sysdeps/aarch64/fpu/math_private.h
147e83
+++ b/ports/sysdeps/aarch64/fpu/math_private.h
147e83
@@ -209,6 +209,61 @@ libc_feresetround_aarch64 (fenv_t *envp)
147e83
 #define libc_feresetroundf libc_feresetround_aarch64
147e83
 #define libc_feresetroundl libc_feresetround_aarch64
147e83
 
147e83
+/* We have support for rounding mode context.  */
147e83
+#define HAVE_RM_CTX 1
147e83
+
147e83
+static __always_inline void
147e83
+libc_feholdsetround_aarch64_ctx (struct rm_ctx *ctx, int r)
147e83
+{
147e83
+  fpu_control_t fpcr, fpsr, round;
147e83
+
147e83
+  _FPU_GETCW (fpcr);
147e83
+  _FPU_GETFPSR (fpsr);
147e83
+  ctx->env.__fpsr = fpsr;
147e83
+
147e83
+  /* Check whether rounding modes are different.  */
147e83
+  round = (fpcr ^ r) & FE_TOWARDZERO;
147e83
+  ctx->updated_status = round != 0;
147e83
+
147e83
+  /* Set the rounding mode if changed.  */
147e83
+  if (__glibc_unlikely (round != 0))
147e83
+    {
147e83
+      ctx->env.__fpcr = fpcr;
147e83
+      _FPU_SETCW (fpcr ^ round);
147e83
+    }
147e83
+}
147e83
+
147e83
+#define libc_feholdsetround_ctx		libc_feholdsetround_aarch64_ctx
147e83
+#define libc_feholdsetroundf_ctx	libc_feholdsetround_aarch64_ctx
147e83
+#define libc_feholdsetroundl_ctx	libc_feholdsetround_aarch64_ctx
147e83
+
147e83
+static __always_inline void
147e83
+libc_feresetround_aarch64_ctx (struct rm_ctx *ctx)
147e83
+{
147e83
+  /* Restore the rounding mode if updated.  */
147e83
+  if (__glibc_unlikely (ctx->updated_status))
147e83
+    _FPU_SETCW (ctx->env.__fpcr);
147e83
+}
147e83
+
147e83
+#define libc_feresetround_ctx		libc_feresetround_aarch64_ctx
147e83
+#define libc_feresetroundf_ctx		libc_feresetround_aarch64_ctx
147e83
+#define libc_feresetroundl_ctx		libc_feresetround_aarch64_ctx
147e83
+
147e83
+static __always_inline void
147e83
+libc_feresetround_noex_aarch64_ctx (struct rm_ctx *ctx)
147e83
+{
147e83
+  /* Restore the rounding mode if updated.  */
147e83
+  if (__glibc_unlikely (ctx->updated_status))
147e83
+    _FPU_SETCW (ctx->env.__fpcr);
147e83
+
147e83
+  /* Write new FPSR to restore exception flags.  */
147e83
+  _FPU_SETFPSR (ctx->env.__fpsr);
147e83
+}
147e83
+
147e83
+#define libc_feresetround_noex_ctx	libc_feresetround_noex_aarch64_ctx
147e83
+#define libc_feresetround_noexf_ctx	libc_feresetround_noex_aarch64_ctx
147e83
+#define libc_feresetround_noexl_ctx	libc_feresetround_noex_aarch64_ctx
147e83
+
147e83
 #include_next <math_private.h>
147e83
 
147e83
 #endif