Slight cleanup of utils.c
Also added the missing memX functions needed for compilation. Interrupts next, I do believe.
This commit is contained in:
parent
e4500c27e3
commit
f74809718a
|
@ -39,8 +39,29 @@ void memcpy(void* dest, void* src, size_t n) {
|
|||
}
|
||||
}
|
||||
|
||||
void* memmove (void *dest, const void *src, size_t len) {
|
||||
const char *s = (char *)src;
|
||||
char *d = (char *)dest;
|
||||
|
||||
const char *nexts = s + len;
|
||||
char *nextd = d + len;
|
||||
|
||||
if (d < s) {
|
||||
while (d != nextd) {
|
||||
*d++ = *s++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (nextd != d) {
|
||||
*--nextd = *--nexts;
|
||||
}
|
||||
}
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Memory Set. Required by GCC>
|
||||
Memory Set. Required by GCC.
|
||||
* @param src: The data to be overwritten.
|
||||
* @param chr: The byte to overwrite the source with.
|
||||
* @param n: How many bytes to overwrite.
|
||||
|
@ -52,6 +73,19 @@ void memset(void* src, int chr, size_t n) {
|
|||
}
|
||||
}
|
||||
|
||||
int memcmp (const void *str1, const void *str2, size_t count) {
|
||||
const unsigned char *s1 = (unsigned char *)str1;
|
||||
const unsigned char *s2 = (unsigned char *)str2;
|
||||
|
||||
while (count-- > 0) {
|
||||
if (*s1++ != *s2++) {
|
||||
return s1[-1] < s2[-1] ? -1 : 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Turns an integer into a C-str.
|
||||
* @note Inefficient and unsafe.
|
||||
|
@ -165,7 +199,7 @@ void empty_string(char* string) {
|
|||
|
||||
* @param cause: A string, telling the basic reason for the crash.
|
||||
*/
|
||||
void panic(char* cause) {
|
||||
void panic() {
|
||||
printf("Kernel Halted.");
|
||||
|
||||
for(;;);
|
||||
|
|
Loading…
Reference in New Issue
Block a user