clear_cache/
lib.rs

1#![doc = include_str!("../README.md")]
2#![no_std]
3
4#[cfg(any(target_os = "linux", target_os = "android"))]
5mod linux;
6#[cfg(any(target_os = "linux", target_os = "android"))]
7use linux::*;
8
9#[cfg(target_os = "windows")]
10mod windows;
11#[cfg(target_os = "windows")]
12use windows::*;
13
14#[cfg(target_os = "macos")]
15mod macos;
16#[cfg(target_os = "macos")]
17use macos::*;
18
19/// Flush CPU's instruction cache at given range.
20///
21/// Return `false` if the cache is not successfully cleared.
22///
23/// # Safety
24///
25/// It seems that this function should be safe. However, the complexity of certain
26/// instructions and syscalls make it difficult to guarantee that this function is totally
27/// safe.
28pub unsafe fn clear_cache<T>(start: *const T, end: *const T) -> bool {
29    os_arch_clear_cache(start, end)
30}