From f74375fdecdb59ef5aaf9c3812f0fbfb1aecacec Mon Sep 17 00:00:00 2001 From: Chun-wei Fan Date: Wed, 22 Sep 2021 15:40:38 +0800 Subject: orcarm.c: Implement orc_arm_flush_cache on Windows Use the Windows API FlushInstructionCache() to flush the CPU cache on ARM64 Windows. As a consequence, include windows.h with WIN32_LEAN_AND_MEAN defined. --- orc/orcarm.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/orc/orcarm.c b/orc/orcarm.c index 94ab88e..21933d4 100644 --- a/orc/orcarm.c +++ b/orc/orcarm.c @@ -18,6 +18,10 @@ #if defined(__APPLE__) #include #endif +#if defined (_WIN32) +#define WIN32_LEAN_AND_MEAN +#include +#endif #endif /** @@ -935,6 +939,13 @@ orc_arm_flush_cache (OrcCode *code) #ifdef __APPLE__ sys_dcache_flush(code->code, code->code_size); sys_icache_invalidate(code->exec, code->code_size); +#elif defined (_WIN32) + HANDLE h_proc = GetCurrentProcess(); + + FlushInstructionCache(h_proc, code->code, code->code_size); + + if ((void *) code->exec != (void *) code->code) + FlushInstructionCache(h_proc, code->exec, code->code_size); #else __clear_cache (code->code, code->code + code->code_size); if ((void *) code->exec != (void *) code->code) -- cgit v1.2.3