File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 3838void sys_icache_invalidate (void * start , size_t len );
3939#endif
4040
41+ #if LJ_TARGET_RISCV64 && LJ_TARGET_LINUX
42+ #include <unistd.h>
43+ #include <sys/syscall.h>
44+ #include <sys/cachectl.h>
45+ #endif
46+
4147/* Synchronize data/instruction cache. */
4248void lj_mcode_sync (void * start , void * end )
4349{
@@ -52,6 +58,17 @@ void lj_mcode_sync(void *start, void *end)
5258 sys_icache_invalidate (start , (char * )end - (char * )start );
5359#elif LJ_TARGET_PPC
5460 lj_vm_cachesync (start , end );
61+ #elif LJ_TARGET_RISCV64 && LJ_TARGET_LINUX
62+ #if (defined(__GNUC__ ) || defined(__clang__ ))
63+ __asm__ volatile ("fence rw, rw" );
64+ #else
65+ lj_vm_fence_rw_rw ();
66+ #endif
67+ #ifdef __GLIBC__
68+ __riscv_flush_icache (start , end , 0 );
69+ #else
70+ syscall (__NR_riscv_flush_icache , start , end , 0UL );
71+ #endif
5572#elif defined(__GNUC__ ) || defined(__clang__ )
5673 __clear_cache (start , end );
5774#else
You can’t perform that action at this time.
0 commit comments