diff options
Diffstat (limited to 'ARMeilleure/Native/macos_jit_support')
| -rw-r--r-- | ARMeilleure/Native/macos_jit_support/Makefile | 8 | ||||
| -rw-r--r-- | ARMeilleure/Native/macos_jit_support/support.c | 14 |
2 files changed, 22 insertions, 0 deletions
diff --git a/ARMeilleure/Native/macos_jit_support/Makefile b/ARMeilleure/Native/macos_jit_support/Makefile new file mode 100644 index 00000000..d6da35d5 --- /dev/null +++ b/ARMeilleure/Native/macos_jit_support/Makefile @@ -0,0 +1,8 @@ +NAME = libarmeilleure-jitsupport.dylib + +all: ${NAME} + +${NAME}: + clang -O3 -dynamiclib support.c -o ${NAME} +clean: + rm -f ${NAME} diff --git a/ARMeilleure/Native/macos_jit_support/support.c b/ARMeilleure/Native/macos_jit_support/support.c new file mode 100644 index 00000000..1b13d906 --- /dev/null +++ b/ARMeilleure/Native/macos_jit_support/support.c @@ -0,0 +1,14 @@ +#include <stddef.h> +#include <string.h> +#include <pthread.h> + +#include <libkern/OSCacheControl.h> + +void armeilleure_jit_memcpy(void *dst, const void *src, size_t n) { + pthread_jit_write_protect_np(0); + memcpy(dst, src, n); + pthread_jit_write_protect_np(1); + + // Ensure that the instruction cache for this range is invalidated. + sys_icache_invalidate(dst, n); +} |
