Method: ConcurrentSHM::Region.map
- Defined in:
- ext/concurrent-shm/posix.c
.map(file, off, len) ⇒ Region
Memory-map a region of a file or shared memory space. The region is read/write and shared.
328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'ext/concurrent-shm/posix.c', line 328 static VALUE region_map(VALUE self, VALUE file, VALUE off, VALUE len) { UNUSED(self); int fd = FIX2INT(rb_funcall(file, rb_intern("fileno"), 0)); void * data = mmap(NULL, FIX2INT(len), PROT_READ | PROT_WRITE, MAP_SHARED, fd, FIX2INT(off)); if (data == MAP_FAILED) { rb_syserr_fail_strf(errno, "mmap(fd=%d, len=%d)", fd, FIX2INT(len)); } return __new_region(data, FIX2INT(len), 1, file); } |