1 /* Multiple versions of memset.
2    Copyright (C) 2013-2022 Free Software Foundation, Inc.
3    This file is part of the GNU C Library.
4 
5    The GNU C Library is free software; you can redistribute it and/or
6    modify it under the terms of the GNU Lesser General Public
7    License as published by the Free Software Foundation; either
8    version 2.1 of the License, or (at your option) any later version.
9 
10    The GNU C Library is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    Lesser General Public License for more details.
14 
15    You should have received a copy of the GNU Lesser General Public
16    License along with the GNU C Library; if not, see
17    <https://www.gnu.org/licenses/>.  */
18 
19 /* Define multiple versions only for definition in libc.  */
20 #if defined SHARED && IS_IN (libc)
21 /* Redefine memset so that the compiler won't complain about the type
22    mismatch with the IFUNC selector in strong_alias, below.  */
23 # undef memset
24 # define memset __redirect_memset
25 # include <string.h>
26 # include <shlib-compat.h>
27 # include "init-arch.h"
28 
29 extern __typeof (__redirect_memset) __libc_memset;
30 
31 extern __typeof (__redirect_memset) __memset_ppc attribute_hidden;
32 extern __typeof (__redirect_memset) __memset_power4 attribute_hidden;
33 extern __typeof (__redirect_memset) __memset_power6 attribute_hidden;
34 extern __typeof (__redirect_memset) __memset_power7 attribute_hidden;
35 extern __typeof (__redirect_memset) __memset_power8 attribute_hidden;
36 # ifdef __LITTLE_ENDIAN__
37 extern __typeof (__redirect_memset) __memset_power10 attribute_hidden;
38 # endif
39 
40 /* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
41    ifunc symbol properly.  */
42 libc_ifunc (__libc_memset,
43 # ifdef __LITTLE_ENDIAN__
44 	    (hwcap2 & PPC_FEATURE2_ARCH_3_1
45 	     && hwcap2 & PPC_FEATURE2_HAS_ISEL
46 	     && hwcap & PPC_FEATURE_HAS_VSX
47 	     && GLRO(dl_cache_line_size) == 128)
48 	    ? __memset_power10 :
49 # endif
50             (hwcap2 & PPC_FEATURE2_ARCH_2_07
51 	     && hwcap & PPC_FEATURE_HAS_ALTIVEC
52 	     && GLRO(dl_cache_line_size) == 128)
53             ? __memset_power8 :
54 	      (hwcap & PPC_FEATURE_ARCH_2_06
55 	       && GLRO(dl_cache_line_size) == 128)
56 	      ? __memset_power7 :
57 		(hwcap & PPC_FEATURE_ARCH_2_05
58 	         && GLRO(dl_cache_line_size) == 128)
59 		? __memset_power6 :
60 		  (hwcap & PPC_FEATURE_POWER4
61 	           && GLRO(dl_cache_line_size) == 128)
62 		  ? __memset_power4
63             : __memset_ppc);
64 
65 #undef memset
66 strong_alias (__libc_memset, memset);
67 libc_hidden_ver (__libc_memset, memset);
68 #endif
69