Make more code aarch64 friendly

This commit is contained in:
Justine Tunney 2023-05-02 13:38:16 -07:00
parent ca2860947f
commit 2b73e72d59
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
568 changed files with 2197 additions and 1061 deletions

View file

@ -36,6 +36,7 @@ typedef char xmm_t __attribute__((__vector_size__(16), __aligned__(16)));
* @see memmem()
*/
noasan char *strstr(const char *haystack, const char *needle) {
#ifdef __x86_64__
xmm_t *p;
size_t i;
unsigned k, m;
@ -66,4 +67,18 @@ noasan char *strstr(const char *haystack, const char *needle) {
if (!*haystack++) break;
}
return 0;
#else
size_t i;
unsigned k, m;
if (haystack == needle || !*needle) return haystack;
for (;;) {
for (i = 0;; ++i) {
if (!needle[i]) return (/*unconst*/ char *)haystack;
if (!haystack[i]) break;
if (needle[i] != haystack[i]) break;
}
if (!*haystack++) break;
}
return 0;
#endif
}