lib: c: combine libc and ulibc

libc is now made up of several independent components, each of which is individually compiled into a static library.
they are then all combined into a single shared library.
This commit is contained in:
2026-03-06 20:12:58 +00:00
parent 267b893bf4
commit 68714fa0e5
33 changed files with 1695 additions and 8483 deletions

View File

@@ -0,0 +1,16 @@
#ifndef HEAP__LIBALLOC_H_
#define HEAP__LIBALLOC_H_
struct liballoc_major;
struct liballoc_minor;
#define HEAP_INIT \
{ \
.heap_region = KERN_HANDLE_INVALID, \
.heap_liballoc = { \
.l_pageSize = 4096, \
.l_pageCount = 16, \
}, \
}
#endif

View File

@@ -0,0 +1,50 @@
#ifndef HEAP_H_
#define HEAP_H_
#include <heap/_liballoc.h>
#include <mango/types.h>
#include <stddef.h>
typedef enum heap_result {
HEAP_OK = 0,
HEAP_ERR_NO_MEMORY,
HEAP_ERR_INVALID_ARGUMENT,
} heap_result_t;
typedef struct heap {
kern_handle_t heap_region;
/* amount of space requested from the heap by the user */
size_t heap_req_alloc;
/* amount of space requested from the system by the heap */
size_t heap_sys_alloc;
/* base address of the heap */
virt_addr_t heap_base;
union {
struct {
struct liballoc_major *l_memRoot;
struct liballoc_major *l_bestBet;
unsigned int l_pageSize;
unsigned int l_pageCount;
unsigned long long l_allocated;
unsigned long long l_inuse;
long long l_warningCount;
long long l_errorCount;
long long l_possibleOverruns;
} heap_liballoc;
};
} heap_t;
extern kern_status_t heap_init(heap_t *heap, size_t size);
extern kern_status_t heap_destroy(heap_t *heap);
extern void *heap_alloc(heap_t *heap, size_t sz);
extern void *heap_realloc(heap_t *heap, void *p, size_t sz);
extern void *heap_calloc(heap_t *heap, size_t num, size_t itemsz);
extern void heap_free(heap_t *heap, void *p);
extern void *heap_expand(heap_t *heap, size_t size);
#endif