/sysdeps/i386/i686/multiarch/ifunc-impl-list.c

https://gitlab.com/Namal/glibc · C · 376 lines · 272 code · 45 blank · 59 comment · 0 complexity · d9c969572a2d7001b734170660f228a2 MD5 · raw file

  1. /* Enumerate available IFUNC implementations of a function. i686 version.
  2. Copyright (C) 2012-2016 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <assert.h>
  16. #include <string.h>
  17. #include <wchar.h>
  18. #include <ifunc-impl-list.h>
  19. #include "init-arch.h"
  20. /* Maximum number of IFUNC implementations. */
  21. #define MAX_IFUNC 4
  22. /* Fill ARRAY of MAX elements with IFUNC implementations for function
  23. NAME and return the number of valid entries. */
  24. size_t
  25. __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
  26. size_t max)
  27. {
  28. assert (max >= MAX_IFUNC);
  29. size_t i = 0;
  30. /* Support sysdeps/i386/i686/multiarch/bcopy.S. */
  31. IFUNC_IMPL (i, name, bcopy,
  32. IFUNC_IMPL_ADD (array, i, bcopy, HAS_CPU_FEATURE (SSSE3),
  33. __bcopy_ssse3_rep)
  34. IFUNC_IMPL_ADD (array, i, bcopy, HAS_CPU_FEATURE (SSSE3),
  35. __bcopy_ssse3)
  36. IFUNC_IMPL_ADD (array, i, bcopy, HAS_CPU_FEATURE (SSE2),
  37. __bcopy_sse2_unaligned)
  38. IFUNC_IMPL_ADD (array, i, bcopy, 1, __bcopy_ia32))
  39. /* Support sysdeps/i386/i686/multiarch/bzero.S. */
  40. IFUNC_IMPL (i, name, bzero,
  41. IFUNC_IMPL_ADD (array, i, bzero, HAS_CPU_FEATURE (SSE2),
  42. __bzero_sse2_rep)
  43. IFUNC_IMPL_ADD (array, i, bzero, HAS_CPU_FEATURE (SSE2),
  44. __bzero_sse2)
  45. IFUNC_IMPL_ADD (array, i, bzero, 1, __bzero_ia32))
  46. /* Support sysdeps/i386/i686/multiarch/memchr.S. */
  47. IFUNC_IMPL (i, name, memchr,
  48. IFUNC_IMPL_ADD (array, i, memchr, HAS_CPU_FEATURE (SSE2),
  49. __memchr_sse2_bsf)
  50. IFUNC_IMPL_ADD (array, i, memchr, HAS_CPU_FEATURE (SSE2),
  51. __memchr_sse2)
  52. IFUNC_IMPL_ADD (array, i, memchr, 1, __memchr_ia32))
  53. /* Support sysdeps/i386/i686/multiarch/memcmp.S. */
  54. IFUNC_IMPL (i, name, memcmp,
  55. IFUNC_IMPL_ADD (array, i, memcmp, HAS_CPU_FEATURE (SSE4_2),
  56. __memcmp_sse4_2)
  57. IFUNC_IMPL_ADD (array, i, memcmp, HAS_CPU_FEATURE (SSSE3),
  58. __memcmp_ssse3)
  59. IFUNC_IMPL_ADD (array, i, memcmp, 1, __memcmp_ia32))
  60. /* Support sysdeps/i386/i686/multiarch/memmove_chk.S. */
  61. IFUNC_IMPL (i, name, __memmove_chk,
  62. IFUNC_IMPL_ADD (array, i, __memmove_chk,
  63. HAS_CPU_FEATURE (SSSE3),
  64. __memmove_chk_ssse3_rep)
  65. IFUNC_IMPL_ADD (array, i, __memmove_chk,
  66. HAS_CPU_FEATURE (SSSE3),
  67. __memmove_chk_ssse3)
  68. IFUNC_IMPL_ADD (array, i, __memmove_chk,
  69. HAS_CPU_FEATURE (SSE2),
  70. __memmove_chk_sse2_unaligned)
  71. IFUNC_IMPL_ADD (array, i, __memmove_chk, 1,
  72. __memmove_chk_ia32))
  73. /* Support sysdeps/i386/i686/multiarch/memmove.S. */
  74. IFUNC_IMPL (i, name, memmove,
  75. IFUNC_IMPL_ADD (array, i, memmove, HAS_CPU_FEATURE (SSSE3),
  76. __memmove_ssse3_rep)
  77. IFUNC_IMPL_ADD (array, i, memmove, HAS_CPU_FEATURE (SSSE3),
  78. __memmove_ssse3)
  79. IFUNC_IMPL_ADD (array, i, memmove, HAS_CPU_FEATURE (SSE2),
  80. __memmove_sse2_unaligned)
  81. IFUNC_IMPL_ADD (array, i, memmove, 1, __memmove_ia32))
  82. /* Support sysdeps/i386/i686/multiarch/memrchr.S. */
  83. IFUNC_IMPL (i, name, memrchr,
  84. IFUNC_IMPL_ADD (array, i, memrchr, HAS_CPU_FEATURE (SSE2),
  85. __memrchr_sse2_bsf)
  86. IFUNC_IMPL_ADD (array, i, memrchr, HAS_CPU_FEATURE (SSE2),
  87. __memrchr_sse2)
  88. IFUNC_IMPL_ADD (array, i, memrchr, 1, __memrchr_ia32))
  89. /* Support sysdeps/i386/i686/multiarch/memset_chk.S. */
  90. IFUNC_IMPL (i, name, __memset_chk,
  91. IFUNC_IMPL_ADD (array, i, __memset_chk,
  92. HAS_CPU_FEATURE (SSE2),
  93. __memset_chk_sse2_rep)
  94. IFUNC_IMPL_ADD (array, i, __memset_chk,
  95. HAS_CPU_FEATURE (SSE2),
  96. __memset_chk_sse2)
  97. IFUNC_IMPL_ADD (array, i, __memset_chk, 1,
  98. __memset_chk_ia32))
  99. /* Support sysdeps/i386/i686/multiarch/memset.S. */
  100. IFUNC_IMPL (i, name, memset,
  101. IFUNC_IMPL_ADD (array, i, memset, HAS_CPU_FEATURE (SSE2),
  102. __memset_sse2_rep)
  103. IFUNC_IMPL_ADD (array, i, memset, HAS_CPU_FEATURE (SSE2),
  104. __memset_sse2)
  105. IFUNC_IMPL_ADD (array, i, memset, 1, __memset_ia32))
  106. /* Support sysdeps/i386/i686/multiarch/rawmemchr.S. */
  107. IFUNC_IMPL (i, name, rawmemchr,
  108. IFUNC_IMPL_ADD (array, i, rawmemchr, HAS_CPU_FEATURE (SSE2),
  109. __rawmemchr_sse2_bsf)
  110. IFUNC_IMPL_ADD (array, i, rawmemchr, HAS_CPU_FEATURE (SSE2),
  111. __rawmemchr_sse2)
  112. IFUNC_IMPL_ADD (array, i, rawmemchr, 1, __rawmemchr_ia32))
  113. /* Support sysdeps/i386/i686/multiarch/stpncpy.S. */
  114. IFUNC_IMPL (i, name, stpncpy,
  115. IFUNC_IMPL_ADD (array, i, stpncpy, HAS_CPU_FEATURE (SSSE3),
  116. __stpncpy_ssse3)
  117. IFUNC_IMPL_ADD (array, i, stpncpy, HAS_CPU_FEATURE (SSE2),
  118. __stpncpy_sse2)
  119. IFUNC_IMPL_ADD (array, i, stpncpy, 1, __stpncpy_ia32))
  120. /* Support sysdeps/i386/i686/multiarch/stpcpy.S. */
  121. IFUNC_IMPL (i, name, stpcpy,
  122. IFUNC_IMPL_ADD (array, i, stpcpy, HAS_CPU_FEATURE (SSSE3),
  123. __stpcpy_ssse3)
  124. IFUNC_IMPL_ADD (array, i, stpcpy, HAS_CPU_FEATURE (SSE2),
  125. __stpcpy_sse2)
  126. IFUNC_IMPL_ADD (array, i, stpcpy, 1, __stpcpy_ia32))
  127. /* Support sysdeps/i386/i686/multiarch/strcasecmp.S. */
  128. IFUNC_IMPL (i, name, strcasecmp,
  129. IFUNC_IMPL_ADD (array, i, strcasecmp,
  130. HAS_CPU_FEATURE (SSE4_2),
  131. __strcasecmp_sse4_2)
  132. IFUNC_IMPL_ADD (array, i, strcasecmp,
  133. HAS_CPU_FEATURE (SSSE3),
  134. __strcasecmp_ssse3)
  135. IFUNC_IMPL_ADD (array, i, strcasecmp, 1, __strcasecmp_ia32))
  136. /* Support sysdeps/i386/i686/multiarch/strcasecmp_l.S. */
  137. IFUNC_IMPL (i, name, strcasecmp_l,
  138. IFUNC_IMPL_ADD (array, i, strcasecmp_l,
  139. HAS_CPU_FEATURE (SSE4_2),
  140. __strcasecmp_l_sse4_2)
  141. IFUNC_IMPL_ADD (array, i, strcasecmp_l,
  142. HAS_CPU_FEATURE (SSSE3),
  143. __strcasecmp_l_ssse3)
  144. IFUNC_IMPL_ADD (array, i, strcasecmp_l, 1,
  145. __strcasecmp_l_ia32))
  146. /* Support sysdeps/i386/i686/multiarch/strcat.S. */
  147. IFUNC_IMPL (i, name, strcat,
  148. IFUNC_IMPL_ADD (array, i, strcat, HAS_CPU_FEATURE (SSSE3),
  149. __strcat_ssse3)
  150. IFUNC_IMPL_ADD (array, i, strcat, HAS_CPU_FEATURE (SSE2),
  151. __strcat_sse2)
  152. IFUNC_IMPL_ADD (array, i, strcat, 1, __strcat_ia32))
  153. /* Support sysdeps/i386/i686/multiarch/strchr.S. */
  154. IFUNC_IMPL (i, name, strchr,
  155. IFUNC_IMPL_ADD (array, i, strchr, HAS_CPU_FEATURE (SSE2),
  156. __strchr_sse2_bsf)
  157. IFUNC_IMPL_ADD (array, i, strchr, HAS_CPU_FEATURE (SSE2),
  158. __strchr_sse2)
  159. IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_ia32))
  160. /* Support sysdeps/i386/i686/multiarch/strcmp.S. */
  161. IFUNC_IMPL (i, name, strcmp,
  162. IFUNC_IMPL_ADD (array, i, strcmp, HAS_CPU_FEATURE (SSE4_2),
  163. __strcmp_sse4_2)
  164. IFUNC_IMPL_ADD (array, i, strcmp, HAS_CPU_FEATURE (SSSE3),
  165. __strcmp_ssse3)
  166. IFUNC_IMPL_ADD (array, i, strcmp, 1, __strcmp_ia32))
  167. /* Support sysdeps/i386/i686/multiarch/strcpy.S. */
  168. IFUNC_IMPL (i, name, strcpy,
  169. IFUNC_IMPL_ADD (array, i, strcpy, HAS_CPU_FEATURE (SSSE3),
  170. __strcpy_ssse3)
  171. IFUNC_IMPL_ADD (array, i, strcpy, HAS_CPU_FEATURE (SSE2),
  172. __strcpy_sse2)
  173. IFUNC_IMPL_ADD (array, i, strcpy, 1, __strcpy_ia32))
  174. /* Support sysdeps/i386/i686/multiarch/strcspn.S. */
  175. IFUNC_IMPL (i, name, strcspn,
  176. IFUNC_IMPL_ADD (array, i, strcspn, HAS_CPU_FEATURE (SSE4_2),
  177. __strcspn_sse42)
  178. IFUNC_IMPL_ADD (array, i, strcspn, 1, __strcspn_ia32))
  179. /* Support sysdeps/i386/i686/multiarch/strncase.S. */
  180. IFUNC_IMPL (i, name, strncasecmp,
  181. IFUNC_IMPL_ADD (array, i, strncasecmp,
  182. HAS_CPU_FEATURE (SSE4_2),
  183. __strncasecmp_sse4_2)
  184. IFUNC_IMPL_ADD (array, i, strncasecmp,
  185. HAS_CPU_FEATURE (SSSE3),
  186. __strncasecmp_ssse3)
  187. IFUNC_IMPL_ADD (array, i, strncasecmp, 1,
  188. __strncasecmp_ia32))
  189. /* Support sysdeps/i386/i686/multiarch/strncase_l.S. */
  190. IFUNC_IMPL (i, name, strncasecmp_l,
  191. IFUNC_IMPL_ADD (array, i, strncasecmp_l,
  192. HAS_CPU_FEATURE (SSE4_2),
  193. __strncasecmp_l_sse4_2)
  194. IFUNC_IMPL_ADD (array, i, strncasecmp_l,
  195. HAS_CPU_FEATURE (SSSE3),
  196. __strncasecmp_l_ssse3)
  197. IFUNC_IMPL_ADD (array, i, strncasecmp_l, 1,
  198. __strncasecmp_l_ia32))
  199. /* Support sysdeps/i386/i686/multiarch/strncat.S. */
  200. IFUNC_IMPL (i, name, strncat,
  201. IFUNC_IMPL_ADD (array, i, strncat, HAS_CPU_FEATURE (SSSE3),
  202. __strncat_ssse3)
  203. IFUNC_IMPL_ADD (array, i, strncat, HAS_CPU_FEATURE (SSE2),
  204. __strncat_sse2)
  205. IFUNC_IMPL_ADD (array, i, strncat, 1, __strncat_ia32))
  206. /* Support sysdeps/i386/i686/multiarch/strncpy.S. */
  207. IFUNC_IMPL (i, name, strncpy,
  208. IFUNC_IMPL_ADD (array, i, strncpy, HAS_CPU_FEATURE (SSSE3),
  209. __strncpy_ssse3)
  210. IFUNC_IMPL_ADD (array, i, strncpy, HAS_CPU_FEATURE (SSE2),
  211. __strncpy_sse2)
  212. IFUNC_IMPL_ADD (array, i, strncpy, 1, __strncpy_ia32))
  213. /* Support sysdeps/i386/i686/multiarch/strnlen.S. */
  214. IFUNC_IMPL (i, name, strnlen,
  215. IFUNC_IMPL_ADD (array, i, strnlen, HAS_CPU_FEATURE (SSE2),
  216. __strnlen_sse2)
  217. IFUNC_IMPL_ADD (array, i, strnlen, 1, __strnlen_ia32))
  218. /* Support sysdeps/i386/i686/multiarch/strpbrk.S. */
  219. IFUNC_IMPL (i, name, strpbrk,
  220. IFUNC_IMPL_ADD (array, i, strpbrk, HAS_CPU_FEATURE (SSE4_2),
  221. __strpbrk_sse42)
  222. IFUNC_IMPL_ADD (array, i, strpbrk, 1, __strpbrk_ia32))
  223. /* Support sysdeps/i386/i686/multiarch/strrchr.S. */
  224. IFUNC_IMPL (i, name, strrchr,
  225. IFUNC_IMPL_ADD (array, i, strrchr, HAS_CPU_FEATURE (SSE2),
  226. __strrchr_sse2_bsf)
  227. IFUNC_IMPL_ADD (array, i, strrchr, HAS_CPU_FEATURE (SSE2),
  228. __strrchr_sse2)
  229. IFUNC_IMPL_ADD (array, i, strrchr, 1, __strrchr_ia32))
  230. /* Support sysdeps/i386/i686/multiarch/strspn.S. */
  231. IFUNC_IMPL (i, name, strspn,
  232. IFUNC_IMPL_ADD (array, i, strspn, HAS_CPU_FEATURE (SSE4_2),
  233. __strspn_sse42)
  234. IFUNC_IMPL_ADD (array, i, strspn, 1, __strspn_ia32))
  235. /* Support sysdeps/i386/i686/multiarch/wcschr.S. */
  236. IFUNC_IMPL (i, name, wcschr,
  237. IFUNC_IMPL_ADD (array, i, wcschr, HAS_CPU_FEATURE (SSE2),
  238. __wcschr_sse2)
  239. IFUNC_IMPL_ADD (array, i, wcschr, 1, __wcschr_ia32))
  240. /* Support sysdeps/i386/i686/multiarch/wcscmp.S. */
  241. IFUNC_IMPL (i, name, wcscmp,
  242. IFUNC_IMPL_ADD (array, i, wcscmp, HAS_CPU_FEATURE (SSE2),
  243. __wcscmp_sse2)
  244. IFUNC_IMPL_ADD (array, i, wcscmp, 1, __wcscmp_ia32))
  245. /* Support sysdeps/i386/i686/multiarch/wcscpy.S. */
  246. IFUNC_IMPL (i, name, wcscpy,
  247. IFUNC_IMPL_ADD (array, i, wcscpy, HAS_CPU_FEATURE (SSSE3),
  248. __wcscpy_ssse3)
  249. IFUNC_IMPL_ADD (array, i, wcscpy, 1, __wcscpy_ia32))
  250. /* Support sysdeps/i386/i686/multiarch/wcslen.S. */
  251. IFUNC_IMPL (i, name, wcslen,
  252. IFUNC_IMPL_ADD (array, i, wcslen, HAS_CPU_FEATURE (SSE2),
  253. __wcslen_sse2)
  254. IFUNC_IMPL_ADD (array, i, wcslen, 1, __wcslen_ia32))
  255. /* Support sysdeps/i386/i686/multiarch/wcsrchr.S. */
  256. IFUNC_IMPL (i, name, wcsrchr,
  257. IFUNC_IMPL_ADD (array, i, wcsrchr, HAS_CPU_FEATURE (SSE2),
  258. __wcsrchr_sse2)
  259. IFUNC_IMPL_ADD (array, i, wcsrchr, 1, __wcsrchr_ia32))
  260. /* Support sysdeps/i386/i686/multiarch/wmemcmp.S. */
  261. IFUNC_IMPL (i, name, wmemcmp,
  262. IFUNC_IMPL_ADD (array, i, wmemcmp, HAS_CPU_FEATURE (SSE4_2),
  263. __wmemcmp_sse4_2)
  264. IFUNC_IMPL_ADD (array, i, wmemcmp, HAS_CPU_FEATURE (SSSE3),
  265. __wmemcmp_ssse3)
  266. IFUNC_IMPL_ADD (array, i, wmemcmp, 1, __wmemcmp_ia32))
  267. #ifdef SHARED
  268. /* Support sysdeps/i386/i686/multiarch/memcpy_chk.S. */
  269. IFUNC_IMPL (i, name, __memcpy_chk,
  270. IFUNC_IMPL_ADD (array, i, __memcpy_chk,
  271. HAS_CPU_FEATURE (SSSE3),
  272. __memcpy_chk_ssse3_rep)
  273. IFUNC_IMPL_ADD (array, i, __memcpy_chk,
  274. HAS_CPU_FEATURE (SSSE3),
  275. __memcpy_chk_ssse3)
  276. IFUNC_IMPL_ADD (array, i, __memcpy_chk,
  277. HAS_CPU_FEATURE (SSE2),
  278. __memcpy_chk_sse2_unaligned)
  279. IFUNC_IMPL_ADD (array, i, __memcpy_chk, 1,
  280. __memcpy_chk_ia32))
  281. /* Support sysdeps/i386/i686/multiarch/memcpy.S. */
  282. IFUNC_IMPL (i, name, memcpy,
  283. IFUNC_IMPL_ADD (array, i, memcpy, HAS_CPU_FEATURE (SSSE3),
  284. __memcpy_ssse3_rep)
  285. IFUNC_IMPL_ADD (array, i, memcpy, HAS_CPU_FEATURE (SSSE3),
  286. __memcpy_ssse3)
  287. IFUNC_IMPL_ADD (array, i, memcpy, HAS_CPU_FEATURE (SSE2),
  288. __memcpy_sse2_unaligned)
  289. IFUNC_IMPL_ADD (array, i, memcpy, 1, __memcpy_ia32))
  290. /* Support sysdeps/i386/i686/multiarch/mempcpy_chk.S. */
  291. IFUNC_IMPL (i, name, __mempcpy_chk,
  292. IFUNC_IMPL_ADD (array, i, __mempcpy_chk,
  293. HAS_CPU_FEATURE (SSSE3),
  294. __mempcpy_chk_ssse3_rep)
  295. IFUNC_IMPL_ADD (array, i, __mempcpy_chk,
  296. HAS_CPU_FEATURE (SSSE3),
  297. __mempcpy_chk_ssse3)
  298. IFUNC_IMPL_ADD (array, i, __mempcpy_chk,
  299. HAS_CPU_FEATURE (SSE2),
  300. __mempcpy_chk_sse2_unaligned)
  301. IFUNC_IMPL_ADD (array, i, __mempcpy_chk, 1,
  302. __mempcpy_chk_ia32))
  303. /* Support sysdeps/i386/i686/multiarch/mempcpy.S. */
  304. IFUNC_IMPL (i, name, mempcpy,
  305. IFUNC_IMPL_ADD (array, i, mempcpy, HAS_CPU_FEATURE (SSSE3),
  306. __mempcpy_ssse3_rep)
  307. IFUNC_IMPL_ADD (array, i, mempcpy, HAS_CPU_FEATURE (SSSE3),
  308. __mempcpy_ssse3)
  309. IFUNC_IMPL_ADD (array, i, mempcpy, HAS_CPU_FEATURE (SSE2),
  310. __mempcpy_sse2_unaligned)
  311. IFUNC_IMPL_ADD (array, i, mempcpy, 1, __mempcpy_ia32))
  312. /* Support sysdeps/i386/i686/multiarch/strlen.S. */
  313. IFUNC_IMPL (i, name, strlen,
  314. IFUNC_IMPL_ADD (array, i, strlen, HAS_CPU_FEATURE (SSE2),
  315. __strlen_sse2_bsf)
  316. IFUNC_IMPL_ADD (array, i, strlen, HAS_CPU_FEATURE (SSE2),
  317. __strlen_sse2)
  318. IFUNC_IMPL_ADD (array, i, strlen, 1, __strlen_ia32))
  319. /* Support sysdeps/i386/i686/multiarch/strncmp.S. */
  320. IFUNC_IMPL (i, name, strncmp,
  321. IFUNC_IMPL_ADD (array, i, strncmp, HAS_CPU_FEATURE (SSE4_2),
  322. __strncmp_sse4_2)
  323. IFUNC_IMPL_ADD (array, i, strncmp, HAS_CPU_FEATURE (SSSE3),
  324. __strncmp_ssse3)
  325. IFUNC_IMPL_ADD (array, i, strncmp, 1, __strncmp_ia32))
  326. #endif
  327. return i;
  328. }