This commit is contained in:
2024-03-23 21:44:27 +01:00
parent 5a28cd640f
commit e52b9ee3c0
2 changed files with 35 additions and 0 deletions

View File

@@ -1,6 +1,10 @@
#ifndef OS1_KMEM_H
#define OS1_KMEM_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <stdint.h>
@@ -28,4 +32,8 @@ void *krealloc(void *addr, size_t newsize);
uint64_t get_heap_allocated();
uint64_t get_heap_used();
#ifdef __cplusplus
}
#endif
#endif

27
src/kernel/stdlib.h Normal file
View File

@@ -0,0 +1,27 @@
//
// Created by Stepan Usatiuk on 23.03.2024.
//
#ifndef OS2_STDLIB_H
#define OS2_STDLIB_H
#include "kmem.hpp"
#ifdef __cplusplus
extern "C" {
#endif
static inline void free(void *ptr) { return kfree(ptr); }
static inline void *calloc(size_t nmemb, size_t size) {
void *ret = kmalloc(nmemb * size);
__builtin_memset(ret, 0, nmemb * size);
return ret;
}
static inline void *malloc(size_t size) { return kmalloc(size); }
static inline void *realloc(void *ptr, size_t size) { return krealloc(ptr, size); }
#ifdef __cplusplus
}
#endif
#endif //OS2_STDLIB_H