mirror of
https://github.com/usatiuk/ficus.git
synced 2025-10-29 00:27:52 +01:00
stdlib.h
This commit is contained in:
@@ -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
27
src/kernel/stdlib.h
Normal 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
|
||||
Reference in New Issue
Block a user