aboutsummaryrefslogtreecommitdiff
path: root/source/arm_dynarec/map_rwx.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/arm_dynarec/map_rwx.c')
-rw-r--r--source/arm_dynarec/map_rwx.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/arm_dynarec/map_rwx.c b/source/arm_dynarec/map_rwx.c
new file mode 100644
index 0000000..d4373f7
--- /dev/null
+++ b/source/arm_dynarec/map_rwx.c
@@ -0,0 +1,16 @@
+#define _GNU_SOURCE /* MAP_ANONYMOUS */
+
+#include <sys/mman.h>
+#include <stdlib.h>
+
+void *MapRWX(void *target, size_t size) {
+ void *buf = mmap(target, size, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_PRIVATE, -1, 0);
+
+ if (buf == MAP_FAILED)
+ {
+ perror("mmap");
+ return NULL;
+ }
+
+ return buf;
+}