0002-RISCV-revert-strchrnul-strncmp-strnlen.patch 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. From 0dfcc83599765108e12ab6630a16bd27adae2b6a Mon Sep 17 00:00:00 2001
  2. From: "max.ma" <max.ma@starfivetech.com>
  3. Date: Thu, 16 Mar 2023 00:22:15 -0700
  4. Subject: [PATCH 2/2] [RISCV] revert strchrnul/strncmp/strnlen
  5. ---
  6. .../riscv/rv64/multiarch/ifunc-impl-list.c | 11 ---
  7. sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S | 1 -
  8. sysdeps/riscv/rv64/multiarch/rtld-strncmp.S | 1 -
  9. sysdeps/riscv/rv64/strchrnul.S | 80 -------------------
  10. sysdeps/riscv/rv64/strncmp.S | 74 -----------------
  11. sysdeps/riscv/rv64/strnlen.S | 65 ---------------
  12. 6 files changed, 232 deletions(-)
  13. delete mode 100644 sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S
  14. delete mode 100644 sysdeps/riscv/rv64/multiarch/rtld-strncmp.S
  15. delete mode 100644 sysdeps/riscv/rv64/strchrnul.S
  16. delete mode 100644 sysdeps/riscv/rv64/strncmp.S
  17. delete mode 100644 sysdeps/riscv/rv64/strnlen.S
  18. diff --git a/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c b/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c
  19. index 7bba6fa30c..07d584deec 100644
  20. --- a/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c
  21. +++ b/sysdeps/riscv/rv64/multiarch/ifunc-impl-list.c
  22. @@ -61,17 +61,6 @@ __libc_ifunc_impl_list (const char *name, struct libc_ifunc_impl *array,
  23. IFUNC_IMPL_ADD (array, i, memset, use_rvv, __memset_vector)
  24. IFUNC_IMPL_ADD (array, i, memset, 1, __memset_riscv));
  25. - IFUNC_IMPL (i, name, strchr,
  26. - IFUNC_IMPL_ADD (array, i, strchr, use_rvv, __strchr_riscv)
  27. - IFUNC_IMPL_ADD (array, i, strchr, 1, __strchr_riscv));
  28. -
  29. - IFUNC_IMPL (i, name, strchrnul,
  30. - IFUNC_IMPL_ADD (array, i, strchrnul, use_rvv, __strchrnul_riscv)
  31. - IFUNC_IMPL_ADD (array, i, strchrnul, 1, __strchrnul_riscv));
  32. -
  33. - IFUNC_IMPL (i, name, strncmp,
  34. - IFUNC_IMPL_ADD (array, i, strncmp, use_rvv, __strncmp_riscv)
  35. - IFUNC_IMPL_ADD (array, i, strncmp, 1, __strncmp_riscv));
  36. #endif
  37. return i;
  38. }
  39. diff --git a/sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S b/sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S
  40. deleted file mode 100644
  41. index 5799994393..0000000000
  42. --- a/sysdeps/riscv/rv64/multiarch/rtld-strchrnul.S
  43. +++ /dev/null
  44. @@ -1 +0,0 @@
  45. -#include "../strchrnul.S"
  46. diff --git a/sysdeps/riscv/rv64/multiarch/rtld-strncmp.S b/sysdeps/riscv/rv64/multiarch/rtld-strncmp.S
  47. deleted file mode 100644
  48. index c5a02a137c..0000000000
  49. --- a/sysdeps/riscv/rv64/multiarch/rtld-strncmp.S
  50. +++ /dev/null
  51. @@ -1 +0,0 @@
  52. -#include "../strncmp.S"
  53. diff --git a/sysdeps/riscv/rv64/strchrnul.S b/sysdeps/riscv/rv64/strchrnul.S
  54. deleted file mode 100644
  55. index 6cf125cf46..0000000000
  56. --- a/sysdeps/riscv/rv64/strchrnul.S
  57. +++ /dev/null
  58. @@ -1,80 +0,0 @@
  59. -/* The assembly function for strchrnul. RISC-V version.
  60. - Copyright (C) 2018 Free Software Foundation, Inc.
  61. - This file is part of the GNU C Library.
  62. -
  63. - The GNU C Library is free software; you can redistribute it and/or
  64. - modify it under the terms of the GNU Lesser General Public
  65. - License as published by the Free Software Foundation; either
  66. - version 2.1 of the License, or (at your option) any later version.
  67. -
  68. - The GNU C Library is distributed in the hope that it will be useful,
  69. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  70. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  71. - Lesser General Public License for more details.
  72. -
  73. - You should have received a copy of the GNU Lesser General Public
  74. - License along with the GNU C Library. If not, see
  75. - <http://www.gnu.org/licenses/>. */
  76. -
  77. -#include <sysdep.h>
  78. -
  79. - .p2align 6
  80. -ENTRY (__strchrnul)
  81. - andi a1, a1, 0xff
  82. -
  83. -.Lmisaligned:
  84. - andi a5, a0, 7
  85. - beqz a5, .Laligned
  86. - lbu a5, 0(a0)
  87. - beq a5, a1, .Ldone
  88. - beqz a5, .Ldone
  89. - addi a0, a0, 1
  90. - j .Lmisaligned
  91. -
  92. -.Laligned:
  93. - slli a5, a1, 0x8
  94. - or a5, a5, a1
  95. - slli t0, a5, 0x10
  96. - or t0, t0, a5
  97. - slli a5, t0, 0x20
  98. - or t0, t0, a5
  99. -
  100. - li a5, -1
  101. - addi a0, a0, -8
  102. - .p2align 3
  103. -.Lloop:
  104. - addi a0, a0, 8
  105. - ld a2, 0(a0)
  106. - orc.b t1, a2
  107. - bne t1, a5, .Lnull
  108. - xor a3, a2, t0
  109. - orc.b a3, a3
  110. - bne a3, a5, .Lfind
  111. - orc.b a2, a2
  112. - beq a2, a5, .Lloop
  113. -
  114. -.Ldone:
  115. - ret
  116. -
  117. -.Lfind:
  118. - not a3, a3
  119. - ctz a3, a3
  120. - srli a3, a3, 3
  121. - add a0, a0, a3
  122. - ret
  123. -
  124. -# cases in which a null byte was detected
  125. -.Lnull:
  126. - bne a2, t0, .Lend
  127. - j .Lfind
  128. -
  129. -.Lend:
  130. - lbu a5, 0(a0)
  131. - beq a5, a1, .Ldone
  132. - beqz a5, .Ldone
  133. - addi a0, a0, 1
  134. - j .Lend
  135. -
  136. -END (__strchrnul)
  137. -weak_alias (__strchrnul,strchrnul)
  138. -libc_hidden_builtin_def (__strchrnul)
  139. \ No newline at end of file
  140. diff --git a/sysdeps/riscv/rv64/strncmp.S b/sysdeps/riscv/rv64/strncmp.S
  141. deleted file mode 100644
  142. index 200bee4fe1..0000000000
  143. --- a/sysdeps/riscv/rv64/strncmp.S
  144. +++ /dev/null
  145. @@ -1,74 +0,0 @@
  146. -/* The assembly function for strncmp. RISC-V version.
  147. - Copyright (C) 2018 Free Software Foundation, Inc.
  148. - This file is part of the GNU C Library.
  149. -
  150. - The GNU C Library is free software; you can redistribute it and/or
  151. - modify it under the terms of the GNU Lesser General Public
  152. - License as published by the Free Software Foundation; either
  153. - version 2.1 of the License, or (at your option) any later version.
  154. -
  155. - The GNU C Library is distributed in the hope that it will be useful,
  156. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  157. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  158. - Lesser General Public License for more details.
  159. -
  160. - You should have received a copy of the GNU Lesser General Public
  161. - License along with the GNU C Library. If not, see
  162. - <http://www.gnu.org/licenses/>. */
  163. -
  164. -#include <sysdep.h>
  165. -
  166. - .p2align 6
  167. -ENTRY (strncmp)
  168. - beqz a2, .Lequal
  169. - or a4, a0, a1
  170. - li t2, -1
  171. - and a4, a4, 7
  172. - beqz a4, .Lenter
  173. - j .Lmisaligned
  174. -
  175. - .p2align 3
  176. -.Lloop:
  177. - addi a0, a0, 8
  178. - addi a1, a1, 8
  179. - addi a2, a2, -8
  180. -
  181. -.Lenter:
  182. - addi a5, a2, -8
  183. - blez a5, .Lmisaligned
  184. - ld a3, 0(a0)
  185. - ld a4, 0(a1)
  186. - orc.b t0, a3
  187. - bne t0, t2, .Lnull
  188. - beq a3, a4, .Lloop
  189. - rev8 a6, a3
  190. - rev8 a7, a4
  191. - bgeu a6, a7, 1f
  192. - li a0, -1
  193. - ret
  194. -1:
  195. - li a0, 1
  196. - ret
  197. -
  198. -.Lmisaligned:
  199. - blez a2, .Ldone
  200. - lbu a3, 0(a0)
  201. - lbu a4, 0(a1)
  202. - addi a0, a0, 1
  203. - addi a1, a1, 1
  204. - addi a2, a2, -1
  205. - bne a3, a4, .Ldone
  206. - bnez a3, .Lmisaligned
  207. -.Ldone:
  208. - sub a0, a3, a4
  209. - ret
  210. -
  211. -# cases in which a null byte was detected
  212. -.Lnull:
  213. - bne a3, a4, .Lmisaligned
  214. -.Lequal:
  215. - li a0, 0
  216. - ret
  217. -
  218. -END (strncmp)
  219. -libc_hidden_builtin_def (strncmp)
  220. \ No newline at end of file
  221. diff --git a/sysdeps/riscv/rv64/strnlen.S b/sysdeps/riscv/rv64/strnlen.S
  222. deleted file mode 100644
  223. index 502f108710..0000000000
  224. --- a/sysdeps/riscv/rv64/strnlen.S
  225. +++ /dev/null
  226. @@ -1,65 +0,0 @@
  227. -/* The assembly function for strnlen. RISC-V version.
  228. - Copyright (C) 2018 Free Software Foundation, Inc.
  229. - This file is part of the GNU C Library.
  230. -
  231. - The GNU C Library is free software; you can redistribute it and/or
  232. - modify it under the terms of the GNU Lesser General Public
  233. - License as published by the Free Software Foundation; either
  234. - version 2.1 of the License, or (at your option) any later version.
  235. -
  236. - The GNU C Library is distributed in the hope that it will be useful,
  237. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  238. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  239. - Lesser General Public License for more details.
  240. -
  241. - You should have received a copy of the GNU Lesser General Public
  242. - License along with the GNU C Library. If not, see
  243. - <http://www.gnu.org/licenses/>. */
  244. -
  245. -#include <sysdep.h>
  246. -
  247. - .p2align 6
  248. -ENTRY (__strnlen)
  249. - mv a2, a0
  250. - mv a0, a1
  251. - li a3, -1
  252. - beqz a1, .Ldone
  253. - add a0, a2, a1
  254. - bleu a2, a0, 1f
  255. - li a0, -1
  256. -1:
  257. - mv a5, a2
  258. -
  259. -.Lmisaligned:
  260. - andi a4, a5, 7
  261. - beqz a4, .Lloop
  262. - lbu a4, 0(a5)
  263. - beqz a4, .Llenth
  264. - addi a5, a5, 1
  265. - j .Lmisaligned
  266. -.p2align 3
  267. -.Laligned:
  268. - addi a5, a5, 8
  269. - addi a1, a1, -8
  270. -.Lloop:
  271. - bleu a1, x0, .Llenth
  272. - ld a4, 0(a5)
  273. - orc.b a4, a4
  274. - beq a4, a3, .Laligned
  275. - not a4, a4
  276. - ctz a4, a4
  277. - srli a4, a4, 3
  278. - add a5, a5, a4
  279. -.Llenth:
  280. - minu a5, a5, a0
  281. - sub a0, a5, a2
  282. -.Ldone:
  283. - ret
  284. -
  285. -END (__strnlen)
  286. -
  287. -#ifndef STRNLEN
  288. -libc_hidden_def (__strnlen)
  289. -weak_alias (__strnlen, strnlen)
  290. -#endif
  291. -libc_hidden_def (strnlen)
  292. --
  293. 2.25.1