Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0
0002 #include <linux/string.h>
0003 #include <linux/export.h>
0004 
0005 char *strstr(const char *cs, const char *ct)
0006 {
0007 int d0, d1;
0008 register char *__res;
0009 __asm__ __volatile__(
0010     "movl %6,%%edi\n\t"
0011     "repne\n\t"
0012     "scasb\n\t"
0013     "notl %%ecx\n\t"
0014     "decl %%ecx\n\t"    /* NOTE! This also sets Z if searchstring='' */
0015     "movl %%ecx,%%edx\n"
0016     "1:\tmovl %6,%%edi\n\t"
0017     "movl %%esi,%%eax\n\t"
0018     "movl %%edx,%%ecx\n\t"
0019     "repe\n\t"
0020     "cmpsb\n\t"
0021     "je 2f\n\t"     /* also works for empty string, see above */
0022     "xchgl %%eax,%%esi\n\t"
0023     "incl %%esi\n\t"
0024     "cmpb $0,-1(%%eax)\n\t"
0025     "jne 1b\n\t"
0026     "xorl %%eax,%%eax\n\t"
0027     "2:"
0028     : "=a" (__res), "=&c" (d0), "=&S" (d1)
0029     : "0" (0), "1" (0xffffffff), "2" (cs), "g" (ct)
0030     : "dx", "di");
0031 return __res;
0032 }
0033 EXPORT_SYMBOL(strstr);