clear_cache/
lib.rs

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