]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
x86-64: Implement libm IFUNC selectors in C
authorH.J. Lu <hjl.tools@gmail.com>
Fri, 4 Aug 2017 20:01:59 +0000 (13:01 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Fri, 4 Aug 2017 20:02:13 +0000 (13:02 -0700)
* sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
Add s_ceil-sse4_1, s_ceilf-sse4_1, s_floor-sse4_1,
s_floorf-sse4_1, s_nearbyint-sse4_1, s_nearbyintf-sse4_1,
s_rint-sse4_1 and s_rintf-sse4_1.
* sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h: New file.
* sysdeps/x86_64/fpu/multiarch/s_ceil.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_ceilf.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_floor.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_floorf.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_nearbyint.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_rint.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_rintf.c: Likewise.
* sysdeps/x86_64/fpu/multiarch/s_ceil.S: Renamed to ...
* sysdeps/x86_64/fpu/multiarch/s_ceil-sse4_1.S: This.  Don't
include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
(__ceil): Removed.
* sysdeps/x86_64/fpu/multiarch/s_ceilf.S: Renamed to ...
* sysdeps/x86_64/fpu/multiarch/s_ceilf-sse4_1.S: This.  Don't
include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
(__ceilf): Removed.
* sysdeps/x86_64/fpu/multiarch/s_floor.S: Renamed to ...
* sysdeps/x86_64/fpu/multiarch/s_floor-sse4_1.S: This.  Don't
include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
(__floor): Removed.
* sysdeps/x86_64/fpu/multiarch/s_floorf.S: Renamed to ...
* sysdeps/x86_64/fpu/multiarch/s_floorf-sse4_1.S: This.  Don't
include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
(__floorf): Removed.
* sysdeps/x86_64/fpu/multiarch/s_nearbyint.S: Renamed to ...
* sysdeps/x86_64/fpu/multiarch/s_nearbyint-sse4_1.S: This.  Don't
include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
(__nearbyint): Removed.
* sysdeps/x86_64/fpu/multiarch/s_nearbyintf.S: Renamed to ...
* sysdeps/x86_64/fpu/multiarch/s_nearbyintf-sse4_1.S: This.  Don't
include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
(__nearbyintf): Removed.
* sysdeps/x86_64/fpu/multiarch/s_rint.S: Renamed to ...
* sysdeps/x86_64/fpu/multiarch/s_rint-sse4_1.S: This.  Don't
include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
(__rint): Removed.
* sysdeps/x86_64/fpu/multiarch/s_rintf.S: Renamed to ...
* sysdeps/x86_64/fpu/multiarch/s_rintf-sse4_1.S: This.  Don't
include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
(__rintf): Removed.

19 files changed:
ChangeLog
sysdeps/x86_64/fpu/multiarch/Makefile
sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h [new file with mode: 0644]
sysdeps/x86_64/fpu/multiarch/s_ceil-sse4_1.S [moved from sysdeps/x86_64/fpu/multiarch/s_ceil.S with 77% similarity]
sysdeps/x86_64/fpu/multiarch/s_ceil.c [new file with mode: 0644]
sysdeps/x86_64/fpu/multiarch/s_ceilf-sse4_1.S [moved from sysdeps/x86_64/fpu/multiarch/s_ceilf.S with 77% similarity]
sysdeps/x86_64/fpu/multiarch/s_ceilf.c [new file with mode: 0644]
sysdeps/x86_64/fpu/multiarch/s_floor-sse4_1.S [moved from sysdeps/x86_64/fpu/multiarch/s_floor.S with 77% similarity]
sysdeps/x86_64/fpu/multiarch/s_floor.c [new file with mode: 0644]
sysdeps/x86_64/fpu/multiarch/s_floorf-sse4_1.S [moved from sysdeps/x86_64/fpu/multiarch/s_floorf.S with 76% similarity]
sysdeps/x86_64/fpu/multiarch/s_floorf.c [new file with mode: 0644]
sysdeps/x86_64/fpu/multiarch/s_nearbyint-sse4_1.S [moved from sysdeps/x86_64/fpu/multiarch/s_nearbyint.S with 75% similarity]
sysdeps/x86_64/fpu/multiarch/s_nearbyint.c [new file with mode: 0644]
sysdeps/x86_64/fpu/multiarch/s_nearbyintf-sse4_1.S [moved from sysdeps/x86_64/fpu/multiarch/s_nearbyintf.S with 75% similarity]
sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c [new file with mode: 0644]
sysdeps/x86_64/fpu/multiarch/s_rint-sse4_1.S [moved from sysdeps/x86_64/fpu/multiarch/s_rint.S with 77% similarity]
sysdeps/x86_64/fpu/multiarch/s_rint.c [new file with mode: 0644]
sysdeps/x86_64/fpu/multiarch/s_rintf-sse4_1.S [moved from sysdeps/x86_64/fpu/multiarch/s_rintf.S with 77% similarity]
sysdeps/x86_64/fpu/multiarch/s_rintf.c [new file with mode: 0644]

index acfcdcc2ee15fedbbc1ec2673845fceb050fb010..421a0e05948a1d1ba5f1b462346a3235ae9625bc 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,51 @@
+2017-08-04  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * sysdeps/x86_64/fpu/multiarch/Makefile (libm-sysdep_routines):
+       Add s_ceil-sse4_1, s_ceilf-sse4_1, s_floor-sse4_1,
+       s_floorf-sse4_1, s_nearbyint-sse4_1, s_nearbyintf-sse4_1,
+       s_rint-sse4_1 and s_rintf-sse4_1.
+       * sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h: New file.
+       * sysdeps/x86_64/fpu/multiarch/s_ceil.c: Likewise.
+       * sysdeps/x86_64/fpu/multiarch/s_ceilf.c: Likewise.
+       * sysdeps/x86_64/fpu/multiarch/s_floor.c: Likewise.
+       * sysdeps/x86_64/fpu/multiarch/s_floorf.c: Likewise.
+       * sysdeps/x86_64/fpu/multiarch/s_nearbyint.c: Likewise.
+       * sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c: Likewise.
+       * sysdeps/x86_64/fpu/multiarch/s_rint.c: Likewise.
+       * sysdeps/x86_64/fpu/multiarch/s_rintf.c: Likewise.
+       * sysdeps/x86_64/fpu/multiarch/s_ceil.S: Renamed to ...
+       * sysdeps/x86_64/fpu/multiarch/s_ceil-sse4_1.S: This.  Don't
+       include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
+       (__ceil): Removed.
+       * sysdeps/x86_64/fpu/multiarch/s_ceilf.S: Renamed to ...
+       * sysdeps/x86_64/fpu/multiarch/s_ceilf-sse4_1.S: This.  Don't
+       include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
+       (__ceilf): Removed.
+       * sysdeps/x86_64/fpu/multiarch/s_floor.S: Renamed to ...
+       * sysdeps/x86_64/fpu/multiarch/s_floor-sse4_1.S: This.  Don't
+       include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
+       (__floor): Removed.
+       * sysdeps/x86_64/fpu/multiarch/s_floorf.S: Renamed to ...
+       * sysdeps/x86_64/fpu/multiarch/s_floorf-sse4_1.S: This.  Don't
+       include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
+       (__floorf): Removed.
+       * sysdeps/x86_64/fpu/multiarch/s_nearbyint.S: Renamed to ...
+       * sysdeps/x86_64/fpu/multiarch/s_nearbyint-sse4_1.S: This.  Don't
+       include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
+       (__nearbyint): Removed.
+       * sysdeps/x86_64/fpu/multiarch/s_nearbyintf.S: Renamed to ...
+       * sysdeps/x86_64/fpu/multiarch/s_nearbyintf-sse4_1.S: This.  Don't
+       include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
+       (__nearbyintf): Removed.
+       * sysdeps/x86_64/fpu/multiarch/s_rint.S: Renamed to ...
+       * sysdeps/x86_64/fpu/multiarch/s_rint-sse4_1.S: This.  Don't
+       include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
+       (__rint): Removed.
+       * sysdeps/x86_64/fpu/multiarch/s_rintf.S: Renamed to ...
+       * sysdeps/x86_64/fpu/multiarch/s_rintf-sse4_1.S: This.  Don't
+       include <machine/asm.h> nor <init-arch.h>.  Include <sysdep.h>.
+       (__rintf): Removed.
+
 2017-08-04  H.J. Lu  <hongjiu.lu@intel.com>
 
        * sysdeps/i386/start.S (_start): Check Check PIC instead of
index 34542155aa4f98b4b3f32a3402af38501d14301c..86ddde358bc14a093169b8929b8b84a67f4ccd83 100644 (file)
@@ -2,6 +2,10 @@ ifeq ($(subdir),math)
 libm-sysdep_routines += s_floor-c s_ceil-c s_floorf-c s_ceilf-c \
                        s_rint-c s_rintf-c s_nearbyint-c s_nearbyintf-c
 
+libm-sysdep_routines += s_ceil-sse4_1 s_ceilf-sse4_1 s_floor-sse4_1 \
+                       s_floorf-sse4_1 s_nearbyint-sse4_1 \
+                       s_nearbyintf-sse4_1 s_rint-sse4_1 s_rintf-sse4_1
+
 libm-sysdep_routines += e_exp-fma4 e_log-fma4 e_pow-fma4 s_atan-fma4 \
                        e_asin-fma4 e_atan2-fma4 s_sin-fma4 s_tan-fma4 \
                        mplog-fma4 mpa-fma4 slowexp-fma4 slowpow-fma4 \
diff --git a/sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h b/sysdeps/x86_64/fpu/multiarch/ifunc-sse4_1.h
new file mode 100644 (file)
index 0000000..ad8d878
--- /dev/null
@@ -0,0 +1,33 @@
+/* Common definition for ifunc selections optimized with SSE4.1.
+   Copyright (C) 2017 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 <init-arch.h>
+
+extern __typeof (REDIRECT_NAME) OPTIMIZE (c) attribute_hidden;
+extern __typeof (REDIRECT_NAME) OPTIMIZE (sse41) attribute_hidden;
+
+static inline void *
+IFUNC_SELECTOR (void)
+{
+  const struct cpu_features* cpu_features = __get_cpu_features ();
+
+  if (CPU_FEATURES_CPU_P (cpu_features, SSE4_1))
+    return OPTIMIZE (sse41);
+
+  return OPTIMIZE (c);
+}
similarity index 77%
rename from sysdeps/x86_64/fpu/multiarch/s_ceil.S
rename to sysdeps/x86_64/fpu/multiarch/s_ceil-sse4_1.S
index f8eef43eff176d2e8104f23481241b26a1340b87..6d6be97432e7446e39b76c1a87f7ccf1c7debc22 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <machine/asm.h>
-#include <init-arch.h>
-
-
-ENTRY(__ceil)
-       .type   __ceil, @gnu_indirect_function
-       LOAD_RTLD_GLOBAL_RO_RDX
-       leaq    __ceil_sse41(%rip), %rax
-       HAS_CPU_FEATURE (SSE4_1)
-       jnz     2f
-       leaq    __ceil_c(%rip), %rax
-2:     ret
-END(__ceil)
-weak_alias (__ceil, ceil)
-
+#include <sysdep.h>
 
+       .section .text.sse4.1,"ax",@progbits
 ENTRY(__ceil_sse41)
        roundsd $10, %xmm0, %xmm0
        ret
diff --git a/sysdeps/x86_64/fpu/multiarch/s_ceil.c b/sysdeps/x86_64/fpu/multiarch/s_ceil.c
new file mode 100644 (file)
index 0000000..2c01957
--- /dev/null
@@ -0,0 +1,29 @@
+/* Multiple versions of __ceil.
+   Copyright (C) 2017 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/>.  */
+
+#define ceil __redirect_ceil
+#define __ceil __redirect___ceil
+#include <math.h>
+#undef ceil
+#undef __ceil
+
+#define SYMBOL_NAME ceil
+#include "ifunc-sse4_1.h"
+
+libc_ifunc_redirected (__redirect_ceil, __ceil, IFUNC_SELECTOR ());
+weak_alias (__ceil, ceil)
similarity index 77%
rename from sysdeps/x86_64/fpu/multiarch/s_ceilf.S
rename to sysdeps/x86_64/fpu/multiarch/s_ceilf-sse4_1.S
index 076f10f0f07eb946c5bf8014c3fc6d4f11a52d36..9081ce6eb488e737f5d95a90e53ff72c5a4385ed 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <machine/asm.h>
-#include <init-arch.h>
-
-
-ENTRY(__ceilf)
-       .type   __ceilf, @gnu_indirect_function
-       LOAD_RTLD_GLOBAL_RO_RDX
-       leaq    __ceilf_sse41(%rip), %rax
-       HAS_CPU_FEATURE (SSE4_1)
-       jnz     2f
-       leaq    __ceilf_c(%rip), %rax
-2:     ret
-END(__ceilf)
-weak_alias (__ceilf, ceilf)
-
+#include <sysdep.h>
 
+       .section .text.sse4.1,"ax",@progbits
 ENTRY(__ceilf_sse41)
        roundss $10, %xmm0, %xmm0
        ret
diff --git a/sysdeps/x86_64/fpu/multiarch/s_ceilf.c b/sysdeps/x86_64/fpu/multiarch/s_ceilf.c
new file mode 100644 (file)
index 0000000..090de04
--- /dev/null
@@ -0,0 +1,29 @@
+/* Multiple versions of __ceilf.
+   Copyright (C) 2017 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/>.  */
+
+#define ceilf __redirect_ceilf
+#define __ceilf __redirect___ceilf
+#include <math.h>
+#undef ceilf
+#undef __ceilf
+
+#define SYMBOL_NAME ceilf
+#include "ifunc-sse4_1.h"
+
+libc_ifunc_redirected (__redirect_ceilf, __ceilf, IFUNC_SELECTOR ());
+weak_alias (__ceilf, ceilf)
similarity index 77%
rename from sysdeps/x86_64/fpu/multiarch/s_floor.S
rename to sysdeps/x86_64/fpu/multiarch/s_floor-sse4_1.S
index f519ab24f4b0b1467240497cd622fbe0d656b0e3..022a4ac160fae0d762c7f90c4cb56a5b3930ff5a 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <machine/asm.h>
-#include <init-arch.h>
-
-
-ENTRY(__floor)
-       .type   __floor, @gnu_indirect_function
-       LOAD_RTLD_GLOBAL_RO_RDX
-       leaq    __floor_sse41(%rip), %rax
-       HAS_CPU_FEATURE (SSE4_1)
-       jnz     2f
-       leaq    __floor_c(%rip), %rax
-2:     ret
-END(__floor)
-weak_alias (__floor, floor)
-
+#include <sysdep.h>
 
+       .section .text.sse4.1,"ax",@progbits
 ENTRY(__floor_sse41)
        roundsd $9, %xmm0, %xmm0
        ret
diff --git a/sysdeps/x86_64/fpu/multiarch/s_floor.c b/sysdeps/x86_64/fpu/multiarch/s_floor.c
new file mode 100644 (file)
index 0000000..3dd0f81
--- /dev/null
@@ -0,0 +1,29 @@
+/* Multiple versions of __floor.
+   Copyright (C) 2017 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/>.  */
+
+#define floor __redirect_floor
+#define __floor __redirect___floor
+#include <math.h>
+#undef floor
+#undef __floor
+
+#define SYMBOL_NAME floor
+#include "ifunc-sse4_1.h"
+
+libc_ifunc_redirected (__redirect_floor, __floor, IFUNC_SELECTOR ());
+weak_alias (__floor, floor)
similarity index 76%
rename from sysdeps/x86_64/fpu/multiarch/s_floorf.S
rename to sysdeps/x86_64/fpu/multiarch/s_floorf-sse4_1.S
index 8613f73accba421fcaa610475c286a159d22ac2f..ea631441e7e0fe60dc4d12c1ac292c5976fc37d0 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <machine/asm.h>
-#include <init-arch.h>
-
-
-ENTRY(__floorf)
-       .type   __floorf, @gnu_indirect_function
-       LOAD_RTLD_GLOBAL_RO_RDX
-       leaq    __floorf_sse41(%rip), %rax
-       HAS_CPU_FEATURE (SSE4_1)
-       jnz     2f
-       leaq    __floorf_c(%rip), %rax
-2:     ret
-END(__floorf)
-weak_alias (__floorf, floorf)
-
+#include <sysdep.h>
 
+       .section .text.sse4.1,"ax",@progbits
 ENTRY(__floorf_sse41)
        roundss $9, %xmm0, %xmm0
        ret
diff --git a/sysdeps/x86_64/fpu/multiarch/s_floorf.c b/sysdeps/x86_64/fpu/multiarch/s_floorf.c
new file mode 100644 (file)
index 0000000..d6cf14d
--- /dev/null
@@ -0,0 +1,29 @@
+/* Multiple versions of __floorf.
+   Copyright (C) 2017 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/>.  */
+
+#define floorf __redirect_floorf
+#define __floorf __redirect___floorf
+#include <math.h>
+#undef floorf
+#undef __floorf
+
+#define SYMBOL_NAME floorf
+#include "ifunc-sse4_1.h"
+
+libc_ifunc_redirected (__redirect_floorf, __floorf, IFUNC_SELECTOR ());
+weak_alias (__floorf, floorf)
similarity index 75%
rename from sysdeps/x86_64/fpu/multiarch/s_nearbyint.S
rename to sysdeps/x86_64/fpu/multiarch/s_nearbyint-sse4_1.S
index 5a734f60279e5ebd6b79f0f6a3cefb54118444d2..68934aac730803e93083cd97300ac087fd8be570 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <machine/asm.h>
-#include <init-arch.h>
-
-
-ENTRY(__nearbyint)
-       .type   __nearbyint, @gnu_indirect_function
-       LOAD_RTLD_GLOBAL_RO_RDX
-       leaq    __nearbyint_sse41(%rip), %rax
-       HAS_CPU_FEATURE (SSE4_1)
-       jnz     2f
-       leaq    __nearbyint_c(%rip), %rax
-2:     ret
-END(__nearbyint)
-weak_alias (__nearbyint, nearbyint)
-
+#include <sysdep.h>
 
+       .section .text.sse4.1,"ax",@progbits
 ENTRY(__nearbyint_sse41)
        roundsd $0xc, %xmm0, %xmm0
        ret
diff --git a/sysdeps/x86_64/fpu/multiarch/s_nearbyint.c b/sysdeps/x86_64/fpu/multiarch/s_nearbyint.c
new file mode 100644 (file)
index 0000000..05579c6
--- /dev/null
@@ -0,0 +1,30 @@
+/* Multiple versions of __nearbyint.
+   Copyright (C) 2017 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/>.  */
+
+#define nearbyint __redirect_nearbyint
+#define __nearbyint __redirect___nearbyint
+#include <math.h>
+#undef nearbyint
+#undef __nearbyint
+
+#define SYMBOL_NAME nearbyint
+#include "ifunc-sse4_1.h"
+
+libc_ifunc_redirected (__redirect_nearbyint, __nearbyint,
+                      IFUNC_SELECTOR ());
+weak_alias (__nearbyint, nearbyint)
similarity index 75%
rename from sysdeps/x86_64/fpu/multiarch/s_nearbyintf.S
rename to sysdeps/x86_64/fpu/multiarch/s_nearbyintf-sse4_1.S
index ad79fd6021b4892b16b9a35083773ab38c233b00..16bd905655f069e6b267255b906cb9a8856bd112 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <machine/asm.h>
-#include <init-arch.h>
-
-
-ENTRY(__nearbyintf)
-       .type   __nearbyintf, @gnu_indirect_function
-       LOAD_RTLD_GLOBAL_RO_RDX
-       leaq    __nearbyintf_sse41(%rip), %rax
-       HAS_CPU_FEATURE (SSE4_1)
-       jnz     2f
-       leaq    __nearbyintf_c(%rip), %rax
-2:     ret
-END(__nearbyintf)
-weak_alias (__nearbyintf, nearbyintf)
-
+#include <sysdep.h>
 
+       .section .text.sse4.1,"ax",@progbits
 ENTRY(__nearbyintf_sse41)
        roundss $0xc, %xmm0, %xmm0
        ret
diff --git a/sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c b/sysdeps/x86_64/fpu/multiarch/s_nearbyintf.c
new file mode 100644 (file)
index 0000000..e716c94
--- /dev/null
@@ -0,0 +1,30 @@
+/* Multiple versions of __nearbyintf.
+   Copyright (C) 2017 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/>.  */
+
+#define nearbyintf __redirect_nearbyintf
+#define __nearbyintf __redirect___nearbyintf
+#include <math.h>
+#undef nearbyintf
+#undef __nearbyintf
+
+#define SYMBOL_NAME nearbyintf
+#include "ifunc-sse4_1.h"
+
+libc_ifunc_redirected (__redirect_nearbyintf, __nearbyintf,
+                      IFUNC_SELECTOR ());
+weak_alias (__nearbyintf, nearbyintf)
similarity index 77%
rename from sysdeps/x86_64/fpu/multiarch/s_rint.S
rename to sysdeps/x86_64/fpu/multiarch/s_rint-sse4_1.S
index 4f628a93a4a163f290bbaff1ba4daeacbfeaec08..9224aa92b22b44bd4bb0e7a34ab16b4d9828b1c8 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <machine/asm.h>
-#include <init-arch.h>
-
-
-ENTRY(__rint)
-       .type   __rint, @gnu_indirect_function
-       LOAD_RTLD_GLOBAL_RO_RDX
-       leaq    __rint_sse41(%rip), %rax
-       HAS_CPU_FEATURE (SSE4_1)
-       jnz     2f
-       leaq    __rint_c(%rip), %rax
-2:     ret
-END(__rint)
-weak_alias (__rint, rint)
-
+#include <sysdep.h>
 
+       .section .text.sse4.1,"ax",@progbits
 ENTRY(__rint_sse41)
        roundsd $4, %xmm0, %xmm0
        ret
diff --git a/sysdeps/x86_64/fpu/multiarch/s_rint.c b/sysdeps/x86_64/fpu/multiarch/s_rint.c
new file mode 100644 (file)
index 0000000..ad44e7c
--- /dev/null
@@ -0,0 +1,29 @@
+/* Multiple versions of __rint.
+   Copyright (C) 2017 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/>.  */
+
+#define rint __redirect_rint
+#define __rint __redirect___rint
+#include <math.h>
+#undef rint
+#undef __rint
+
+#define SYMBOL_NAME rint
+#include "ifunc-sse4_1.h"
+
+libc_ifunc_redirected (__redirect_rint, __rint, IFUNC_SELECTOR ());
+weak_alias (__rint, rint)
similarity index 77%
rename from sysdeps/x86_64/fpu/multiarch/s_rintf.S
rename to sysdeps/x86_64/fpu/multiarch/s_rintf-sse4_1.S
index dee4ad794cf3af0df6ffe9e600fb794441250d88..7f47592d8cc6c44faeaefb230b28db321b6a8188 100644 (file)
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <machine/asm.h>
-#include <init-arch.h>
-
-
-ENTRY(__rintf)
-       .type   __rintf, @gnu_indirect_function
-       LOAD_RTLD_GLOBAL_RO_RDX
-       leaq    __rintf_sse41(%rip), %rax
-       HAS_CPU_FEATURE (SSE4_1)
-       jnz     2f
-       leaq    __rintf_c(%rip), %rax
-2:     ret
-END(__rintf)
-weak_alias (__rintf, rintf)
-
+#include <sysdep.h>
 
+       .section .text.sse4.1,"ax",@progbits
 ENTRY(__rintf_sse41)
        roundss $4, %xmm0, %xmm0
        ret
diff --git a/sysdeps/x86_64/fpu/multiarch/s_rintf.c b/sysdeps/x86_64/fpu/multiarch/s_rintf.c
new file mode 100644 (file)
index 0000000..88f3052
--- /dev/null
@@ -0,0 +1,29 @@
+/* Multiple versions of __rintf.
+   Copyright (C) 2017 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/>.  */
+
+#define rintf __redirect_rintf
+#define __rintf __redirect___rintf
+#include <math.h>
+#undef rintf
+#undef __rintf
+
+#define SYMBOL_NAME rintf
+#include "ifunc-sse4_1.h"
+
+libc_ifunc_redirected (__redirect_rintf, __rintf, IFUNC_SELECTOR ());
+weak_alias (__rintf, rintf)