Initial commit
This commit is contained in:
40
kernel/libc/libc.c
Normal file
40
kernel/libc/libc.c
Normal file
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* libc.c
|
||||
*
|
||||
* Created on: Oct 11, 2018
|
||||
* Author: rick
|
||||
*/
|
||||
|
||||
#include "libc.h"
|
||||
|
||||
int memcpy(char *dst, char *src, int amount) {
|
||||
for (int i = 0; i < amount; i++) {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int memset(char *dst, char data, int amount) {
|
||||
for (int i = 0; i < amount; ++i) {
|
||||
dst[i] = data;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int itoa(int i, char *target) {
|
||||
target[0] = (char) (i % 10 + '0');
|
||||
target[1] = '\0';
|
||||
if (i > 9) {
|
||||
itoa(i / 10, target + 1);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int strlen(char *str) {
|
||||
int length = 0;
|
||||
while (str[length] != 0) {
|
||||
length++;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user