diff --git a/src/lib/libc/string/memcmp.c b/src/lib/libc/string/memcmp.c new file mode 100755 index 0000000..82edb4a --- /dev/null +++ b/src/lib/libc/string/memcmp.c @@ -0,0 +1,28 @@ +#include +#include + +int memcmp(const void * dst, const void * src, size_t length) +{ + size_t x = length / 4; + size_t y = length % 4; + size_t i; + + for (i = 0; i < x; i++) + { + if (((unsigned long *)dst)[i] > ((unsigned long *)src)[i]) + return 1; + if (((unsigned long *)dst)[i] < ((unsigned long *)src)[i]) + return -1; + } + + for (i = 0; i < y; i++) + { + if (((char *) dst)[length-y+i] > ((char *) src)[length-y+i]) + return 1; + if (((char *) dst)[length-y+i] < ((char *) src)[length-y+i]) + return -1; + } + + return 0; +} +