make the mmapped buffer configurable

This commit is contained in:
Folkert 2022-07-26 23:29:18 +02:00
parent 64c2d8d87e
commit 40d7e94a17
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
5 changed files with 37 additions and 30 deletions

View file

@ -13,8 +13,18 @@ const O_CREAT: c_int = 64;
pub const PROT_WRITE: c_int = 2;
pub const MAP_SHARED: c_int = 0x0001;
// IMPORTANT: shared memory object names must begin with / and contain no other slashes!
var MMAPPED_FILE: []const u8 = "/roc_expect_buffer";
pub fn setMmappedFile(ptr: [*]u8, length: usize) callconv(.C) usize {
MMAPPED_FILE = ptr[0..length];
// the rust side expects that a pointer is returned
return 0;
}
pub fn expectFailedStart() callconv(.C) [*]u8 {
const name = "/roc_expect_buffer"; // IMPORTANT: shared memory object names must begin with / and contain no other slashes!
const name = MMAPPED_FILE;
const shared_fd = shm_open(@ptrCast(*const i8, name), O_RDWR | O_CREAT, 0o666);