kolibrios-fun/programs/develop/ktcc/trunk/libc.obj/source/string/memchr.c
turbocat cde4fa851d libc.obj:
- Formatted by clang-format (WebKit-style).
- Removed unnecessary errno linux. 
- Added KOS error codes. 
- String functions have been replaced with more optimal ones for x86. 
- Changed wrappers for 70 sysfunction.

git-svn-id: svn://kolibrios.org@9765 a494cfbc-eb01-0410-851d-a64ba20cac60
2022-04-15 09:00:55 +00:00

20 lines
417 B
C

#include <assert.h>
#include "unconst.h"
#include <string.h>
void* memchr(const void* s, int c, size_t n)
{
int d0;
register void* __res;
if (!n)
return NULL;
__asm__ __volatile__(
"repne\n\t"
"scasb\n\t"
"je 1f\n\t"
"movl $1,%0\n"
"1:\tdecl %0"
: "=D"(__res), "=&c"(d0)
: "a"(c), "0"(s), "1"(n));
return __res;
}