]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
PowerPC: copysign/copysignf multilib for PowerPC
authorAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Fri, 12 Apr 2013 23:03:48 +0000 (18:03 -0500)
committerAdhemerval Zanella <azanella@linux.vnet.ibm.com>
Sun, 14 Apr 2013 20:37:53 +0000 (15:37 -0500)
sysdeps/powerpc/powerpc32/fpu/multiarch/Makefile
sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysign-power6.S [moved from sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S with 65% similarity]
sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysign-ppc32.S [new file with mode: 0644]
sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysign.c [new file with mode: 0644]
sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysignf.c [new file with mode: 0644]
sysdeps/powerpc/powerpc32/fpu/s_copysign.S
sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S [deleted file]

index c9003e36a6da57ac8e43888a776a7de05d98f914..9fb2528e21ed1a89a768eb2adc856e8247ae2d22 100644 (file)
@@ -2,7 +2,8 @@ ifeq ($(subdir),math)
 sysdep_routines += s_isnan-power7 s_isnan-power6 s_isnan-power5 \
                   s_isnan-ppc32 \
                   s_isnanf-power7 s_isnanf-power6 s_isnanf-power5 \
-                  s_isnanf-ppc32
+                  s_isnanf-ppc32 \
+                  s_copysign-power6 s_copysign-ppc32
 
 libm-sysdep_routines += s_llrintf-power6 s_llrintf-power4 s_llrintf-c \
                        s_llrint-power6 s_llrint-power4 s_llrint-c \
@@ -13,7 +14,8 @@ libm-sysdep_routines += s_llrintf-power6 s_llrintf-power4 s_llrintf-c \
                        s_isnan-power7 s_isnan-power6 s_isnan-power5 \
                        s_isnan-ppc32 \
                        s_isnanf-power7 s_isnanf-power6 s_isnanf-power5 \
-                       s_isnanf-ppc32
+                       s_isnanf-ppc32 \
+                       s_copysign-power6 s_copysign-ppc32
 
 CFLAGS-s_llround.c = -fno-builtin-llroundf
 endif
similarity index 65%
rename from sysdeps/powerpc/powerpc32/power6/fpu/s_copysign.S
rename to sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysign-power6.S
index 1b8d73af03e3397ab5214b3ec85e565b3257e366..7aa28e1814f7476ba11a5525b2d058eddb5db861 100644 (file)
        .section    ".text"
        .type       __copysign, @function
        .machine    power6
-EALIGN (__copysign, 4, 0)
+EALIGN (__copysign_power6, 4, 0)
        CALL_MCOUNT
        fcpsgn  fp1,fp2,fp1
        blr
-END (__copysign)
-
-hidden_def (__copysign)
-weak_alias (__copysign, copysign)
-
-/* It turns out that the 'double' version will also always work for
-   single-precision.  */
-strong_alias (__copysign, __copysignf)
-hidden_def (__copysignf)
-weak_alias (__copysignf, copysignf)
-
-#ifdef NO_LONG_DOUBLE
-strong_alias (__copysign, __copysignl)
-weak_alias (__copysign, copysignl)
-#endif
-
-#ifdef IS_IN_libm
-# if LONG_DOUBLE_COMPAT (libm, GLIBC_2_0)
-compat_symbol (libm, copysign, copysignl, GLIBC_2_0)
-# endif
-#else
-# if LONG_DOUBLE_COMPAT (libc, GLIBC_2_0)
-compat_symbol (libc, copysign, copysignl, GLIBC_2_0);
-# endif
-#endif
+END (__copysign_power6)
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysign-ppc32.S b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysign-ppc32.S
new file mode 100644 (file)
index 0000000..c0b9f45
--- /dev/null
@@ -0,0 +1,12 @@
+#include <sysdep.h>
+#include <math_ldbl_opt.h>
+
+#undef compat_symbol
+#define compat_symbol(a, b, c, d)
+
+#define __copysign __copysign_ppc32
+#undef hidden_def
+#define hidden_def(name)
+  strong_alias (__copysign_ppc32, __GI___copysign)
+
+#include <sysdeps/powerpc/powerpc32/fpu/s_copysign.S>
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysign.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysign.c
new file mode 100644 (file)
index 0000000..67a38e9
--- /dev/null
@@ -0,0 +1,55 @@
+/* Multiple versions of s_copysign.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <math_ldbl_opt.h>
+#include <shlib-compat.h>
+#include "init-arch.h"
+
+extern __typeof (__copysign) __copysign_ppc32 attribute_hidden;
+extern __typeof (__copysign) __copysign_power6 attribute_hidden;
+
+libc_ifunc (__copysign,
+           (hwcap & PPC_FEATURE_ARCH_2_05)
+           ? __copysign_power6
+            : __copysign_ppc32);
+
+weak_alias (__copysign, copysign)
+
+/* It's safe to use double-precision implementation for single-precision.
+   The following assembly directives are basically doing:
+   weak_alias (__copysign,copysignf)
+   strong_alias(__copysign,__copysignf)
+   But the compiler will not let us do it in C because both __copysignf and
+   copysignf are already defined.  */
+asm (".weak copysignf\n"
+     ".set  copysignf, __copysign");
+asm (".globl __copysign\n"
+     "__copysign = __copysignf");
+
+#ifdef NO_LONG_DOUBLE
+weak_alias (__copysign,copysignl)
+strong_alias(__copysign,__copysignl)
+#endif
+#ifdef IS_IN_libm
+# if LONG_DOUBLE_COMPAT(libm, GLIBC_2_0)
+compat_symbol (libm, __copysign, copysignl, GLIBC_2_0);
+# endif
+#elif LONG_DOUBLE_COMPAT(libc, GLIBC_2_0)
+compat_symbol (libc, __copysign, copysignl, GLIBC_2_0);
+#endif
diff --git a/sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysignf.c b/sysdeps/powerpc/powerpc32/fpu/multiarch/s_copysignf.c
new file mode 100644 (file)
index 0000000..2838458
--- /dev/null
@@ -0,0 +1 @@
+/* copysignf() is in s_copysign.c  */
index 840891f1c388d24110924d29838f97ebc0333863..9753cb682f8d2f759c2e88e7e72a685742a34dfb 100644 (file)
@@ -43,8 +43,10 @@ L(0):        fnabs   fp1,fp1
 weak_alias (__copysign,copysign)
 
 /* It turns out that it's safe to use this code even for single-precision.  */
+#ifndef __isnan
 weak_alias (__copysign,copysignf)
 strong_alias(__copysign,__copysignf)
+#endif
 
 #ifdef NO_LONG_DOUBLE
 weak_alias (__copysign,copysignl)
diff --git a/sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S b/sysdeps/powerpc/powerpc32/power6/fpu/s_copysignf.S
deleted file mode 100644 (file)
index d4aa702..0000000
+++ /dev/null
@@ -1 +0,0 @@
-/* This function uses the same code as s_copysign.S.  */