clear-cache 0.1.3

A native implementation of `__builtin___clear_cache` without dependency of GCC/Clang.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use windows_sys::Win32::System::{
    Diagnostics::Debug::FlushInstructionCache, Threading::GetCurrentProcess,
};

pub(crate) unsafe fn os_arch_clear_cache<T>(start: *const T, end: *const T) -> bool {
    let res = unsafe {
        FlushInstructionCache(
            GetCurrentProcess(),
            start.cast(),
            (end as *const u8).offset_from(start as *const u8) as usize,
        )
    };
    res != 0
}