oscall 0.1.1

Low-level cross-platform interface to operating system services: files, memory mapping, networking and more, with no libc on Linux
Documentation
//! `mem` on WebAssembly: a module has one linear memory, which only grows,
//! and no control over its pages. Nothing can be mapped.
//!
//! This file is also the `mem` of the `unsupported` backend.

use crate::mem::{Advice, MapOptions, Protection, Sharing};
use crate::{BorrowedHandle, ErrorKind, OwnedHandle, Result};

/// The page of WebAssembly's linear memory, fixed by the specification.
const PAGE_SIZE: usize = 1 << 16;

pub(crate) fn page_size() -> usize {
    PAGE_SIZE
}

pub(crate) fn allocation_granularity() -> usize {
    PAGE_SIZE
}

fn unsupported<T>() -> Result<T> {
    Err(ErrorKind::Unsupported.into())
}

pub(crate) fn map_anonymous(_len: usize, _options: &MapOptions) -> Result<*mut u8> {
    unsupported()
}

pub(crate) fn map_file(
    _file: BorrowedHandle<'_>,
    _offset: u64,
    _len: usize,
    _sharing: Sharing,
    _options: &MapOptions,
) -> Result<*mut u8> {
    unsupported()
}

pub(crate) fn reserve(_len: usize, _options: &MapOptions, _placeholder: bool) -> Result<*mut u8> {
    unsupported()
}

/// # Safety
///
/// None: nothing is done.
pub(crate) unsafe fn unmap(_ptr: *mut u8, _len: usize) -> Result<()> {
    unsupported()
}

/// # Safety
///
/// None: nothing is done.
pub(crate) unsafe fn protect(_ptr: *mut u8, _len: usize, _protection: Protection) -> Result<()> {
    unsupported()
}

/// # Safety
///
/// None: nothing is done.
pub(crate) unsafe fn commit(_ptr: *mut u8, _len: usize, _protection: Protection) -> Result<()> {
    unsupported()
}

/// # Safety
///
/// None: nothing is done.
pub(crate) unsafe fn decommit(_ptr: *mut u8, _len: usize) -> Result<()> {
    unsupported()
}

/// # Safety
///
/// None: nothing is done.
pub(crate) unsafe fn advise(_ptr: *mut u8, _len: usize, _advice: Advice) -> Result<()> {
    unsupported()
}

pub(crate) fn flush(_ptr: *const u8, _len: usize, _file: BorrowedHandle<'_>) -> Result<()> {
    unsupported()
}

pub(crate) fn lock(_ptr: *const u8, _len: usize) -> Result<()> {
    unsupported()
}

pub(crate) fn unlock(_ptr: *const u8, _len: usize) -> Result<()> {
    unsupported()
}

/// # Safety
///
/// None: nothing is done.
pub(crate) unsafe fn flush_instruction_cache(_ptr: *const u8, _len: usize) -> Result<()> {
    unsupported()
}

pub(crate) fn create_shared(_len: usize) -> Result<OwnedHandle> {
    unsupported()
}