silk/raw_mapping
Profiles: aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu-no-libc.
Owned anonymous Linux mappings with runtime page-size and alignment checks.
When to use
Use Mapping.allocate in a raw Linux composition after startup validates AT_PAGESZ.
Each successful value owns its entire mapping and releases it on structured drop.
Gotchas
Raw pointers do not keep their mapping alive. Fatal traps do not guarantee release.
Import as Mapping with import silk.raw_mapping { Mapping }.
Public declarations: 1.
Mapping
pub struct MappingOne affine, zero-initialized anonymous mapping and its aligned usable range.
Associated function Mapping.allocate
pub fn allocate(length: usize, alignment: usize, pageSize: usize) -> silk/result.Result<silk/raw_mapping.Mapping, usize>Allocates a zero-initialized byte range with the requested alignment.
Details
The caller supplies the process page size from validated AT_PAGESZ. Size must be positive; page size and alignment must be powers of two. Invalid values and arithmetic overflow return error 22. Mapping failure returns the kernel error. Success owns one complete mapping.
Method Mapping.length
pub fn length<'life0>(self: &'life0 silk/raw_mapping.Mapping) -> usizeReturns the requested usable byte count, excluding alignment padding.
Method Mapping.pointer
pub unsafe fn pointer<'life0>(self: &'life0 mut silk/raw_mapping.Mapping) -> ?[*]mut u8Returns the aligned address of the mapping's usable range.
Gotchas
The pointer grants no ownership. Keep the mapping alive and limit accesses to length bytes.
The initial bytes are zero; subsequent reads require the caller to preserve initialization.
Associated function Mapping.release
pub fn release(value: Mapping) -> usizeReleases the complete mapping and consumes its owner.
Details
Returns zero on success or the positive kernel error. Drop makes no second release attempt.
Implementation Drop for Mapping
impl Drop for Mapping