Sha256: 9e5333f750cd7380465cd34b4611c1f7b5251c11befca0d4482a323e0b1c20b2

Contents?: true

Size: 905 Bytes

Versions: 25

Compression:

Stored size: 905 Bytes

Contents

//! This module roughly corresponds to `mach/vm_page_size.h`

use vm_types::{mach_vm_offset_t, mach_vm_size_t, vm_size_t};

extern "C" {
    pub static vm_page_size: vm_size_t;
    pub static vm_page_mask: vm_size_t;
    pub static vm_page_shift: ::libc::c_int;
}

pub unsafe fn mach_vm_trunc_page(x: mach_vm_offset_t) -> mach_vm_offset_t {
    (x & !(vm_page_mask as mach_vm_size_t))
}

pub unsafe fn mach_vm_round_page(x: mach_vm_offset_t) -> mach_vm_offset_t {
    ((x + vm_page_mask as mach_vm_size_t) & !(vm_page_mask as mach_vm_size_t))
}

#[cfg(test)]
mod tests {
    use vm_page_size::*;
    use vm_types::mach_vm_size_t;

    #[test]
    fn page_size() {
        unsafe {
            assert!(vm_page_size > 0);
            assert!(vm_page_size % 2 == 0);
            assert_eq!(mach_vm_round_page(1), vm_page_size as mach_vm_size_t);
            assert_eq!(vm_page_size, 4096);
        }
    }
}

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
wasmtime-18.0.3 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-17.0.1 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-17.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-16.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-15.0.1 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-15.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-14.0.4 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-14.0.3 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-14.0.1 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-14.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-13.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-12.0.1 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-12.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-11.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-10.0.1 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-10.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-9.0.4 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-9.0.1 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-8.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs
wasmtime-7.0.0 ./ext/cargo-vendor/mach-0.3.2/src/vm_page_size.rs