/* Written by Stone Horse. Public domain
 *
 * This file contains functions and procedures that depend on a kernel
 * and dynamic memory
 * It builds upon `core.h'
 */
#define MAP_SHARED 1
#define MAP_PRIVATE 2
#define MAP_SHARED_VALIDATE 3
#define MAP_TYPE 15
#define MAP_FIXED 16
#ifdef __NetBSD__
#define MAP_ANON 4096
#else
#define MAP_ANON 32
#endif
#define MAP_ANONYMOUS  MAP_ANON
#define MAP_NORESERVE 16384
#define MAP_GROWSDOWN 256
#define MAP_DENYWRITE 2048
#define MAP_EXECUTABLE 4096
#define MAP_LOCKED 8192
#define MAP_POPULATE 32768
#define MAP_NONBLOCK 65536
#define MAP_STACK 131072
#define MAP_HUGETLB 262144
#define MAP_SYNC 524288
#define MAP_FIXED_NOREPLACE 1048576
#define MAP_FILE 0

#define PROT_NONE 0
#define PROT_READ 1
#define PROT_WRITE 2
#define PROT_EXEC 4
#define PROT_GROWSDOWN 16777216
#define PROT_GROWSUP 33554432

struct memory_pool {
	char *pool;
	unsigned int used;
	unsigned int size;
};

extern void *mmap(void *addr, unsigned int len, int prot, int flags, int fd, unsigned int offset);
extern int munmap(void *start, unsigned int size);
extern struct memory_pool *pool_new(unsigned int size);
extern void *pool_alloc(struct memory_pool *mp, unsigned int size);
extern void pool_close(struct memory_pool *mp);

#endif
