From 7408c1ec242bd20f99509a80d2bde335876e4a29 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Thu, 20 Aug 2015 08:33:40 -0700 Subject: Add i386 rawmemchr multiarch functions --- sysdeps/i386/i686/multiarch/Makefile | 1 - sysdeps/i386/i686/multiarch/rawmemchr-sse2-bsf.S | 3 -- sysdeps/i386/i686/multiarch/rawmemchr-sse2.S | 3 -- sysdeps/i386/i686/multiarch/rawmemchr.S | 65 ------------------------ sysdeps/i386/multiarch/Makefile | 3 +- sysdeps/i386/multiarch/ifunc-impl-list.c | 4 +- sysdeps/i386/multiarch/rawmemchr-sse2-bsf.S | 3 ++ sysdeps/i386/multiarch/rawmemchr-sse2.S | 3 ++ sysdeps/i386/multiarch/rawmemchr.S | 65 ++++++++++++++++++++++++ sysdeps/i386/multiarch/rtld-rawmemchr.S | 20 ++++++++ 10 files changed, 95 insertions(+), 75 deletions(-) delete mode 100644 sysdeps/i386/i686/multiarch/rawmemchr-sse2-bsf.S delete mode 100644 sysdeps/i386/i686/multiarch/rawmemchr-sse2.S delete mode 100644 sysdeps/i386/i686/multiarch/rawmemchr.S create mode 100644 sysdeps/i386/multiarch/rawmemchr-sse2-bsf.S create mode 100644 sysdeps/i386/multiarch/rawmemchr-sse2.S create mode 100644 sysdeps/i386/multiarch/rawmemchr.S create mode 100644 sysdeps/i386/multiarch/rtld-rawmemchr.S diff --git a/sysdeps/i386/i686/multiarch/Makefile b/sysdeps/i386/i686/multiarch/Makefile index 0b91d00a0d..74333caee5 100644 --- a/sysdeps/i386/i686/multiarch/Makefile +++ b/sysdeps/i386/i686/multiarch/Makefile @@ -7,7 +7,6 @@ sysdep_routines += strcmp-ssse3 \ strncpy-sse2 stpcpy-sse2 stpncpy-sse2 strcat-ssse3 \ strcat-sse2 strncat-ssse3 strncat-sse2 strncat-c \ strchr-sse2 strrchr-sse2 strchr-sse2-bsf strrchr-sse2-bsf \ - rawmemchr-sse2 rawmemchr-sse2-bsf \ strnlen-sse2 strnlen-c \ strcasecmp_l-c strcasecmp-c strcasecmp_l-ssse3 \ strncase_l-c strncase-c strncase_l-ssse3 \ diff --git a/sysdeps/i386/i686/multiarch/rawmemchr-sse2-bsf.S b/sysdeps/i386/i686/multiarch/rawmemchr-sse2-bsf.S deleted file mode 100644 index 88c0e5776c..0000000000 --- a/sysdeps/i386/i686/multiarch/rawmemchr-sse2-bsf.S +++ /dev/null @@ -1,3 +0,0 @@ -#define USE_AS_RAWMEMCHR -#define MEMCHR __rawmemchr_sse2_bsf -#include "memchr-sse2-bsf.S" diff --git a/sysdeps/i386/i686/multiarch/rawmemchr-sse2.S b/sysdeps/i386/i686/multiarch/rawmemchr-sse2.S deleted file mode 100644 index 038c74896b..0000000000 --- a/sysdeps/i386/i686/multiarch/rawmemchr-sse2.S +++ /dev/null @@ -1,3 +0,0 @@ -#define USE_AS_RAWMEMCHR -#define MEMCHR __rawmemchr_sse2 -#include "memchr-sse2.S" diff --git a/sysdeps/i386/i686/multiarch/rawmemchr.S b/sysdeps/i386/i686/multiarch/rawmemchr.S deleted file mode 100644 index 2cfbe1b3fc..0000000000 --- a/sysdeps/i386/i686/multiarch/rawmemchr.S +++ /dev/null @@ -1,65 +0,0 @@ -/* Multiple versions of rawmemchr - All versions must be listed in ifunc-impl-list.c. - Copyright (C) 2011-2015 Free Software Foundation, Inc. - Contributed by Intel Corporation. - 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 - . */ - -#include -#include - -#if IS_IN (libc) - .text -ENTRY(__rawmemchr) - .type __rawmemchr, @gnu_indirect_function - LOAD_GOT_AND_RTLD_GLOBAL_RO - HAS_CPU_FEATURE (SSE2) - jz 2f - HAS_ARCH_FEATURE (Slow_BSF) - jz 3f - - LOAD_FUNC_GOT_EAX (__rawmemchr_sse2) - ret - -2: LOAD_FUNC_GOT_EAX (__rawmemchr_ia32) - ret - -3: LOAD_FUNC_GOT_EAX (__rawmemchr_sse2_bsf) - ret -END(__rawmemchr) - -weak_alias(__rawmemchr, rawmemchr) - -# undef ENTRY -# define ENTRY(name) \ - .type __rawmemchr_ia32, @function; \ - .globl __rawmemchr_ia32; \ - .p2align 4; \ - __rawmemchr_ia32: cfi_startproc; \ - CALL_MCOUNT -# undef END -# define END(name) \ - cfi_endproc; .size __rawmemchr_ia32, .-__rawmemchr_ia32 - -# undef libc_hidden_def -/* IFUNC doesn't work with the hidden functions in shared library since - they will be called without setting up EBX needed for PLT which is - used by IFUNC. */ -# define libc_hidden_def(name) \ - .globl __GI___rawmemchr; __GI___rawmemchr = __rawmemchr_ia32 - -#endif -#include "../../rawmemchr.S" diff --git a/sysdeps/i386/multiarch/Makefile b/sysdeps/i386/multiarch/Makefile index fc9364fe65..8a9ecf3a3a 100644 --- a/sysdeps/i386/multiarch/Makefile +++ b/sysdeps/i386/multiarch/Makefile @@ -20,5 +20,6 @@ sysdep_routines += bcopy-i386 bcopy-i686 bcopy-sse2-unaligned \ memset-sse2 memset-sse2-rep \ memchr-sse2-bsf memchr-sse2 \ memcmp-i386 memcmp-i686 memcmp-ssse3 memcmp-sse4 \ - memrchr-i386 memrchr-sse2-bsf memrchr-sse2 + memrchr-i386 memrchr-sse2-bsf memrchr-sse2 \ + rawmemchr-sse2-bsf rawmemchr-sse2 endif diff --git a/sysdeps/i386/multiarch/ifunc-impl-list.c b/sysdeps/i386/multiarch/ifunc-impl-list.c index 15c2009e62..ce5abeb335 100644 --- a/sysdeps/i386/multiarch/ifunc-impl-list.c +++ b/sysdeps/i386/multiarch/ifunc-impl-list.c @@ -157,15 +157,15 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array, #endif ) -#if 0 /* Support sysdeps/i386/i686/multiarch/rawmemchr.S. */ IFUNC_IMPL (i, name, rawmemchr, IFUNC_IMPL_ADD (array, i, rawmemchr, HAS_CPU_FEATURE (SSE2), __rawmemchr_sse2_bsf) IFUNC_IMPL_ADD (array, i, rawmemchr, HAS_CPU_FEATURE (SSE2), __rawmemchr_sse2) - IFUNC_IMPL_ADD (array, i, rawmemchr, 1, __rawmemchr_ia32)) + IFUNC_IMPL_ADD (array, i, rawmemchr, 1, __rawmemchr_i386)) +#if 0 /* Support sysdeps/i386/i686/multiarch/stpncpy.S. */ IFUNC_IMPL (i, name, stpncpy, IFUNC_IMPL_ADD (array, i, stpncpy, HAS_CPU_FEATURE (SSSE3), diff --git a/sysdeps/i386/multiarch/rawmemchr-sse2-bsf.S b/sysdeps/i386/multiarch/rawmemchr-sse2-bsf.S new file mode 100644 index 0000000000..88c0e5776c --- /dev/null +++ b/sysdeps/i386/multiarch/rawmemchr-sse2-bsf.S @@ -0,0 +1,3 @@ +#define USE_AS_RAWMEMCHR +#define MEMCHR __rawmemchr_sse2_bsf +#include "memchr-sse2-bsf.S" diff --git a/sysdeps/i386/multiarch/rawmemchr-sse2.S b/sysdeps/i386/multiarch/rawmemchr-sse2.S new file mode 100644 index 0000000000..038c74896b --- /dev/null +++ b/sysdeps/i386/multiarch/rawmemchr-sse2.S @@ -0,0 +1,3 @@ +#define USE_AS_RAWMEMCHR +#define MEMCHR __rawmemchr_sse2 +#include "memchr-sse2.S" diff --git a/sysdeps/i386/multiarch/rawmemchr.S b/sysdeps/i386/multiarch/rawmemchr.S new file mode 100644 index 0000000000..27cc9f3b8b --- /dev/null +++ b/sysdeps/i386/multiarch/rawmemchr.S @@ -0,0 +1,65 @@ +/* Multiple versions of rawmemchr + All versions must be listed in ifunc-impl-list.c. + Copyright (C) 2011-2015 Free Software Foundation, Inc. + Contributed by Intel Corporation. + 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 + . */ + +#include +#include + +#if IS_IN (libc) + .text +ENTRY(__rawmemchr) + .type __rawmemchr, @gnu_indirect_function + LOAD_GOT_AND_RTLD_GLOBAL_RO + HAS_CPU_FEATURE (SSE2) + jz 2f + HAS_ARCH_FEATURE (Slow_BSF) + jz 3f + + LOAD_FUNC_GOT_EAX (__rawmemchr_sse2) + ret + +2: LOAD_FUNC_GOT_EAX (__rawmemchr_i386) + ret + +3: LOAD_FUNC_GOT_EAX (__rawmemchr_sse2_bsf) + ret +END(__rawmemchr) + +weak_alias(__rawmemchr, rawmemchr) + +# undef ENTRY +# define ENTRY(name) \ + .type __rawmemchr_i386, @function; \ + .globl __rawmemchr_i386; \ + .p2align 4; \ + __rawmemchr_i386: cfi_startproc; \ + CALL_MCOUNT +# undef END +# define END(name) \ + cfi_endproc; .size __rawmemchr_i386, .-__rawmemchr_i386 + +# undef libc_hidden_def +/* IFUNC doesn't work with the hidden functions in shared library since + they will be called without setting up EBX needed for PLT which is + used by IFUNC. */ +# define libc_hidden_def(name) \ + .globl __GI___rawmemchr; __GI___rawmemchr = __rawmemchr_i386 + +#endif +#include diff --git a/sysdeps/i386/multiarch/rtld-rawmemchr.S b/sysdeps/i386/multiarch/rtld-rawmemchr.S new file mode 100644 index 0000000000..9d5c19632d --- /dev/null +++ b/sysdeps/i386/multiarch/rtld-rawmemchr.S @@ -0,0 +1,20 @@ +/* rawmemchr for ld.so + Copyright (C) 2015 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 + . */ + +#include +#include -- cgit 1.4.1