blob: be0b142c35372ef07d274f5f13dc66ebf2384b60 [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/*
2 * Adapted from strlen.c code
3 *
4 * Copyright (C) 2008 Denys Vlasenko <vda.linux@googlemail.com>
5 *
6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
7 */
8
9#include <string.h>
10
11#undef rawmemchr
12void *rawmemchr(const void *s, int c)
13{
14 void *eax;
15 int ecx, edi;
16 __asm__ __volatile__(
17 " repne; scasb\n"
18 " leal -1(%%edi), %%eax\n"
19 : "=&c" (ecx), "=&D" (edi), "=&a" (eax)
20 : "0" (0xffffffff), "1" (s), "2" (c)
21 );
22 return eax;
23}
24libc_hidden_def(rawmemchr)