From 0a146fb14ab54ff22ada1cd60292e4f0b86e4fa6 Mon Sep 17 00:00:00 2001 From: Avril Date: Fri, 21 Oct 2022 02:24:33 +0100 Subject: [PATCH] Added doc-comment for `hugetlb::HugePage` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fortune for mapped-file's current commit: Future small blessing − 末小吉 --- Cargo.toml | 2 +- src/file/memory.rs | 2 +- src/hugetlb.rs | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9a7a2c3..264e722 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "mapped-file" description = "Construct a memory mapping over any file object" keywords = ["unix", "mmap", "generic", "file", "fd"] -version = "0.0.1" +version = "0.0.2" edition = "2021" repository="https://github.com/notflan/mapped-file" license="MIT" diff --git a/src/file/memory.rs b/src/file/memory.rs index 2628ac1..a02283c 100644 --- a/src/file/memory.rs +++ b/src/file/memory.rs @@ -167,7 +167,7 @@ impl NamedMemoryFile Ok(Self(name, MemoryFile(managed))) } - pub fn with_hugetlb(name: impl AsRef, hugetlb: MapHugeFlag) -> io::Result + pub fn with_hugetlb(name: impl AsRef, hugetlb: MapHugeFlag) -> io::Result { let name: Box = alloc_cstring(name.as_ref()).into(); let memfd = MemoryFile(unsafe { create_raw(&name, DEFAULT_FLAGS | (hugetlb.get_mask() as c_uint)) } diff --git a/src/hugetlb.rs b/src/hugetlb.rs index fb06a6c..ccd92fa 100644 --- a/src/hugetlb.rs +++ b/src/hugetlb.rs @@ -140,6 +140,12 @@ impl From for c_int } } +/// Provides an arbitrary huge-page size and mapping flag for that size. +/// +/// Can store or create a `MAP_HUGE_*` flag for use with `mmap()`, (`MappedFile`) or `memfd_create()` (`file::MemoryFile::with_hugetlb()`) +/// +/// # Usage +/// Main usage is for generating a `MapHugeFlag` via `compute_huge()`. This function may fail (rarely), so a `TryInto` impl exists for `MapHugeFlag` as well. #[derive(Default, Clone, Copy)] pub enum HugePage { /// A staticly presented `MAP_HUGE_*` flag. See `MapHugeFlag` for details.