Commit 8cf50c9a authored by Mathieu Maret's avatar Mathieu Maret

implement memcmp

parent 3f258485
#include "klibc.h"
int memcmp(const void* aptr, const void* bptr, size_t size) {
const unsigned char* a = (const unsigned char*) aptr;
const unsigned char* b = (const unsigned char*) bptr;
for (size_t i = 0; i < size; i++) {
if (a[i] < b[i])
return -1;
else if (b[i] < a[i])
return 1;
}
return 0;
}
void *memcpy(void *dst, const void *src, size_t n)
{
char *dstChar = dst;
......
......@@ -9,6 +9,7 @@
((c) == '\r') || ((c) == '\v'))
#define isprint(c) ((' ' <= (c)) && ((c) <= '~'))
int memcmp(const void *s1, const void *s2, size_t n);
void *memcpy(void *dest, const void *src, size_t n);
void *memset(void *s, int c, size_t n);
char *itoa(int value, char *str, int base);
......
......@@ -38,7 +38,7 @@ void kmain(unsigned long magic, unsigned long addr)
irqSetup();
pitSetup(100);
if (magic == MULTIBOOT_BOOTLOADER_MAGIC) { // Get loaded by Grub wuth mutliboot version 1
if (magic == MULTIBOOT_BOOTLOADER_MAGIC) { // Get loaded by Grub with mutliboot version 1
multiboot_info_t *mbi = (multiboot_info_t *)addr;
/* Are mem_* valid? */
if (CHECK_FLAG(mbi->flags, 0)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment