mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Added memcmp(3).
This commit is contained in:
parent
46e717e30f
commit
9064185bd8
3 changed files with 19 additions and 7 deletions
|
@ -33,6 +33,7 @@ __BEGIN_DECLS
|
||||||
@include(size_t.h)
|
@include(size_t.h)
|
||||||
@include(locale_t.h)
|
@include(locale_t.h)
|
||||||
|
|
||||||
|
int memcmp(const void*, const void*, size_t);
|
||||||
void* memcpy(void* restrict, const void* restrict, size_t);
|
void* memcpy(void* restrict, const void* restrict, size_t);
|
||||||
void* memset(void*, int, size_t);
|
void* memset(void*, int, size_t);
|
||||||
char* strcat(char* restrict, const char* restrict);
|
char* strcat(char* restrict, const char* restrict);
|
||||||
|
@ -46,7 +47,6 @@ int strncmp(const char*, const char*, size_t);
|
||||||
#ifndef SORTIX_UNIMPLEMENTED
|
#ifndef SORTIX_UNIMPLEMENTED
|
||||||
void* memccpy(void* restrict, const void* restrict, int, size_t);
|
void* memccpy(void* restrict, const void* restrict, int, size_t);
|
||||||
void* memchr(const void*, int, size_t);
|
void* memchr(const void*, int, size_t);
|
||||||
int memcmp(const void*, const void*, size_t);
|
|
||||||
void* memmove(void*, const void*, size_t);
|
void* memmove(void*, const void*, size_t);
|
||||||
char* stpcpy(char* restrict, const char* restrict);
|
char* stpcpy(char* restrict, const char* restrict);
|
||||||
char* stpncpy(char* restrict, const char* restrict, size_t);
|
char* stpncpy(char* restrict, const char* restrict, size_t);
|
||||||
|
|
|
@ -30,12 +30,13 @@ namespace Maxsi
|
||||||
{
|
{
|
||||||
namespace Memory
|
namespace Memory
|
||||||
{
|
{
|
||||||
void Init();
|
void Init();
|
||||||
void* Allocate(size_t Size);
|
void* Allocate(size_t Size);
|
||||||
void Free(void* Addr);
|
void Free(void* Addr);
|
||||||
size_t GetChunkOverhead();
|
size_t GetChunkOverhead();
|
||||||
void* Copy(void* Dest, const void* Src, size_t Length);
|
void* Copy(void* Dest, const void* Src, size_t Length);
|
||||||
void* Set(void* Dest, int Value, size_t Length);
|
void* Set(void* Dest, int Value, size_t Length);
|
||||||
|
int Compare(const void* a, const void* b, size_t size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,5 +77,16 @@ namespace Maxsi
|
||||||
|
|
||||||
return Dest;
|
return Dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DUAL_FUNCTION(int, memcmp, Compare, (const void* a, const void* b, size_t size))
|
||||||
|
{
|
||||||
|
const byte* buf1 = (const byte*) a;
|
||||||
|
const byte* buf2 = (const byte*) b;
|
||||||
|
for ( size_t i = 0; i < size; i++ )
|
||||||
|
{
|
||||||
|
if ( buf1[i] != buf2[i] ) { return (int)(buf1[i]) - (int)(buf2[i]); }
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue