5de29b
From e7197c1f8c4c30734723059c97b6e7a8f58fb171 Mon Sep 17 00:00:00 2001
5de29b
From: Rajalakshmi Srinivasaraghavan <raji@linux.vnet.ibm.com>
5de29b
Date: Wed, 30 Jul 2014 11:33:51 -0500
5de29b
Subject: [PATCH] PowerPC: multiarch finite/finitef for PowerPC64
5de29b
5de29b
commit 1481d7066c4ce697ada1f33c8c7f97b46ef685e3
5de29b
Author: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
5de29b
Date:   Fri Dec 13 15:34:52 2013 -0500
5de29b
5de29b
Modified the following files apart from the original commit.
5de29b
sysdeps/ieee754/dbl-64/s_finite.c
5de29b
sysdeps/ieee754/flt-32/s_finitef.c
5de29b
---
5de29b
 sysdeps/ieee754/dbl-64/s_finite.c                  | 13 ++++--
5de29b
 sysdeps/ieee754/flt-32/s_finitef.c                 |  7 ++-
5de29b
 sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile   |  6 ++-
5de29b
 .../powerpc64/fpu/multiarch/s_finite-power7.S      | 33 ++++++++++++++
5de29b
 .../powerpc64/fpu/multiarch/s_finite-ppc64.c       | 34 +++++++++++++++
5de29b
 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c | 51 ++++++++++++++++++++++
5de29b
 .../powerpc64/fpu/multiarch/s_finitef-ppc64.c      | 32 ++++++++++++++
5de29b
 .../powerpc/powerpc64/fpu/multiarch/s_finitef.c    | 32 ++++++++++++++
5de29b
 8 files changed, 201 insertions(+), 7 deletions(-)
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c
5de29b
 create mode 100644 sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c
5de29b
12745e
diff --git glibc-2.17-c758a686/sysdeps/ieee754/dbl-64/s_finite.c glibc-2.17-c758a686/sysdeps/ieee754/dbl-64/s_finite.c
5de29b
index 47dad5d..49986bb 100644
12745e
--- glibc-2.17-c758a686/sysdeps/ieee754/dbl-64/s_finite.c
12745e
+++ glibc-2.17-c758a686/sysdeps/ieee754/dbl-64/s_finite.c
5de29b
@@ -23,11 +23,16 @@ static char rcsid[] = "$NetBSD: s_finite.c,v 1.8 1995/05/10 20:47:17 jtc Exp $";
5de29b
 #include <math_private.h>
5de29b
 
5de29b
 #undef __finite
5de29b
-int __finite(double x)
5de29b
+
5de29b
+#ifndef FINITE
5de29b
+# define FINITE __finite
5de29b
+#endif
5de29b
+
5de29b
+int FINITE(double x)
5de29b
 {
5de29b
-	int32_t hx;
5de29b
-	GET_HIGH_WORD(hx,x);
5de29b
-	return (int)((u_int32_t)((hx&0x7fffffff)-0x7ff00000)>>31);
5de29b
+  int32_t hx;
5de29b
+  GET_HIGH_WORD (hx, x);
5de29b
+  return (int) ((u_int32_t) ((hx & 0x7fffffff) - 0x7ff00000) >> 31);
5de29b
 }
5de29b
 hidden_def (__finite)
5de29b
 weak_alias (__finite, finite)
12745e
diff --git glibc-2.17-c758a686/sysdeps/ieee754/flt-32/s_finitef.c glibc-2.17-c758a686/sysdeps/ieee754/flt-32/s_finitef.c
5de29b
index dfdf4ad..4ea270a 100644
12745e
--- glibc-2.17-c758a686/sysdeps/ieee754/flt-32/s_finitef.c
12745e
+++ glibc-2.17-c758a686/sysdeps/ieee754/flt-32/s_finitef.c
5de29b
@@ -26,7 +26,12 @@ static char rcsid[] = "$NetBSD: s_finitef.c,v 1.4 1995/05/10 20:47:18 jtc Exp $"
5de29b
 #include <math_private.h>
5de29b
 
5de29b
 #undef __finitef
5de29b
-int __finitef(float x)
5de29b
+
5de29b
+#ifndef FINITEF
5de29b
+# define FINITEF __finitef
5de29b
+#endif
5de29b
+
5de29b
+int FINITEF(float x)
5de29b
 {
5de29b
 	int32_t ix;
5de29b
 	GET_FLOAT_WORD(ix,x);
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
5de29b
index 10d0ac9..1c23ddc 100644
12745e
--- glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/Makefile
5de29b
@@ -1,7 +1,8 @@
5de29b
 ifeq ($(subdir),math)
5de29b
 sysdep_routines += s_isnan-power7 s_isnan-power6x s_isnan-power6 \
5de29b
                   s_isnan-power5 s_isnan-ppc64 s_copysign-power6 \
5de29b
-                  s_copysign-ppc64
5de29b
+                  s_copysign-ppc64 s_finite-power7 s_finite-ppc64 \
5de29b
+                  s_finitef-ppc64
5de29b
 
5de29b
 libm-sysdep_routines += s_isnan-power7 s_isnan-power6x s_isnan-power6 \
5de29b
                        s_isnan-power5 s_isnan-ppc64 s_llround-power6x \
5de29b
@@ -12,5 +13,6 @@ libm-sysdep_routines += s_isnan-power7 s_isnan-power6x s_isnan-power6 \
5de29b
                        s_roundf-power5+ s_roundf-ppc64 s_trunc-power5+ \
5de29b
                        s_trunc-ppc64 s_truncf-power5+ s_truncf-ppc64 \
5de29b
                        s_copysign-power6 s_copysign-ppc64 s_llrint-power6x \
5de29b
-                       s_llrint-ppc64
5de29b
+                       s_llrint-ppc64 s_finite-power7 s_finite-ppc64 \
5de29b
+                       s_finitef-ppc64
5de29b
 endif
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S
5de29b
new file mode 100644
5de29b
index 0000000..ac2244b
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-power7.S
5de29b
@@ -0,0 +1,33 @@
5de29b
+/* isnan().  PowerPC64/POWER7 version.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <sysdep.h>
5de29b
+#include <math_ldbl_opt.h>
5de29b
+
5de29b
+#undef hidden_def
5de29b
+#define hidden_def(name)
5de29b
+#undef weak_alias
5de29b
+#define weak_alias(name, alias)
5de29b
+#undef strong_alias
5de29b
+#define strong_alias(name, alias)
5de29b
+#undef compat_symbol
5de29b
+#define compat_symbol(lib, name, symbol, ver)
5de29b
+
5de29b
+#define __finite __finite_power7
5de29b
+
5de29b
+#include <sysdeps/powerpc/powerpc64/power7/fpu/s_finite.S>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c
5de29b
new file mode 100644
5de29b
index 0000000..1922e2b
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite-ppc64.c
5de29b
@@ -0,0 +1,34 @@
5de29b
+/* finite().  PowerPC64 default version.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   Contributed by Luis Machado <luisgpm@br.ibm.com>.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <math.h>
5de29b
+
5de29b
+#undef weak_alias
5de29b
+#define weak_alias(a, b)
5de29b
+#undef strong_alias
5de29b
+#define strong_alias(a, b)
5de29b
+
5de29b
+#define FINITE __finite_ppc64
5de29b
+#ifdef SHARED
5de29b
+# undef hidden_def
5de29b
+# define hidden_def(a) \
5de29b
+   __hidden_ver1 (__finite_ppc64, __GI___finite, __finite_ppc64);
5de29b
+#endif
5de29b
+
5de29b
+#include <sysdeps/ieee754/dbl-64/s_finite.c>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
5de29b
new file mode 100644
5de29b
index 0000000..f79a93e
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finite.c
5de29b
@@ -0,0 +1,51 @@
5de29b
+/* Multiple versions of finite.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <math.h>
5de29b
+#include <math_ldbl_opt.h>
5de29b
+#include <shlib-compat.h>
5de29b
+#include "init-arch.h"
5de29b
+
5de29b
+extern __typeof (__finite) __finite_ppc64 attribute_hidden;
5de29b
+extern __typeof (__finite) __finite_power7 attribute_hidden;
5de29b
+
5de29b
+libc_ifunc (__finite,
5de29b
+	    (hwcap & PPC_FEATURE_ARCH_2_06)
5de29b
+	    ? __finite_power7
5de29b
+            : __finite_ppc64);
5de29b
+
5de29b
+weak_alias (__finite, finite)
5de29b
+
5de29b
+#ifdef NO_LONG_DOUBLE
5de29b
+strong_alias (__finite, __finitel)
5de29b
+weak_alias (__finite, finitel)
5de29b
+#endif
5de29b
+
5de29b
+#ifdef IS_IN_libm
5de29b
+# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)
5de29b
+compat_symbol (libm, finite, finitel, GLIBC_2_0);
5de29b
+# endif
5de29b
+# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_1)
5de29b
+compat_symbol (libm, __finite, __finitel, GLIBC_2_1);
5de29b
+# endif
5de29b
+#else
5de29b
+# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
5de29b
+compat_symbol (libc, __finite, __finitel, GLIBC_2_0);
5de29b
+compat_symbol (libc, finite, finitel, GLIBC_2_0);
5de29b
+# endif
5de29b
+#endif
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c
5de29b
new file mode 100644
5de29b
index 0000000..63dd003
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef-ppc64.c
5de29b
@@ -0,0 +1,32 @@
5de29b
+/* finitef().  PowerPC64 default version.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   Contributed by Luis Machado <luisgpm@br.ibm.com>.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <math.h>
5de29b
+
5de29b
+#undef weak_alias
5de29b
+#define weak_alias(a, b)
5de29b
+
5de29b
+#define FINITEF __finitef_ppc64
5de29b
+#ifdef SHARED
5de29b
+# undef hidden_def
5de29b
+# define hidden_def(a) \
5de29b
+   __hidden_ver1 (__finitef_ppc64, __GI___finitef, __finitef_ppc64);
5de29b
+#endif
5de29b
+
5de29b
+#include <sysdeps/ieee754/flt-32/s_finitef.c>
12745e
diff --git glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c
5de29b
new file mode 100644
5de29b
index 0000000..a7243b5
5de29b
--- /dev/null
12745e
+++ glibc-2.17-c758a686/sysdeps/powerpc/powerpc64/fpu/multiarch/s_finitef.c
5de29b
@@ -0,0 +1,32 @@
5de29b
+/* Multiple versions of finitef.
5de29b
+   Copyright (C) 2013-2014 Free Software Foundation, Inc.
5de29b
+   This file is part of the GNU C Library.
5de29b
+
5de29b
+   The GNU C Library is free software; you can redistribute it and/or
5de29b
+   modify it under the terms of the GNU Lesser General Public
5de29b
+   License as published by the Free Software Foundation; either
5de29b
+   version 2.1 of the License, or (at your option) any later version.
5de29b
+
5de29b
+   The GNU C Library is distributed in the hope that it will be useful,
5de29b
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
5de29b
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
5de29b
+   Lesser General Public License for more details.
5de29b
+
5de29b
+   You should have received a copy of the GNU Lesser General Public
5de29b
+   License along with the GNU C Library; if not, see
5de29b
+   <http://www.gnu.org/licenses/>.  */
5de29b
+
5de29b
+#include <math.h>
5de29b
+#include <shlib-compat.h>
5de29b
+#include "init-arch.h"
5de29b
+
5de29b
+extern __typeof (__finitef) __finitef_ppc64 attribute_hidden;
5de29b
+/* The double-precision version also works for single-precision.  */
5de29b
+extern __typeof (__finitef) __finite_power7 attribute_hidden;
5de29b
+
5de29b
+libc_ifunc (__finitef,
5de29b
+	    (hwcap & PPC_FEATURE_ARCH_2_06)
5de29b
+	    ? __finite_power7
5de29b
+            : __finitef_ppc64);
5de29b
+
5de29b
+weak_alias (__finitef, finitef)
5de29b
-- 
5de29b
1.8.3.1
5de29b