string: Add libc_hidden_proto for memrchr

Although static linker can optimize it to local call, it follows the
internal scheme to provide hidden proto and definitions.

Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
This commit is contained in:
Adhemerval Zanella 2023-02-06 15:05:56 -03:00
parent 7ea510127e
commit 22999b2f0f
15 changed files with 45 additions and 18 deletions

View File

@ -119,6 +119,7 @@ extern __typeof (memmem) __memmem;
libc_hidden_proto (__memmem)
libc_hidden_proto (__ffs)
libc_hidden_proto (__strerror_l)
libc_hidden_proto (__memrchr)
#if IS_IN (libc)
/* Avoid hidden reference to IFUNC symbol __explicit_bzero_chk. */

View File

@ -75,5 +75,6 @@ __memrchr (const void *s, int c_in, size_t n)
return NULL;
}
#ifndef MEMRCHR
libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
#endif

View File

@ -123,5 +123,6 @@ L(nomatch):
ret
END (__memrchr)
libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
libc_hidden_builtin_def (memrchr)

View File

@ -720,4 +720,5 @@ L(ret_null):
ret
END (__memrchr_sse2)
strong_alias (__memrchr_sse2, __GI___memrchr)
#endif

View File

@ -20,8 +20,10 @@
/* Define multiple versions only for the definition in libc. */
#if IS_IN (libc)
# define memrchr __redirect_memrchr
# define __memrchr __redirect___memrchr
# include <string.h>
# undef memrchr
# undef __memrchr
# define SYMBOL_NAME memrchr
# include "ifunc-sse2-bsf.h"

View File

@ -23,3 +23,13 @@ extern void *__memrchr_ppc (const void *, int, size_t);
#endif
#include <string/memrchr.c>
# if IS_IN (libc)
# undef __memrchr
# ifdef SHARED
__hidden_ver1 (__memrchr_ppc, __GI___memrchr, __memrchr_ppc);
strong_alias (__memrchr_ppc, __memrchr_ppc1);
__hidden_ver1 (__memrchr_ppc1, __memrchr, __memrchr_ppc1);
# else
strong_alias (__memrchr_ppc, __memrchr)
# endif
#endif

View File

@ -17,21 +17,21 @@
<https://www.gnu.org/licenses/>. */
#if IS_IN (libc)
# define memrchr __redirect_memrchr
# include <string.h>
# include <shlib-compat.h>
# include "init-arch.h"
extern __typeof (__memrchr) __memrchr_ppc attribute_hidden;
extern __typeof (__memrchr) __memrchr_power7 attribute_hidden;
# undef memrchr
/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
ifunc symbol properly. */
libc_ifunc (__memrchr,
(hwcap & PPC_FEATURE_HAS_VSX)
? __memrchr_power7
: __memrchr_ppc);
weak_alias (__memrchr, memrchr)
libc_ifunc_redirected (__redirect_memrchr, memrchr,
(hwcap & PPC_FEATURE_HAS_VSX)
? __memrchr_power7
: __memrchr_ppc);
#else
#include <string/memrchr.c>
#endif

View File

@ -191,5 +191,6 @@ L(loop_small):
blr
END (__memrchr)
libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
libc_hidden_builtin_def (memrchr)

View File

@ -17,6 +17,7 @@
<https://www.gnu.org/licenses/>. */
#if IS_IN (libc)
# define memrchr __redirect_memrchr
# include <string.h>
# include <shlib-compat.h>
# include "init-arch.h"
@ -24,18 +25,17 @@
extern __typeof (__memrchr) __memrchr_ppc attribute_hidden;
extern __typeof (__memrchr) __memrchr_power7 attribute_hidden;
extern __typeof (__memrchr) __memrchr_power8 attribute_hidden;
# undef memrchr
/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
ifunc symbol properly. */
libc_ifunc (__memrchr,
(hwcap2 & PPC_FEATURE2_ARCH_2_07
&& hwcap & PPC_FEATURE_HAS_ALTIVEC)
? __memrchr_power8 :
(hwcap & PPC_FEATURE_ARCH_2_06)
? __memrchr_power7
: __memrchr_ppc);
weak_alias (__memrchr, memrchr)
libc_ifunc_redirected (__redirect_memrchr, memrchr,
(hwcap2 & PPC_FEATURE2_ARCH_2_07
&& hwcap & PPC_FEATURE_HAS_ALTIVEC)
? __memrchr_power8 :
(hwcap & PPC_FEATURE_ARCH_2_06)
? __memrchr_power7
: __memrchr_ppc);
#else
#include <string/memrchr.c>
#endif

View File

@ -196,5 +196,6 @@ L(loop_small):
blr
END (MEMRCHR)
libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
libc_hidden_builtin_def (memrchr)

View File

@ -332,5 +332,6 @@ L(loop_small):
blr
END (MEMRCHR)
libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
libc_hidden_builtin_def (memrchr)

View File

@ -24,4 +24,8 @@
# endif
# include <string/memrchr.c>
# if defined SHARED && IS_IN (libc)
__hidden_ver1 (__memrchr_c, __GI___memrchr, __memrchr_c);
# endif
#endif

View File

@ -19,18 +19,20 @@
#include <ifunc-memrchr.h>
#if HAVE_MEMRCHR_IFUNC
# define __memrchr __redirect_memrchr
# include <string.h>
# undef __memrchr
# include <ifunc-resolve.h>
# if HAVE_MEMRCHR_C
extern __typeof (__memrchr) MEMRCHR_C attribute_hidden;
extern __typeof (__redirect_memrchr) MEMRCHR_C attribute_hidden;
# endif
# if HAVE_MEMRCHR_Z13
extern __typeof (__memrchr) MEMRCHR_Z13 attribute_hidden;
extern __typeof (__redirect_memrchr) MEMRCHR_Z13 attribute_hidden;
# endif
s390_libc_ifunc_expr (__memrchr, __memrchr,
s390_libc_ifunc_expr (__redirect_memrchr, __memrchr,
(HAVE_MEMRCHR_Z13 && (hwcap & HWCAP_S390_VX))
? MEMRCHR_Z13
: MEMRCHR_DEFAULT

View File

@ -25,4 +25,5 @@
#include "isa-default-impl.h"
libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)

View File

@ -27,5 +27,6 @@
# include "ifunc-avx2.h"
libc_ifunc_redirected (__redirect_memrchr, __memrchr, IFUNC_SELECTOR ());
libc_hidden_def (__memrchr)
weak_alias (__memrchr, memrchr)
#endif