lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame^] | 1 | /* |
| 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 |
| 12 | void *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 | } |
| 24 | libc_hidden_def(rawmemchr) |