sys_map#
Low-level mapping with raw mmap(2) protection and flag constants.
Synopsis#
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;
Arguments#
$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.
Differences from upstream#
Fully compatible with upstream File::Map 0.71.
See also#
map_file,map_handle,map_anonymous— the high-level alternatives.protect— change protection after the mapping exists.