neptune/kern/libkern/buddy.h
2025-09-06 02:37:09 +02:00

22 lines
492 B
C

#ifndef BUDDY_H
#define BUDDY_H
#include <stddef.h>
#include <stdint.h>
extern uintptr_t heap_start;
extern uintptr_t heap_end;
extern char __heap_start;
extern char __heap_end;
void buddy_init(uintptr_t start, uintptr_t end);
void *buddy_alloc(size_t size);
int buddy_free(void *ptr);
/* Returns total heap memory managed by buddy allocator in bytes */
static inline size_t buddy_total_bytes(void) {
return (uintptr_t)&__heap_end - (uintptr_t)&__heap_start;
}
#endif // BUDDY_H