luaur_code_gen/functions/
flush_instruction_cache_code_allocator.rs1use crate::functions::flush_instruction_cache_code_allocator_alt_b::flush_instruction_cache_mut;
2use crate::macros::codegen_assert::CODEGEN_ASSERT;
3
4#[allow(non_snake_case)]
5pub fn flush_instruction_cache(mem: *mut u8, size: usize) {
6 #[cfg(target_os = "windows")]
7 {
8 use core::ffi::c_void;
9 use windows_sys::Win32::System::Diagnostics::Debug::FlushInstructionCache;
10 use windows_sys::Win32::System::Threading::GetCurrentProcess;
11
12 unsafe {
13 if FlushInstructionCache(GetCurrentProcess(), mem as *const c_void, size) == 0 {
14 CODEGEN_ASSERT!(false);
15 }
16 }
17 }
18 #[cfg(not(target_os = "windows"))]
19 {
20 flush_instruction_cache_mut(mem, size);
21 }
22}