mmtk/util/os/imp/unix_like/linux_like/
linux.rs1use crate::util::address::Address;
2use crate::util::os::imp::unix_like::linux_like::linux_common;
3use crate::util::os::imp::unix_like::unix_common;
4use crate::util::os::*;
5
6use std::io::Result;
7
8pub struct Linux;
10
11impl OSMemory for Linux {
12 fn dzmmap(
13 start: Address,
14 size: usize,
15 strategy: MmapStrategy,
16 annotation: &MmapAnnotation<'_>,
17 ) -> MmapResult<Address> {
18 linux_common::dzmmap(start, size, strategy, annotation)
19 }
20
21 fn munmap(start: Address, size: usize) -> Result<()> {
22 unix_common::munmap(start, size)
23 }
24
25 fn set_memory_access(start: Address, size: usize, prot: MmapProtection) -> Result<()> {
26 unix_common::mprotect(start, size, prot)
27 }
28
29 fn is_mmap_oom(os_errno: i32) -> bool {
30 unix_common::is_mmap_oom(os_errno)
31 }
32
33 fn panic_if_unmapped(start: Address, size: usize) {
34 linux_common::panic_if_unmapped(start, size)
35 }
36}
37
38impl OSProcess for Linux {
39 type ProcessIDType = unix_common::ProcessIDType;
40 type ThreadIDType = unix_common::ThreadIDType;
41
42 fn get_process_memory_maps() -> Result<String> {
43 linux_common::get_process_memory_maps()
44 }
45
46 fn get_process_id() -> Result<Self::ProcessIDType> {
47 unix_common::get_process_id()
48 }
49
50 fn get_thread_id() -> Result<Self::ThreadIDType> {
51 unix_common::get_thread_id()
52 }
53
54 fn get_total_num_cpus() -> CoreNum {
55 linux_common::get_total_num_cpus()
56 }
57
58 fn bind_current_thread_to_core(core_id: CoreId) {
59 linux_common::bind_current_thread_to_core(core_id)
60 }
61
62 fn bind_current_thread_to_cpuset(core_ids: &[CoreId]) {
63 linux_common::bind_current_thread_to_cpuset(core_ids)
64 }
65}