Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1// SPDX-License-Identifier: GPL-2.0
2#include <linux/string.h>
3#include <linux/export.h>
4
5char *strstr(const char *cs, const char *ct)
6{
7int d0, d1;
8register char *__res;
9__asm__ __volatile__(
10 "movl %6,%%edi\n\t"
11 "repne scasb\n\t"
12 "notl %%ecx\n\t"
13 "decl %%ecx\n\t" /* NOTE! This also sets Z if searchstring='' */
14 "movl %%ecx,%%edx\n"
15 "1:\tmovl %6,%%edi\n\t"
16 "movl %%esi,%%eax\n\t"
17 "movl %%edx,%%ecx\n\t"
18 "repe cmpsb\n\t"
19 "je 2f\n\t" /* also works for empty string, see above */
20 "xchgl %%eax,%%esi\n\t"
21 "incl %%esi\n\t"
22 "cmpb $0,-1(%%eax)\n\t"
23 "jne 1b\n\t"
24 "xorl %%eax,%%eax\n\t"
25 "2:"
26 : "=a" (__res), "=&c" (d0), "=&S" (d1)
27 : "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct)
28 : "dx", "di");
29return __res;
30}
31EXPORT_SYMBOL(strstr);