diff options
author | Marvin Borner | 2020-07-23 13:10:22 +0200 |
---|---|---|
committer | Marvin Borner | 2020-07-23 13:10:22 +0200 |
commit | 99e183a2f569729d722d83503cb851d6198fc1fe (patch) | |
tree | 21e48da4f0220022d17b420de0bf771a97985293 /src/lib/inc | |
parent | fa00718c221b64070067bcd64acbc297e4ac699c (diff) |
Some functions for stdlib
Diffstat (limited to 'src/lib/inc')
-rw-r--r-- | src/lib/inc/conv.h | 13 | ||||
-rw-r--r-- | src/lib/inc/def.h | 9 | ||||
-rw-r--r-- | src/lib/inc/math.h (renamed from src/lib/inc/string.h) | 6 | ||||
-rw-r--r-- | src/lib/inc/mem.h | 18 | ||||
-rw-r--r-- | src/lib/inc/str.h | 16 |
5 files changed, 50 insertions, 12 deletions
diff --git a/src/lib/inc/conv.h b/src/lib/inc/conv.h new file mode 100644 index 0000000..8295756 --- /dev/null +++ b/src/lib/inc/conv.h @@ -0,0 +1,13 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#ifndef CONV_H +#define CONV_H + +#include <def.h> + +int atoi(char *str); +char *htoa(u32 n); +int htoi(char *str); +char *itoa(int n); + +#endif diff --git a/src/lib/inc/def.h b/src/lib/inc/def.h index 409c0b3..42939a0 100644 --- a/src/lib/inc/def.h +++ b/src/lib/inc/def.h @@ -24,14 +24,5 @@ typedef unsigned long long u64; */ #define NULL ((void *)0) -#define malloc(n) ((void *)((HEAP += n) - n)) // TODO: Implement real/better malloc/free -#define free(x) - -/** - * Heap - */ - -extern u32 HEAP; -extern u32 HEAP_START; #endif diff --git a/src/lib/inc/string.h b/src/lib/inc/math.h index c97fada..268e3e7 100644 --- a/src/lib/inc/string.h +++ b/src/lib/inc/math.h @@ -1,10 +1,10 @@ // MIT License, Copyright (c) 2020 Marvin Borner -#ifndef STRING_H -#define STRING_H +#ifndef MATH_H +#define MATH_H #include <def.h> -u32 strlen(const char *str); +int pow(int base, int exp); #endif diff --git a/src/lib/inc/mem.h b/src/lib/inc/mem.h new file mode 100644 index 0000000..2aaf4d8 --- /dev/null +++ b/src/lib/inc/mem.h @@ -0,0 +1,18 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#ifndef MEM_H +#define MEM_H + +#include <def.h> + +#define malloc(n) ((void *)((HEAP += n) - n)) // TODO: Implement real/better malloc/free +#define free(x) + +extern u32 HEAP; +extern u32 HEAP_START; + +void *memcpy(void *dst, const void *src, u32 n); +void *memset(void *dst, int c, u32 n); +int memcmp(const void *s1, const void *s2, u32 n); + +#endif diff --git a/src/lib/inc/str.h b/src/lib/inc/str.h new file mode 100644 index 0000000..0e00e75 --- /dev/null +++ b/src/lib/inc/str.h @@ -0,0 +1,16 @@ +// MIT License, Copyright (c) 2020 Marvin Borner + +#ifndef STRING_H +#define STRING_H + +#include <def.h> + +u32 strlen(const char *s); +char *strcpy(char *dst, const char *src); +char *strchr(const char *s, int c); +char *strcat(char *dst, const char *src); +int strcmp(const char *s1, const char *s2); +char *strinv(char *s); +char *strdup(const char *s); + +#endif |