aboutsummaryrefslogtreecommitdiff
path: root/libc/inc/mem.h
blob: 216b939ae2a302255fa8e7006f92f26bba06348a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// MIT License, Copyright (c) 2020 Marvin Borner

#ifndef MEM_H
#define MEM_H

#include <def.h>

int malloc_allocated;

void *malloc_debug(u32 size, const char *file, int line, const char *func, const char *inp);
void free_debug(void *ptr, const char *file, int line, const char *func, const char *inp);
#define malloc(size) malloc_debug(size, __FILE__, __LINE__, __func__, #size)
#define free(ptr) free_debug(ptr, __FILE__, __LINE__, __func__, #ptr)
void *zalloc(u32 size);

#ifdef kernel
void heap_init(u32 start);
#elif defined(userspace)
#else
#error "No lib target specified. Please use -Dkernel or -Duserspace"
#endif

void *memcpy(void *dest, const void *src, u32 n);
void *memset(void *dest, int val, u32 n);
void *memchr(void *src, int c, u32 n);
int memcmp(const void *s1, const void *s2, u32 n);
int mememp(const u8 *buf, u32 n);

#endif