1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#![doc = include_str!("../README.md")]
#![no_std]

#[cfg(target_os = "linux")]
mod linux;
#[cfg(target_os = "linux")]
use linux::*;

#[cfg(target_os = "windows")]
mod windows;
#[cfg(target_os = "windows")]
use windows::*;

#[cfg(target_os = "macos")]
mod macos;
#[cfg(target_os = "macos")]
use macos::*;

/// Flush CPU's instruction cache at given range.
///
/// Return `false` if the cache is not successfully cleared.
///
/// # Safety
///
/// It seems that this function should be safe. However, the complexity of certain
/// instructions and syscalls make it difficult to guarantee that this function is totally
/// safe.
pub unsafe fn clear_cache<T>(start: *const T, end: *const T) -> bool {
    os_arch_clear_cache(start, end)
}