(root)/
glibc-2.38/
sysdeps/
powerpc/
powerpc32/
power4/
multiarch/
ifunc-impl-list.c
       1  /* Enumerate available IFUNC implementations of a function.  PowerPC32 version.
       2     Copyright (C) 2013-2023 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  #include <assert.h>
      20  #include <string.h>
      21  #include <wchar.h>
      22  #include <ldsodefs.h>
      23  #include <ifunc-impl-list.h>
      24  
      25  size_t
      26  __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
      27  			size_t max)
      28  {
      29    size_t i = max;
      30  
      31    unsigned long int hwcap = GLRO(dl_hwcap);
      32    /* hwcap contains only the latest supported ISA, the code checks which is
      33       and fills the previous supported ones.  */
      34    if (hwcap & PPC_FEATURE_ARCH_2_06)
      35      hwcap |= PPC_FEATURE_ARCH_2_05 | PPC_FEATURE_POWER5_PLUS |
      36               PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
      37    else if (hwcap & PPC_FEATURE_ARCH_2_05)
      38      hwcap |= PPC_FEATURE_POWER5_PLUS | PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
      39    else if (hwcap & PPC_FEATURE_POWER5_PLUS)
      40      hwcap |= PPC_FEATURE_POWER5 | PPC_FEATURE_POWER4;
      41    else if (hwcap & PPC_FEATURE_POWER5)
      42      hwcap |= PPC_FEATURE_POWER4;
      43  
      44  #ifdef SHARED
      45    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memcpy.c.  */
      46    IFUNC_IMPL (i, name, memcpy,
      47  	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_HAS_VSX,
      48  			      __memcpy_power7)
      49  	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_06,
      50  			      __memcpy_a2)
      51  	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_ARCH_2_05,
      52  			      __memcpy_power6)
      53  	      IFUNC_IMPL_ADD (array, i, memcpy, hwcap & PPC_FEATURE_CELL_BE,
      54  			      __memcpy_cell)
      55  	      IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ppc))
      56  
      57    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memmove.c.  */
      58    IFUNC_IMPL (i, name, memmove,
      59  	      IFUNC_IMPL_ADD (array, i, memmove, hwcap & PPC_FEATURE_HAS_VSX,
      60  			      __memmove_power7)
      61  	      IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_ppc))
      62  
      63    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memset.c.  */
      64    IFUNC_IMPL (i, name, memset,
      65  	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_HAS_VSX,
      66  			      __memset_power7)
      67  	      IFUNC_IMPL_ADD (array, i, memset, hwcap & PPC_FEATURE_ARCH_2_05,
      68  			      __memset_power6)
      69  	      IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ppc))
      70  
      71    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strlen.c.  */
      72    IFUNC_IMPL (i, name, strlen,
      73  	      IFUNC_IMPL_ADD (array, i, strlen, hwcap & PPC_FEATURE_HAS_VSX,
      74  			      __strlen_power7)
      75  	      IFUNC_IMPL_ADD (array, i, strlen, 1,
      76  			      __strlen_ppc))
      77  
      78    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strnlen.c.  */
      79    IFUNC_IMPL (i, name, strnlen,
      80  	      IFUNC_IMPL_ADD (array, i, strnlen, hwcap & PPC_FEATURE_HAS_VSX,
      81  			      __strnlen_power7)
      82  	      IFUNC_IMPL_ADD (array, i, strnlen, 1,
      83  			      __strnlen_ppc))
      84  #endif
      85  
      86    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memcmp.c.  */
      87    IFUNC_IMPL (i, name, memcmp,
      88  	      IFUNC_IMPL_ADD (array, i, memcmp, hwcap & PPC_FEATURE_HAS_VSX,
      89  			      __memcmp_power7)
      90  	      IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_ppc))
      91  
      92    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy.c.  */
      93    IFUNC_IMPL (i, name, mempcpy,
      94  	      IFUNC_IMPL_ADD (array, i, mempcpy,
      95  			      hwcap & PPC_FEATURE_HAS_VSX,
      96  			      __mempcpy_power7)
      97  	      IFUNC_IMPL_ADD (array, i, mempcpy, 1,
      98  			      __mempcpy_ppc))
      99  
     100    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memchr.c.  */
     101    IFUNC_IMPL (i, name, memchr,
     102  	      IFUNC_IMPL_ADD (array, i, memchr,
     103  			      hwcap & PPC_FEATURE_HAS_VSX,
     104  			      __memchr_power7)
     105  	      IFUNC_IMPL_ADD (array, i, memchr, 1,
     106  			      __memchr_ppc))
     107  
     108    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/memrchr.c.  */
     109    IFUNC_IMPL (i, name, memrchr,
     110  	      IFUNC_IMPL_ADD (array, i, memrchr,
     111  			      hwcap & PPC_FEATURE_HAS_VSX,
     112  			      __memrchr_power7)
     113  	      IFUNC_IMPL_ADD (array, i, memrchr, 1,
     114  			      __memrchr_ppc))
     115  
     116    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/rawmemchr.c.  */
     117    IFUNC_IMPL (i, name, rawmemchr,
     118  	      IFUNC_IMPL_ADD (array, i, rawmemchr,
     119  			      hwcap & PPC_FEATURE_HAS_VSX,
     120  			      __rawmemchr_power7)
     121  	      IFUNC_IMPL_ADD (array, i, rawmemchr, 1,
     122  			      __rawmemchr_ppc))
     123  
     124    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strcasecmp.c.  */
     125    IFUNC_IMPL (i, name, strcasecmp,
     126  	      IFUNC_IMPL_ADD (array, i, strcasecmp,
     127  			      hwcap & PPC_FEATURE_HAS_VSX,
     128  			      __strcasecmp_power7)
     129  	      IFUNC_IMPL_ADD (array, i, strcasecmp, 1, __strcasecmp_ppc))
     130  
     131    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strcasecmp_l.c.  */
     132    IFUNC_IMPL (i, name, strcasecmp_l,
     133  	      IFUNC_IMPL_ADD (array, i, strcasecmp_l,
     134  			      hwcap & PPC_FEATURE_HAS_VSX,
     135  			      __strcasecmp_l_power7)
     136  	      IFUNC_IMPL_ADD (array, i, strcasecmp_l, 1,
     137  			      __strcasecmp_l_ppc))
     138  
     139    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strncase.c.  */
     140    IFUNC_IMPL (i, name, strncasecmp,
     141  	      IFUNC_IMPL_ADD (array, i, strncasecmp,
     142  			      hwcap & PPC_FEATURE_HAS_VSX,
     143  			      __strncasecmp_power7)
     144  	      IFUNC_IMPL_ADD (array, i, strncasecmp, 1, __strncasecmp_ppc))
     145  
     146    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strncase_l.c.  */
     147    IFUNC_IMPL (i, name, strncasecmp_l,
     148  	      IFUNC_IMPL_ADD (array, i, strncasecmp_l,
     149  			      hwcap & PPC_FEATURE_HAS_VSX,
     150  			      __strncasecmp_l_power7)
     151  	      IFUNC_IMPL_ADD (array, i, strncasecmp_l, 1,
     152  			      __strncasecmp_l_ppc))
     153  
     154    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strchrnul.c.  */
     155    IFUNC_IMPL (i, name, strchrnul,
     156  	      IFUNC_IMPL_ADD (array, i, strchrnul,
     157  			      hwcap & PPC_FEATURE_HAS_VSX,
     158  			      __strchrnul_power7)
     159  	      IFUNC_IMPL_ADD (array, i, strchrnul, 1,
     160  			      __strchrnul_ppc))
     161  
     162    /* Support sysdeps/powerpc/powerpc32/power4/multiarch/strchr.c.  */
     163    IFUNC_IMPL (i, name, strchr,
     164  	      IFUNC_IMPL_ADD (array, i, strchr,
     165  			      hwcap & PPC_FEATURE_HAS_VSX,
     166  			      __strchr_power7)
     167  	      IFUNC_IMPL_ADD (array, i, strchr, 1,
     168  			      __strchr_ppc))
     169  
     170    return 0;
     171  }