diff options
| author | Ian McFarlane <i.mcfarlane2002@gmail.com> | 2025-04-17 14:19:40 -0400 |
|---|---|---|
| committer | Ian McFarlane <i.mcfarlane2002@gmail.com> | 2025-04-17 14:19:40 -0400 |
| commit | 7108e7c951f7cff79ce4992f1c7d8d0af0bb5af6 (patch) | |
| tree | e99684b87952bded5e51c83848a5d35ab53d9ab0 /kernel/include/lib | |
| parent | starting on ata (diff) | |
| parent | clang 18 in flake instead of zig (diff) | |
| download | comus-7108e7c951f7cff79ce4992f1c7d8d0af0bb5af6.tar.gz comus-7108e7c951f7cff79ce4992f1c7d8d0af0bb5af6.tar.bz2 comus-7108e7c951f7cff79ce4992f1c7d8d0af0bb5af6.zip | |
Merge branch 'main' into ata
Diffstat (limited to 'kernel/include/lib')
| -rw-r--r-- | kernel/include/lib/kctype.h | 5 | ||||
| -rw-r--r-- | kernel/include/lib/kio.h | 10 | ||||
| -rw-r--r-- | kernel/include/lib/klib.h | 25 |
3 files changed, 40 insertions, 0 deletions
diff --git a/kernel/include/lib/kctype.h b/kernel/include/lib/kctype.h index 6d090c6..aee1bb9 100644 --- a/kernel/include/lib/kctype.h +++ b/kernel/include/lib/kctype.h @@ -19,4 +19,9 @@ int isspace(int c); */ int isdigit(int c); +/** + * @returns if a character is ascii printable + */ +int isprint(int c); + #endif /* kctype.h */ diff --git a/kernel/include/lib/kio.h b/kernel/include/lib/kio.h index 66efc7b..1b10a39 100644 --- a/kernel/include/lib/kio.h +++ b/kernel/include/lib/kio.h @@ -26,6 +26,16 @@ void kputc(char c); */ void kputs(const char *s); +#ifdef TRACING +#define TRACE(format, ...) \ + do { \ + kprintf("[TRACE] %s ", __FUNCTION__); \ + kprintf(format, ##__VA_ARGS__); \ + } while (0) +#else +#define TRACE(format, ...) +#endif + /** * prints out a formatted string * diff --git a/kernel/include/lib/klib.h b/kernel/include/lib/klib.h index 7f66e90..0d9797b 100644 --- a/kernel/include/lib/klib.h +++ b/kernel/include/lib/klib.h @@ -231,4 +231,29 @@ void log_backtrace(void); */ void log_backtrace_ex(void *ip, void *bp); +/** + * Allocates size_t bytes in memory + * + * @param size - the amount of bytes to allocate + * @returns the address allocated or NULL on failure + */ +void *kalloc(size_t size); + +/** + * Rellocates a given allocated ptr to a new size of bytes in memory. + * If ptr is NULL it will allocate new memory. + * + * @param ptr - the pointer to reallocate + * @param size - the amount of bytes to reallocate to + * @returns the address allocated or NULL on failure + */ +void *krealloc(void *ptr, size_t size); + +/** + * Frees an allocated pointer in memory + * + * @param ptr - the pointer to free + */ +void kfree(void *ptr); + #endif /* klib.h */ |