sys_map#
Low-level mapping with raw mmap(2) protection and flag constants.
תקציר#
use File::Map qw(sys_map :constants);
sys_map my $map, $length, PROT_READ | PROT_WRITE,
MAP_SHARED, $fh, 0;
sys_map my $buf, 4096, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS;
ארגומנטים#
$lvalue- scalar to receive the mapping.$length- size in bytes.$protection- bitwise-or ofPROT_NONE,PROT_READ,PROT_WRITE,PROT_EXEC.$flags- bitwise-or ofMAP_SHARED,MAP_PRIVATE,MAP_ANONYMOUS,MAP_ANON,MAP_FILE.$filehandle- omitted orundefwhenMAP_ANONYMOUSis set.$offset- byte offset into the file. Defaults to0.
When to reach for it#
Use sys_map only when map_file, map_handle, or map_anonymous cannot express what you need - for example, to request PROT_EXEC on an executable page, or to combine flags that the convenience functions do not expose. If the mmap(2) man page does not feel familiar, map_file or map_anonymous is almost certainly the better choice.
הבדלים מן ה-upstream#
Fully compatible with upstream File::Map 0.71.
ראו גם#
map_file,map_handle,map_anonymous- the high-level alternatives.protect- change protection after the mapping exists.