Subversion Repositories Kolibri OS

Rev

Rev 8793 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8793 Rev 9765
Line 1... Line 1...
1
/* memchr( const void *, int, size_t )
1
#include 
2
 
-
 
3
   This file is part of the Public Domain C Library (PDCLib).
2
#include "unconst.h"
4
   Permission is granted to use, modify, and / or redistribute at will.
-
 
5
*/
-
 
6
 
-
 
7
#include 
3
#include 
Line 8... Line 4...
8
 
4
 
9
void * memchr( const void * s, int c, size_t n )
5
void* memchr(const void* s, int c, size_t n)
10
{
-
 
11
    const unsigned char * p = ( const unsigned char * ) s;
-
 
12
 
-
 
13
    while ( n-- )
-
 
14
    {
-
 
15
        if ( *p == ( unsigned char ) c )
6
{
16
        {
7
    int d0;
17
            return ( void * ) p;
8
    register void* __res;
18
        }
-
 
19
 
-
 
20
        ++p;
-
 
21
    }
-
 
22
 
9
    if (!n)
-
 
10
        return NULL;
-
 
11
    __asm__ __volatile__(
-
 
12
        "repne\n\t"
-
 
13
        "scasb\n\t"
-
 
14
        "je 1f\n\t"
-
 
15
        "movl $1,%0\n"
-
 
16
        "1:\tdecl %0"
-
 
17
        : "=D"(__res), "=&c"(d0)
-
 
18
        : "a"(c), "0"(s), "1"(n));
23
    return NULL;
19
    return __res;
24
}
20
}