diff options
Diffstat (limited to 'src/kernel/libs/libc.c')
-rw-r--r-- | src/kernel/libs/libc.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/kernel/libs/libc.c b/src/kernel/libs/libc.c index 31580ff..dc5c0ac 100644 --- a/src/kernel/libs/libc.c +++ b/src/kernel/libs/libc.c @@ -1,7 +1,6 @@ #include <stddef.h> #include <stdint.h> -//#include <printf.h> -// you need to sort all these into diffrent files! TODO +// TODO clean up variable names int strncmp(const char *s1, const char *s2, unsigned int n) { int i; for(i = 0; ((i <= n) && (s1[i] != '\0') && (s2[i] != '\0')); i++) { @@ -23,7 +22,7 @@ int strcmp(const char *s1, const char *s2) { } int memcmp(const void *s1, const void *s2, size_t n) { - const unsigned char *p1 = s1; // Why is c such a bitch? + const unsigned char *p1 = s1; const unsigned char *p2 = s2; int i; for(i = 0; i < n; i++) { @@ -45,3 +44,17 @@ void memcpy(char *dest, char *src, size_t n) { dest[i] = src[i]; } } + +void bzero(void *dest, size_t size) { + unsigned char *p1 = dest; + for(uint64_t i = 0; i < size; i++) { + p1[i] = 0; + } +} + +//TODO move this function to a seperate math library +int ceil(float n) { + int low_n = (int)n; + if(n == (float)low_n) return(low_n); + return(low_n + 1); +} |