From 64ef2bf86dd385e17ce74ac9a18c73ba801af58f Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Fri, 28 Sep 2012 07:02:42 -0700 Subject: [PATCH 2/6] Add i686 multiarch __libc_func --- ChangeLog.test-ifunc | 12 + sysdeps/i386/i686/multiarch/bcopy.S | 2 + sysdeps/i386/i686/multiarch/bzero.S | 2 + sysdeps/i386/i686/multiarch/libc-func.c | 995 ++++++++++++++++++++++++++++++++ sysdeps/i386/i686/multiarch/memcmp.S | 2 + sysdeps/i386/i686/multiarch/memcpy.S | 2 + sysdeps/i386/i686/multiarch/memmove.S | 2 + sysdeps/i386/i686/multiarch/mempcpy.S | 2 + sysdeps/i386/i686/multiarch/strcat.S | 2 + sysdeps/i386/i686/multiarch/strcmp.S | 2 + sysdeps/i386/i686/multiarch/strcpy.S | 2 + 11 files changed, 1025 insertions(+) create mode 100644 sysdeps/i386/i686/multiarch/libc-func.c diff --git a/ChangeLog.test-ifunc b/ChangeLog.test-ifunc index d87a641..7867b0e 100644 --- a/ChangeLog.test-ifunc +++ b/ChangeLog.test-ifunc @@ -1,5 +1,17 @@ 2012-09-26 H.J. Lu + * sysdeps/i386/i686/multiarch/bcopy.S (__bcopy_ia32): Make it + global and hidden. + * sysdeps/i386/i686/multiarch/bzero.S (__bzero_ia32): Likewise. + * sysdeps/i386/i686/multiarch/memcmp.S (__memcmp_ia32): Likewise. + * sysdeps/i386/i686/multiarch/memcpy.S (__memcpy_ia32): Likewise. + * sysdeps/i386/i686/multiarch/memmove.S (__memmove_ia32): Likewise. + * sysdeps/i386/i686/multiarch/mempcpy.S (__mempcpy_ia32): Likewise. + * sysdeps/i386/i686/multiarch/strcat.S (STRCAT_IA32): Likewise. + * sysdeps/i386/i686/multiarch/strcmp.S (__STRCMP_IA32): Likewise. + * sysdeps/i386/i686/multiarch/strcpy.S (STRCPY_IA32): Likewise. + * sysdeps/i386/i686/multiarch/libc-func.c: New file. + * Rules (tests): Filter out $(tests-ifunc) if multi-arch isn't enabled. (xtests): Filter out $(xtests-ifunc) if multi-arch isn't enabled. diff --git a/sysdeps/i386/i686/multiarch/bcopy.S b/sysdeps/i386/i686/multiarch/bcopy.S index 9db3424..ca507b0 100644 --- a/sysdeps/i386/i686/multiarch/bcopy.S +++ b/sysdeps/i386/i686/multiarch/bcopy.S @@ -67,6 +67,8 @@ END(bcopy) # define ENTRY(name) \ .type __bcopy_ia32, @function; \ .p2align 4; \ + .globl __bcopy_ia32; \ + .hidden __bcopy_ia32; \ __bcopy_ia32: cfi_startproc; \ CALL_MCOUNT # undef END diff --git a/sysdeps/i386/i686/multiarch/bzero.S b/sysdeps/i386/i686/multiarch/bzero.S index 86db169..2226e7a 100644 --- a/sysdeps/i386/i686/multiarch/bzero.S +++ b/sysdeps/i386/i686/multiarch/bzero.S @@ -67,6 +67,8 @@ END(__bzero) # define ENTRY(name) \ .type __bzero_ia32, @function; \ .p2align 4; \ + .globl __bzero_ia32; \ + .hidden __bzero_ia32; \ __bzero_ia32: cfi_startproc; \ CALL_MCOUNT # undef END diff --git a/sysdeps/i386/i686/multiarch/libc-func.c b/sysdeps/i386/i686/multiarch/libc-func.c new file mode 100644 index 0000000..864a4f9 --- /dev/null +++ b/sysdeps/i386/i686/multiarch/libc-func.c @@ -0,0 +1,995 @@ +/* Copyright (C) 2012 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 +#include +#include +#include +#include "init-arch.h" + +#define find_memcmp(array, max) 0 +#define find_memchr(array, max) 0 +#define find_memrchr(array, max) 0 +#define find_rawmemchr(array, max) 0 +#define find_memcpy(array, max) 0 +#define find_memmove(array, max) 0 +#define find_mempcpy(array, max) 0 +#define find___memcpy_chk(array, max) 0 +#define find___memmove_chk(array, max) 0 +#define find___mempcpy_chk(array, max) 0 +#define find_memset(array, max) 0 +#define find_stpcpy(array, max) 0 +#define find_stpncpy(array, max) 0 +#define find_strcpy(array, max) 0 +#define find_strncpy(array, max) 0 +#define find_strcasecmp(array, max) 0 +#define find_strcasecmp_l(array, max) 0 +#define find_strncasecmp(array, max) 0 +#define find_strncasecmp_l(array, max) 0 +#define find_strcasestr(array, max) 0 +#define find_strcat(array, max) 0 +#define find_strncat(array, max) 0 +#define find_strchr(array, max) 0 +#define find_strrchr(array, max) 0 +#define find_strcmp(array, max) 0 +#define find_strncmp(array, max) 0 +#define find_strcspn(array, max) 0 +#define find_strlen(array, max) 0 +#define find_strnlen(array, max) 0 +#define find_strpbrk(array, max) 0 +#define find_strspn(array, max) 0 +#define find_strstr(array, max) 0 +#define find_wcschr(array, max) 0 +#define find_wcscmp(array, max) 0 +#define find_wcscpy(array, max) 0 +#define find_wcslen(array, max) 0 +#define find_wcsrchr(array, max) 0 +#define find_wmemcmp(array, max) 0 + +#ifndef NOT_IN_libc + +extern __typeof (memmove) __memmove_ia32 attribute_hidden; +extern __typeof (memmove) __memmove_ssse3 attribute_hidden; +extern __typeof (memmove) __memmove_ssse3_rep attribute_hidden; + +# undef find_memmove + +static int +find_memmove (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__memmove_ssse3_rep); + array[i + 1] = LIBC_FUNC_INIT (__memmove_ssse3); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__memmove_ia32); + return i + 1; +} + +extern void *__memmove_chk (void *, const void *, size_t, size_t); +extern __typeof (__memmove_chk) __memmove_chk_ia32 attribute_hidden; +extern __typeof (__memmove_chk) __memmove_chk_ssse3 attribute_hidden; +extern __typeof (__memmove_chk) __memmove_chk_ssse3_rep attribute_hidden; + +# undef find___memmove_chk + +static int +find___memmove_chk (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__memmove_chk_ssse3_rep); + array[i + 1] = LIBC_FUNC_INIT (__memmove_chk_ssse3); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__memmove_chk_ia32); + return i + 1; +} + +extern __typeof (memchr) __memchr_ia32 attribute_hidden; +extern __typeof (memchr) __memchr_sse2 attribute_hidden; +extern __typeof (memchr) __memchr_sse2_bsf attribute_hidden; + +# undef find_memchr + +static int +find_memchr (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__memchr_sse2_bsf); + array[i + 1] = LIBC_FUNC_INIT (__memchr_sse2); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__memchr_ia32); + return i + 1; +} + +extern __typeof (memrchr) __memrchr_ia32 attribute_hidden; +extern __typeof (memrchr) __memrchr_sse2 attribute_hidden; +extern __typeof (memrchr) __memrchr_sse2_bsf attribute_hidden; + +# undef find_memrchr + +static int +find_memrchr (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__memrchr_sse2_bsf); + array[i + 1] = LIBC_FUNC_INIT (__memrchr_sse2); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__memrchr_ia32); + return i + 1; +} + +extern __typeof (rawmemchr) __rawmemchr_ia32 attribute_hidden; +extern __typeof (rawmemchr) __rawmemchr_sse2 attribute_hidden; +extern __typeof (rawmemchr) __rawmemchr_sse2_bsf attribute_hidden; + +# undef find_rawmemchr + +static int +find_rawmemchr (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__rawmemchr_sse2_bsf); + array[i + 1] = LIBC_FUNC_INIT (__rawmemchr_sse2); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__rawmemchr_ia32); + return i + 1; +} + +extern __typeof (memcmp) __memcmp_ia32 attribute_hidden; +extern __typeof (memcmp) __memcmp_ssse3 attribute_hidden; +extern __typeof (memcmp) __memcmp_sse4_2 attribute_hidden; + +# undef find_memcmp + +static int +find_memcmp (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__memcmp_sse4_2); + i++; + } + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__memcmp_ssse3); + i++; + } + array[i] = LIBC_FUNC_INIT (__memcmp_ia32); + return i + 1; +} + +extern __typeof (memset) __memset_ia32 attribute_hidden; +extern __typeof (memset) __memset_sse2 attribute_hidden; +extern __typeof (memset) __memset_sse2_rep attribute_hidden; + +# undef find_memset + +static int +find_memset (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__memset_sse2_rep); + array[i + 1] = LIBC_FUNC_INIT (__memset_sse2); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__memset_ia32); + return i + 1; +} + +extern __typeof (stpcpy) __stpcpy_ia32 attribute_hidden; +extern __typeof (stpcpy) __stpcpy_sse2 attribute_hidden; +extern __typeof (stpcpy) __stpcpy_ssse3 attribute_hidden; + +# undef find_stpcpy + +static int +find_stpcpy (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__stpcpy_ssse3); + i++; + } + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__stpcpy_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__stpcpy_ia32); + return i + 1; +} + +extern __typeof (stpncpy) __stpncpy_ia32 attribute_hidden; +extern __typeof (stpncpy) __stpncpy_sse2 attribute_hidden; +extern __typeof (stpncpy) __stpncpy_ssse3 attribute_hidden; + +# undef find_stpncpy + +static int +find_stpncpy (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__stpncpy_ssse3); + i++; + } + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__stpncpy_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__stpncpy_ia32); + return i + 1; +} + +extern __typeof (strcpy) __strcpy_ia32 attribute_hidden; +extern __typeof (strcpy) __strcpy_sse2 attribute_hidden; +extern __typeof (strcpy) __strcpy_ssse3 attribute_hidden; + +# undef find_strcpy + +static int +find_strcpy (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strcpy_ssse3); + i++; + } + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__strcpy_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__strcpy_ia32); + return i + 1; +} + +extern __typeof (strncpy) __strncpy_ia32 attribute_hidden; +extern __typeof (strncpy) __strncpy_sse2 attribute_hidden; +extern __typeof (strncpy) __strncpy_ssse3 attribute_hidden; + +# undef find_strncpy + +static int +find_strncpy (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strncpy_ssse3); + i++; + } + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__strncpy_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__strncpy_ia32); + return i + 1; +} + +extern __typeof (strcasecmp) __strcasecmp_ia32 attribute_hidden; +extern __typeof (strcasecmp) __strcasecmp_ssse3 attribute_hidden; +extern __typeof (strcasecmp) __strcasecmp_sse4_2 attribute_hidden; + +# undef find_strcasecmp + +static int +find_strcasecmp (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strcasecmp_sse4_2); + i++; + } + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strcasecmp_ssse3); + i++; + } + array[i] = LIBC_FUNC_INIT (__strcasecmp_ia32); + return i + 1; +} + +extern __typeof (strcasecmp_l) __strcasecmp_l_ia32 attribute_hidden; +extern __typeof (strcasecmp_l) __strcasecmp_l_ssse3 attribute_hidden; +extern __typeof (strcasecmp_l) __strcasecmp_l_sse4_2 attribute_hidden; + +# undef find_strcasecmp_l + +static int +find_strcasecmp_l (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strcasecmp_l_sse4_2); + i++; + } + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strcasecmp_l_ssse3); + i++; + } + array[i] = LIBC_FUNC_INIT (__strcasecmp_l_ia32); + return i + 1; +} + +extern __typeof (strncasecmp) __strncasecmp_ia32 attribute_hidden; +extern __typeof (strncasecmp) __strncasecmp_ssse3 attribute_hidden; +extern __typeof (strncasecmp) __strncasecmp_sse4_2 attribute_hidden; + +# undef find_strncasecmp + +static int +find_strncasecmp (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strncasecmp_sse4_2); + i++; + } + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strncasecmp_ssse3); + i++; + } + array[i] = LIBC_FUNC_INIT (__strncasecmp_ia32); + return i + 1; +} + +extern __typeof (strncasecmp_l) __strncasecmp_l_ia32 attribute_hidden; +extern __typeof (strncasecmp_l) __strncasecmp_l_ssse3 attribute_hidden; +extern __typeof (strncasecmp_l) __strncasecmp_l_sse4_2 attribute_hidden; + +# undef find_strncasecmp_l + +static int +find_strncasecmp_l (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strncasecmp_l_sse4_2); + i++; + } + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strncasecmp_l_ssse3); + i++; + } + array[i] = LIBC_FUNC_INIT (__strncasecmp_l_ia32); + return i + 1; +} + +extern __typeof (strcasestr) __strcasestr_ia32 attribute_hidden; +extern __typeof (strcasestr) __strcasestr_sse42 attribute_hidden; + +# undef find_strcasestr + +static int +find_strcasestr (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strcasestr_sse42); + i++; + } + array[i] = LIBC_FUNC_INIT (__strcasestr_ia32); + return i + 1; +} + +extern __typeof (strcat) __strcat_ia32 attribute_hidden; +extern __typeof (strcat) __strcat_sse2 attribute_hidden; +extern __typeof (strcat) __strcat_ssse3 attribute_hidden; + +# undef find_strcat + +static int +find_strcat (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strcat_ssse3); + i++; + } + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__strcat_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__strcat_ia32); + return i + 1; +} + +extern __typeof (strncat) __strncat_ia32 attribute_hidden; +extern __typeof (strncat) __strncat_sse2 attribute_hidden; +extern __typeof (strncat) __strncat_ssse3 attribute_hidden; + +# undef find_strncat + +static int +find_strncat (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strncat_ssse3); + i++; + } + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__strncat_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__strncat_ia32); + return i + 1; +} + +extern __typeof (strchr) __strchr_ia32 attribute_hidden; +extern __typeof (strchr) __strchr_sse2 attribute_hidden; +extern __typeof (strchr) __strchr_sse2_bsf attribute_hidden; + +# undef find_strchr + +static int +find_strchr (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__strchr_sse2_bsf); + array[i + 1] = LIBC_FUNC_INIT (__strchr_sse2); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__strchr_ia32); + return i + 1; +} + +extern __typeof (strrchr) __strrchr_ia32 attribute_hidden; +extern __typeof (strrchr) __strrchr_sse2 attribute_hidden; +extern __typeof (strrchr) __strrchr_sse2_bsf attribute_hidden; + +# undef find_strrchr + +static int +find_strrchr (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__strrchr_sse2_bsf); + array[i + 1] = LIBC_FUNC_INIT (__strrchr_sse2); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__strrchr_ia32); + return i + 1; +} + +extern __typeof (strcmp) __strcmp_ia32 attribute_hidden; +extern __typeof (strcmp) __strcmp_ssse3 attribute_hidden; +extern __typeof (strcmp) __strcmp_sse4_2 attribute_hidden; + +# undef find_strcmp + +static int +find_strcmp (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strcmp_sse4_2); + i++; + } + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strcmp_ssse3); + i++; + } + array[i] = LIBC_FUNC_INIT (__strcmp_ia32); + return i + 1; +} + +extern __typeof (strcspn) __strcspn_ia32 attribute_hidden; +extern __typeof (strcspn) __strcspn_sse42 attribute_hidden; + +# undef find_strcspn + +static int +find_strcspn (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strcspn_sse42); + i++; + } + array[i] = LIBC_FUNC_INIT (__strcspn_ia32); + return i + 1; +} + +extern __typeof (strnlen) __strnlen_ia32 attribute_hidden; +extern __typeof (strnlen) __strnlen_sse2 attribute_hidden; + +# undef find_strnlen + +static int +find_strnlen (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__strnlen_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__strnlen_ia32); + return i + 1; +} + +extern __typeof (strpbrk) __strpbrk_ia32 attribute_hidden; +extern __typeof (strpbrk) __strpbrk_sse42 attribute_hidden; + +# undef find_strpbrk + +static int +find_strpbrk (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strpbrk_sse42); + i++; + } + array[i] = LIBC_FUNC_INIT (__strpbrk_ia32); + return i + 1; +} + +extern __typeof (strspn) __strspn_ia32 attribute_hidden; +extern __typeof (strspn) __strspn_sse42 attribute_hidden; + +# undef find_strspn + +static int +find_strspn (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strspn_sse42); + i++; + } + array[i] = LIBC_FUNC_INIT (__strspn_ia32); + return i + 1; +} + +extern __typeof (strstr) __strstr_ia32 attribute_hidden; +extern __typeof (strstr) __strstr_sse42 attribute_hidden; + +# undef find_strstr + +static int +find_strstr (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strstr_sse42); + i++; + } + array[i] = LIBC_FUNC_INIT (__strstr_ia32); + return i + 1; +} + +extern __typeof (wcschr) __wcschr_ia32 attribute_hidden; +extern __typeof (wcschr) __wcschr_sse2 attribute_hidden; + +# undef find_wcschr + +static int +find_wcschr (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__wcschr_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__wcschr_ia32); + return i + 1; +} + +extern __typeof (wcscmp) __wcscmp_ia32 attribute_hidden; +extern __typeof (wcscmp) __wcscmp_sse2 attribute_hidden; + +# undef find_wcscmp + +static int +find_wcscmp (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__wcscmp_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__wcscmp_ia32); + return i + 1; +} + +extern __typeof (wcscpy) __wcscpy_ia32 attribute_hidden; +extern __typeof (wcscpy) __wcscpy_ssse3 attribute_hidden; + +# undef find_wcscpy + +static int +find_wcscpy (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__wcscpy_ssse3); + i++; + } + array[i] = LIBC_FUNC_INIT (__wcscpy_ia32); + return i + 1; +} + +extern __typeof (wcslen) __wcslen_ia32 attribute_hidden; +extern __typeof (wcslen) __wcslen_sse2 attribute_hidden; + +# undef find_wcslen + +static int +find_wcslen (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__wcslen_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__wcslen_ia32); + return i + 1; +} + +extern __typeof (wcsrchr) __wcsrchr_ia32 attribute_hidden; +extern __typeof (wcsrchr) __wcsrchr_sse2 attribute_hidden; + +# undef find_wcsrchr + +static int +find_wcsrchr (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__wcsrchr_sse2); + i++; + } + array[i] = LIBC_FUNC_INIT (__wcsrchr_ia32); + return i + 1; +} + +extern __typeof (wmemcmp) __wmemcmp_ia32 attribute_hidden; +extern __typeof (wmemcmp) __wmemcmp_ssse3 attribute_hidden; +extern __typeof (wmemcmp) __wmemcmp_sse4_2 attribute_hidden; + +# undef find_wmemcmp + +static int +find_wmemcmp (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__wmemcmp_sse4_2); + i++; + } + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__wmemcmp_ssse3); + i++; + } + array[i] = LIBC_FUNC_INIT (__wmemcmp_ia32); + return i + 1; +} + +# ifdef SHARED +extern __typeof (memcpy) __memcpy_ia32 attribute_hidden; +extern __typeof (memcpy) __memcpy_ssse3 attribute_hidden; +extern __typeof (memcpy) __memcpy_ssse3_rep attribute_hidden; + +# undef find_memcpy + +static int +find_memcpy (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__memcpy_ssse3_rep); + array[i + 1] = LIBC_FUNC_INIT (__memcpy_ssse3); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__memcpy_ia32); + return i + 1; +} + +extern __typeof (mempcpy) __mempcpy_ia32 attribute_hidden; +extern __typeof (mempcpy) __mempcpy_ssse3 attribute_hidden; +extern __typeof (mempcpy) __mempcpy_ssse3_rep attribute_hidden; + +# undef find_mempcpy + +static int +find_mempcpy (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__mempcpy_ssse3_rep); + array[i + 1] = LIBC_FUNC_INIT (__mempcpy_ssse3); + i += 2; + } + else + i = 0; + array[i] = LIBC_FUNC_INIT (__mempcpy_ia32); + return i + 1; +} + +extern void *__memcpy_chk (void *, const void *, size_t, size_t); +extern __typeof (__memcpy_chk) __memcpy_chk_ia32 attribute_hidden; +extern __typeof (__memcpy_chk) __memcpy_chk_ssse3 attribute_hidden; +extern __typeof (__memcpy_chk) __memcpy_chk_ssse3_rep attribute_hidden; + +# undef find___memcpy_chk + +static int +find___memcpy_chk (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__memcpy_chk_ssse3_rep); + array[i + 1] = LIBC_FUNC_INIT (__memcpy_chk_ssse3); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__memcpy_chk_ia32); + return i + 1; +} + +extern void *__mempcpy_chk (void *, const void *, size_t, size_t); +extern __typeof (__mempcpy_chk) __mempcpy_chk_ia32 attribute_hidden; +extern __typeof (__mempcpy_chk) __mempcpy_chk_ssse3 attribute_hidden; +extern __typeof (__mempcpy_chk) __mempcpy_chk_ssse3_rep attribute_hidden; + +# undef find___mempcpy_chk + +static int +find___mempcpy_chk (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__mempcpy_chk_ssse3_rep); + array[i + 1] = LIBC_FUNC_INIT (__mempcpy_chk_ssse3); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__mempcpy_chk_ia32); + return i + 1; +} + +extern __typeof (strlen) __strlen_ia32 attribute_hidden; +extern __typeof (strlen) __strlen_sse2 attribute_hidden; +extern __typeof (strlen) __strlen_sse2_bsf attribute_hidden; + +# undef find_strlen + +static int +find_strlen (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE2) + { + array[i] = LIBC_FUNC_INIT (__strlen_sse2_bsf); + array[i + 1] = LIBC_FUNC_INIT (__strlen_sse2); + i += 2; + } + array[i] = LIBC_FUNC_INIT (__strlen_ia32); + return i + 1; +} + +extern __typeof (strncmp) __strncmp_ia32 attribute_hidden; +extern __typeof (strncmp) __strncmp_ssse3 attribute_hidden; +extern __typeof (strncmp) __strncmp_sse4_2 attribute_hidden; + +# undef find_strncmp + +static int +find_strncmp (struct libc_func_test *array, int max) +{ + size_t i = 0; + if (HAS_SSE4_2) + { + array[i] = LIBC_FUNC_INIT (__strncmp_sse4_2); + i++; + } + if (HAS_SSSE3) + { + array[i] = LIBC_FUNC_INIT (__strncmp_ssse3); + i++; + } + array[i] = LIBC_FUNC_INIT (__strncmp_ia32); + return i + 1; +} +# endif /* SHARED */ +#endif /* NOT_IN_libc */ + +/* Maximum number of IFUNC implementations. */ +#define MAX_IFUNC 3 + +/* Fill ARRAY of MAX elements with IFUNC implementations for function + NAME supported on target machine and return the number of valid + entries. */ + +int +__libc_func (const char *name, struct libc_func_test *array, int max) +{ + assert (max >= MAX_IFUNC); + + if (strcmp (name, "memcmp") == 0) + return find_memcmp (array, max); + + if (strcmp (name, "memchr") == 0) + return find_memchr (array, max); + + if (strcmp (name, "memrchr") == 0) + return find_memrchr (array, max); + + if (strcmp (name, "rawmemchr") == 0) + return find_rawmemchr (array, max); + + if (strcmp (name, "memcpy") == 0) + return find_memcpy (array, max); + + if (strcmp (name, "memmove") == 0) + return find_memmove (array, max); + + if (strcmp (name, "mempcpy") == 0) + return find_mempcpy (array, max); + + if (strcmp (name, "__memcpy_chk") == 0) + return find___memcpy_chk (array, max); + + if (strcmp (name, "__memmove_chk") == 0) + return find___memmove_chk (array, max); + + if (strcmp (name, "__mempcpy_chk") == 0) + return find___mempcpy_chk (array, max); + + if (strcmp (name, "memset") == 0) + return find_memset (array, max); + + if (strcmp (name, "stpcpy") == 0) + return find_stpcpy (array, max); + + if (strcmp (name, "stpncpy") == 0) + return find_stpncpy (array, max); + + if (strcmp (name, "strcpy") == 0) + return find_strcpy (array, max); + + if (strcmp (name, "strncpy") == 0) + return find_strncpy (array, max); + + if (strcmp (name, "strcasecmp") == 0) + return find_strcasecmp (array, max); + + if (strcmp (name, "strcasecmp_l") == 0) + return find_strcasecmp_l (array, max); + + if (strcmp (name, "strncasecmp") == 0) + return find_strncasecmp (array, max); + + if (strcmp (name, "strncasecmp_l") == 0) + return find_strncasecmp_l (array, max); + + if (strcmp (name, "strcasestr") == 0) + return find_strcasestr (array, max); + + if (strcmp (name, "strcat") == 0) + return find_strcat (array, max); + + if (strcmp (name, "strncat") == 0) + return find_strncat (array, max); + + if (strcmp (name, "strcmp") == 0) + return find_strcmp (array, max); + + if (strcmp (name, "strncmp") == 0) + return find_strncmp (array, max); + + if (strcmp (name, "strchr") == 0) + return find_strchr (array, max); + + if (strcmp (name, "strrchr") == 0) + return find_strrchr (array, max); + + if (strcmp (name, "strcspn") == 0) + return find_strcspn (array, max); + + if (strcmp (name, "strlen") == 0) + return find_strlen (array, max); + + if (strcmp (name, "strnlen") == 0) + return find_strnlen (array, max); + + if (strcmp (name, "strpbrk") == 0) + return find_strpbrk (array, max); + + if (strcmp (name, "strspn") == 0) + return find_strspn (array, max); + + if (strcmp (name, "strstr") == 0) + return find_strstr (array, max); + + if (strcmp (name, "wcschr") == 0) + return find_wcschr (array, max); + + if (strcmp (name, "wcscmp") == 0) + return find_wcscmp (array, max); + + if (strcmp (name, "wcscpy") == 0) + return find_wcscpy (array, max); + + if (strcmp (name, "wcslen") == 0) + return find_wcslen (array, max); + + if (strcmp (name, "wcsrchr") == 0) + return find_wcsrchr (array, max); + + if (strcmp (name, "wmemcmp") == 0) + return find_wmemcmp (array, max); + + return 0; +} diff --git a/sysdeps/i386/i686/multiarch/memcmp.S b/sysdeps/i386/i686/multiarch/memcmp.S index d8076b9..2756f0c 100644 --- a/sysdeps/i386/i686/multiarch/memcmp.S +++ b/sysdeps/i386/i686/multiarch/memcmp.S @@ -67,6 +67,8 @@ END(memcmp) # define ENTRY(name) \ .type __memcmp_ia32, @function; \ .p2align 4; \ + .globl __memcmp_ia32; \ + .hidden __memcmp_ia32; \ __memcmp_ia32: cfi_startproc; \ CALL_MCOUNT # undef END diff --git a/sysdeps/i386/i686/multiarch/memcpy.S b/sysdeps/i386/i686/multiarch/memcpy.S index 558c04f..646e039 100644 --- a/sysdeps/i386/i686/multiarch/memcpy.S +++ b/sysdeps/i386/i686/multiarch/memcpy.S @@ -51,6 +51,8 @@ END(memcpy) # define ENTRY(name) \ .type __memcpy_ia32, @function; \ .p2align 4; \ + .globl __memcpy_ia32; \ + .hidden __memcpy_ia32; \ __memcpy_ia32: cfi_startproc; \ CALL_MCOUNT # undef END diff --git a/sysdeps/i386/i686/multiarch/memmove.S b/sysdeps/i386/i686/multiarch/memmove.S index b8892c0..de452e3 100644 --- a/sysdeps/i386/i686/multiarch/memmove.S +++ b/sysdeps/i386/i686/multiarch/memmove.S @@ -50,6 +50,8 @@ END(memmove) # define ENTRY(name) \ .type __memmove_ia32, @function; \ .p2align 4; \ + .globl __memmove_ia32; \ + .hidden __memmove_ia32; \ __memmove_ia32: cfi_startproc; \ CALL_MCOUNT # else diff --git a/sysdeps/i386/i686/multiarch/mempcpy.S b/sysdeps/i386/i686/multiarch/mempcpy.S index 95bda46..224fbe4 100644 --- a/sysdeps/i386/i686/multiarch/mempcpy.S +++ b/sysdeps/i386/i686/multiarch/mempcpy.S @@ -51,6 +51,8 @@ END(__mempcpy) # define ENTRY(name) \ .type __mempcpy_ia32, @function; \ .p2align 4; \ + .globl __mempcpy_ia32; \ + .hidden __mempcpy_ia32; \ __mempcpy_ia32: cfi_startproc; \ CALL_MCOUNT # undef END diff --git a/sysdeps/i386/i686/multiarch/strcat.S b/sysdeps/i386/i686/multiarch/strcat.S index e68feca..4bfa21d 100644 --- a/sysdeps/i386/i686/multiarch/strcat.S +++ b/sysdeps/i386/i686/multiarch/strcat.S @@ -94,6 +94,8 @@ END(STRCAT) # define ENTRY(name) \ .type STRCAT_IA32, @function; \ .align 16; \ + .globl STRCAT_IA32; \ + .hidden STRCAT_IA32; \ STRCAT_IA32: cfi_startproc; \ CALL_MCOUNT # undef END diff --git a/sysdeps/i386/i686/multiarch/strcmp.S b/sysdeps/i386/i686/multiarch/strcmp.S index b3b9eb8..a94cd5b 100644 --- a/sysdeps/i386/i686/multiarch/strcmp.S +++ b/sysdeps/i386/i686/multiarch/strcmp.S @@ -95,6 +95,8 @@ END(STRCMP) # define ENTRY(name) \ .type __STRCMP_IA32, @function; \ .p2align 4; \ + .globl __STRCMP_IA32; \ + .hidden __STRCMP_IA32; \ __STRCMP_IA32: cfi_startproc; \ CALL_MCOUNT # undef END diff --git a/sysdeps/i386/i686/multiarch/strcpy.S b/sysdeps/i386/i686/multiarch/strcpy.S index 71eee76..de940dc 100644 --- a/sysdeps/i386/i686/multiarch/strcpy.S +++ b/sysdeps/i386/i686/multiarch/strcpy.S @@ -110,6 +110,8 @@ END(STRCPY) # define ENTRY(name) \ .type STRCPY_IA32, @function; \ .align 16; \ + .globl STRCPY_IA32; \ + .hidden STRCPY_IA32; \ STRCPY_IA32: cfi_startproc; \ CALL_MCOUNT # undef END -- 1.7.11.4