15 lines
402 B
C
15 lines
402 B
C
#include <common.h>
|
|
#include <syscall.h>
|
|
|
|
void* buffer_init(usize size)
|
|
{
|
|
i32 fd = memfd_create("buffer", 0);
|
|
ftruncate(fd, size);
|
|
|
|
void* ptr = mmap(null, 2 * size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
|
mmap( ptr, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
|
|
mmap((c8*)ptr + size, size, PROT_READ | PROT_WRITE, MAP_SHARED | MAP_FIXED, fd, 0);
|
|
|
|
return ptr;
|
|
}
|