about summary refs log tree commit diff stats
path: root/src
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-02-27 09:48:00 +0100
committerptitSeb <sebastien.chev@gmail.com>2022-02-27 09:48:00 +0100
commit0cdb134d45ba7249a9f15d10e46b10e926abae60 (patch)
treefd5500db049bd2fa5a9870a8df3c5a1263f0b521 /src
parentea6d95986eb121f47e1127703485fad706aade30 (diff)
downloadbox64-0cdb134d45ba7249a9f15d10e46b10e926abae60.tar.gz
box64-0cdb134d45ba7249a9f15d10e46b10e926abae60.zip
[DYNAREC] Refactored dynarec to ease the future adding of new target architecture
Diffstat (limited to 'src')
-rw-r--r--src/custommem.c59
-rwxr-xr-xsrc/dynarec/arm64/arm64_emitter.h (renamed from src/dynarec/arm64_emitter.h)0
-rwxr-xr-xsrc/dynarec/arm64/arm64_epilog.S (renamed from src/dynarec/arm64_epilog.S)0
-rwxr-xr-xsrc/dynarec/arm64/arm64_lock.S (renamed from src/dynarec/arm64_lock.S)0
-rwxr-xr-xsrc/dynarec/arm64/arm64_lock.h (renamed from src/dynarec/arm64_lock.h)0
-rwxr-xr-xsrc/dynarec/arm64/arm64_next.S (renamed from src/dynarec/arm64_next.S)0
-rwxr-xr-xsrc/dynarec/arm64/arm64_printer.c (renamed from src/dynarec/arm64_printer.c)0
-rw-r--r--src/dynarec/arm64/arm64_printer.h (renamed from src/dynarec/arm64_printer.h)0
-rwxr-xr-xsrc/dynarec/arm64/arm64_prolog.S (renamed from src/dynarec/arm64_prolog.S)0
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_00.c (renamed from src/dynarec/dynarec_arm64_00.c)16
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_0f.c (renamed from src/dynarec/dynarec_arm64_0f.c)10
-rw-r--r--src/dynarec/arm64/dynarec_arm64_64.c (renamed from src/dynarec/dynarec_arm64_64.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_66.c (renamed from src/dynarec/dynarec_arm64_66.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_660f.c (renamed from src/dynarec/dynarec_arm64_660f.c)6
-rw-r--r--src/dynarec/arm64/dynarec_arm64_6664.c (renamed from src/dynarec/dynarec_arm64_6664.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_67.c (renamed from src/dynarec/dynarec_arm64_67.c)10
-rw-r--r--src/dynarec/arm64/dynarec_arm64_d8.c (renamed from src/dynarec/dynarec_arm64_d8.c)6
-rw-r--r--src/dynarec/arm64/dynarec_arm64_d9.c (renamed from src/dynarec/dynarec_arm64_d9.c)6
-rw-r--r--src/dynarec/arm64/dynarec_arm64_db.c (renamed from src/dynarec/dynarec_arm64_db.c)6
-rw-r--r--src/dynarec/arm64/dynarec_arm64_dc.c (renamed from src/dynarec/dynarec_arm64_dc.c)6
-rw-r--r--src/dynarec/arm64/dynarec_arm64_dd.c (renamed from src/dynarec/dynarec_arm64_dd.c)6
-rw-r--r--src/dynarec/arm64/dynarec_arm64_df.c (renamed from src/dynarec/dynarec_arm64_df.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_emit_logic.c (renamed from src/dynarec/dynarec_arm64_emit_logic.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_emit_math.c (renamed from src/dynarec/dynarec_arm64_emit_math.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_emit_shift.c (renamed from src/dynarec/dynarec_arm64_emit_shift.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_emit_tests.c (renamed from src/dynarec/dynarec_arm64_emit_tests.c)6
-rw-r--r--src/dynarec/arm64/dynarec_arm64_f0.c (renamed from src/dynarec/dynarec_arm64_f0.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_f20f.c (renamed from src/dynarec/dynarec_arm64_f20f.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_f30f.c (renamed from src/dynarec/dynarec_arm64_f30f.c)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_functions.c (renamed from src/dynarec/dynarec_arm64_functions.c)2
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_functions.h (renamed from src/dynarec/dynarec_arm64_functions.h)0
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_helper.c (renamed from src/dynarec/dynarec_arm64_helper.c)8
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_helper.h (renamed from src/dynarec/dynarec_arm64_helper.h)74
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_pass.c (renamed from src/dynarec/dynarec_arm64_pass.c)7
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_pass0.h (renamed from src/dynarec/dynarec_arm64_pass0.h)0
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_pass1.h (renamed from src/dynarec/dynarec_arm64_pass1.h)0
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_pass2.h (renamed from src/dynarec/dynarec_arm64_pass2.h)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_pass3.h (renamed from src/dynarec/dynarec_arm64_pass3.h)6
-rwxr-xr-xsrc/dynarec/arm64/dynarec_arm64_private.h (renamed from src/dynarec/dynarec_arm64_private.h)8
-rwxr-xr-xsrc/dynarec/dynablock.c22
-rwxr-xr-xsrc/dynarec/dynarec_arch.h24
-rwxr-xr-xsrc/dynarec/dynarec_native.c (renamed from src/dynarec/dynarec_arm64.c)60
-rwxr-xr-xsrc/dynarec/native_lock.h25
-rwxr-xr-xsrc/emu/x64run.c2
-rw-r--r--src/emu/x64run0f.c2
-rw-r--r--src/emu/x64run66.c2
-rw-r--r--src/emu/x64run66f0.c58
-rw-r--r--src/emu/x64run670f.c2
-rw-r--r--src/emu/x64run6766.c2
-rw-r--r--src/emu/x64runf0.c170
-rwxr-xr-xsrc/include/dynarec_native.h (renamed from src/include/dynarec_arm64.h)0
51 files changed, 362 insertions, 315 deletions
diff --git a/src/custommem.c b/src/custommem.c
index ff777bc4..c92b7b03 100644
--- a/src/custommem.c
+++ b/src/custommem.c
@@ -24,7 +24,7 @@
 #include "threads.h"
 #ifdef DYNAREC
 #include "dynablock.h"
-#include "dynarec/arm64_lock.h"
+#include "dynarec/native_lock.h"
 
 //#define USE_MMAP
 
@@ -579,17 +579,17 @@ void addDBFromAddressRange(uintptr_t addr, size_t size)
         int idx1 = (i    )&((1<<DYNAMAP_SHIFT)-1);
         if(!dynmap123[idx3]) {
             dynablocklist_t*** p = (dynablocklist_t***)calloc(1<<DYNAMAP_SHIFT, sizeof(dynablocklist_t**));
-            if(arm64_lock_storeifnull(&dynmap123[idx3], p)!=p)
+            if(native_lock_storeifnull(&dynmap123[idx3], p)!=p)
                 free(p);
         }
         if(!dynmap123[idx3][idx2]) {
             dynablocklist_t** p = (dynablocklist_t**)calloc(1<<DYNAMAP_SHIFT, sizeof(dynablocklist_t*));
-            if(arm64_lock_storeifnull(&dynmap123[idx3][idx2], p)!=p)
+            if(native_lock_storeifnull(&dynmap123[idx3][idx2], p)!=p)
                 free(p);
         }
         if(!dynmap123[idx3][idx2][idx1]) {
             dynablocklist_t* p = NewDynablockList(i<<DYNAMAP_SHIFT, 1<<DYNAMAP_SHIFT, 0);
-            if(arm64_lock_storeifnull(&dynmap123[idx3][idx2][idx1], p)!=p)
+            if(native_lock_storeifnull(&dynmap123[idx3][idx2][idx1], p)!=p)
                 FreeDynablockList(&p);
         }
     }
@@ -618,13 +618,13 @@ void cleanDBFromAddressRange(uintptr_t addr, size_t size, int destroy)
                 if(destroy) {
                     if(FreeRangeDynablock(dblist, addr, size) && 0) {    // dblist is empty, check if we can delete more...
                         // disabling this for now. It seems to cause random crash in Terraria
-                        if(!arm64_lock_storeifref(&dynmap123[idx3][idx2][idx1], NULL, dblist)) {
+                        if(!native_lock_storeifref(&dynmap123[idx3][idx2][idx1], NULL, dblist)) {
                             dynablocklist_t** p = dynmap123[idx3][idx2];
                             if(dynmapempty((void**)p)) {
-                                if(!arm64_lock_storeifref(&dynmap123[idx3][idx2], NULL, p)) {
+                                if(!native_lock_storeifref(&dynmap123[idx3][idx2], NULL, p)) {
                                     dynablocklist_t*** p2 = dynmap123[idx3];
                                     if(dynmapempty((void**)p2)) {
-                                        if(!arm64_lock_storeifref(&dynmap123[idx3], NULL, p2)) {
+                                        if(!native_lock_storeifref(&dynmap123[idx3], NULL, p2)) {
                                             free(p2);
                                         }
                                     }
@@ -643,6 +643,9 @@ void cleanDBFromAddressRange(uintptr_t addr, size_t size, int destroy)
 
 #ifdef ARM64
 void arm64_next(void);
+#define native_next arm64_next
+#else
+#error Unsupported architecture
 #endif
 
 void addJumpTableIfDefault64(void* addr, void* jmp)
@@ -656,25 +659,25 @@ void addJumpTableIfDefault64(void* addr, void* jmp)
         uintptr_t*** tbl = (uintptr_t***)malloc((1<<JMPTABL_SHIFT)*sizeof(uintptr_t**));
         for(int i=0; i<(1<<JMPTABL_SHIFT); ++i)
             tbl[i] = box64_jmptbldefault1;
-        if(arm64_lock_storeifref(&box64_jmptbl3[idx3], tbl, box64_jmptbldefault2)!=tbl)
+        if(native_lock_storeifref(&box64_jmptbl3[idx3], tbl, box64_jmptbldefault2)!=tbl)
             free(tbl);
     }
     if(box64_jmptbl3[idx3][idx2] == box64_jmptbldefault1) {
         uintptr_t** tbl = (uintptr_t**)malloc((1<<JMPTABL_SHIFT)*sizeof(uintptr_t*));
         for(int i=0; i<(1<<JMPTABL_SHIFT); ++i)
             tbl[i] = box64_jmptbldefault0;
-        if(arm64_lock_storeifref(&box64_jmptbl3[idx3][idx2], tbl, box64_jmptbldefault1)!=tbl)
+        if(native_lock_storeifref(&box64_jmptbl3[idx3][idx2], tbl, box64_jmptbldefault1)!=tbl)
             free(tbl);
     }
     if(box64_jmptbl3[idx3][idx2][idx1] == box64_jmptbldefault0) {
         uintptr_t* tbl = (uintptr_t*)malloc((1<<JMPTABL_SHIFT)*sizeof(uintptr_t));
         for(int i=0; i<(1<<JMPTABL_SHIFT); ++i)
-            tbl[i] = (uintptr_t)arm64_next;
-        if(arm64_lock_storeifref(&box64_jmptbl3[idx3][idx2][idx1], tbl, box64_jmptbldefault0)!=tbl)
+            tbl[i] = (uintptr_t)native_next;
+        if(native_lock_storeifref(&box64_jmptbl3[idx3][idx2][idx1], tbl, box64_jmptbldefault0)!=tbl)
             free(tbl);
     }
 
-    arm64_lock_storeifref(&box64_jmptbl3[idx3][idx2][idx1][idx0], jmp, arm64_next);
+    native_lock_storeifref(&box64_jmptbl3[idx3][idx2][idx1][idx0], jmp, native_next);
 }
 void setJumpTableDefault64(void* addr)
 {
@@ -689,9 +692,9 @@ void setJumpTableDefault64(void* addr)
         return;
     if(box64_jmptbl3[idx3][idx2][idx1] == box64_jmptbldefault0)
         return;
-    if(box64_jmptbl3[idx3][idx2][idx1][idx0]==(uintptr_t)arm64_next)
+    if(box64_jmptbl3[idx3][idx2][idx1][idx0]==(uintptr_t)native_next)
         return;
-    box64_jmptbl3[idx3][idx2][idx1][idx0] = (uintptr_t)arm64_next;
+    box64_jmptbl3[idx3][idx2][idx1][idx0] = (uintptr_t)native_next;
 }
 int isJumpTableDefault64(void* addr)
 {
@@ -706,9 +709,9 @@ int isJumpTableDefault64(void* addr)
         return 1;
     if(box64_jmptbl3[idx3][idx2][idx1] == box64_jmptbldefault0)
         return 1;
-    if(box64_jmptbl3[idx3][idx2][idx1][idx0]==(uintptr_t)arm64_next)
+    if(box64_jmptbl3[idx3][idx2][idx1][idx0]==(uintptr_t)native_next)
         return 1;
-    return (box64_jmptbl3[idx3][idx2][idx1][idx0]==(uintptr_t)arm64_next)?1:0;
+    return (box64_jmptbl3[idx3][idx2][idx1][idx0]==(uintptr_t)native_next)?1:0;
 }
 uintptr_t getJumpTable64()
 {
@@ -726,21 +729,21 @@ uintptr_t getJumpTableAddress64(uintptr_t addr)
         uintptr_t*** tbl = (uintptr_t***)malloc((1<<JMPTABL_SHIFT)*sizeof(uintptr_t**));
         for(int i=0; i<(1<<JMPTABL_SHIFT); ++i)
             tbl[i] = box64_jmptbldefault1;
-        if(arm64_lock_storeifref(&box64_jmptbl3[idx3], tbl, box64_jmptbldefault2)!=tbl)
+        if(native_lock_storeifref(&box64_jmptbl3[idx3], tbl, box64_jmptbldefault2)!=tbl)
             free(tbl);
     }
     if(box64_jmptbl3[idx3][idx2] == box64_jmptbldefault1) {
         uintptr_t** tbl = (uintptr_t**)malloc((1<<JMPTABL_SHIFT)*sizeof(uintptr_t*));
         for(int i=0; i<(1<<JMPTABL_SHIFT); ++i)
             tbl[i] = box64_jmptbldefault0;
-        if(arm64_lock_storeifref(&box64_jmptbl3[idx3][idx2], tbl, box64_jmptbldefault1)!=tbl)
+        if(native_lock_storeifref(&box64_jmptbl3[idx3][idx2], tbl, box64_jmptbldefault1)!=tbl)
             free(tbl);
     }
     if(box64_jmptbl3[idx3][idx2][idx1] == box64_jmptbldefault0) {
         uintptr_t* tbl = (uintptr_t*)malloc((1<<JMPTABL_SHIFT)*sizeof(uintptr_t));
         for(int i=0; i<(1<<JMPTABL_SHIFT); ++i)
-            tbl[i] = (uintptr_t)arm64_next;
-        if(arm64_lock_storeifref(&box64_jmptbl3[idx3][idx2][idx1], tbl, box64_jmptbldefault0)!=tbl)
+            tbl[i] = (uintptr_t)native_next;
+        if(native_lock_storeifref(&box64_jmptbl3[idx3][idx2][idx1], tbl, box64_jmptbldefault0)!=tbl)
             free(tbl);
     }
 
@@ -762,7 +765,7 @@ void protectDB(uintptr_t addr, uintptr_t size)
     for (uintptr_t i=(idx>>16); i<=(end>>16); ++i)
         if(memprot[i]==memprot_default) {
             uint8_t* newblock = calloc(1<<16, sizeof(uint8_t));
-            /*if (arm64_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
+            /*if (native_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
                 free(newblock);
             }*/
             memprot[i] = newblock;
@@ -795,7 +798,7 @@ void unprotectDB(uintptr_t addr, size_t size)
     for (uintptr_t i=(idx>>16); i<=(end>>16); ++i)
         if(memprot[i]==memprot_default) {
             uint8_t* newblock = calloc(1<<16, sizeof(uint8_t));
-            /*if (arm64_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
+            /*if (native_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
                 free(newblock);
             }*/
             memprot[i] = newblock;
@@ -851,7 +854,7 @@ void updateProtection(uintptr_t addr, size_t size, uint32_t prot)
         if(memprot[i]==memprot_default) {
             uint8_t* newblock = calloc(1<<16, sizeof(uint8_t));
 #if 0 //def ARM64   //disabled for now, not usefull with the mutex
-            if (arm64_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
+            if (native_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
                 free(newblock);
             }
 #else
@@ -880,7 +883,7 @@ void setProtection(uintptr_t addr, size_t size, uint32_t prot)
         if(memprot[i]==memprot_default) {
             uint8_t* newblock = calloc(MEMPROT_SIZE, sizeof(uint8_t));
 #if 0 //def ARM64   //disabled for now, not usefull with the mutex
-            if (arm64_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
+            if (native_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
                 free(newblock);
             }
 #else
@@ -906,7 +909,7 @@ void allocProtection(uintptr_t addr, size_t size, uint32_t prot)
         if(memprot[i]==memprot_default) {
             uint8_t* newblock = calloc(1<<16, sizeof(uint8_t));
 #if 0 //def ARM64   //disabled for now, not usefull with the mutex
-            if (arm64_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
+            if (native_lock_storeifref(&memprot[i], newblock, memprot_default) != newblock) {
                 free(newblock);
             }
 #else
@@ -973,9 +976,9 @@ void freeProtection(uintptr_t addr, size_t size)
             memset(block+start, 0, finish-start+1);
 #if 0 //def ARM64   //disabled for now, not usefull with the mutex
             if (blockempty(block)) {
-                block = (void*)arm64_lock_xchg(&memprot[key], (uintptr_t)memprot_default);
+                block = (void*)native_lock_xchg(&memprot[key], (uintptr_t)memprot_default);
                 if(!blockempty(block)) {
-                    block = (void*)arm64_lock_xchg(&memprot[key], (uintptr_t)block);
+                    block = (void*)native_lock_xchg(&memprot[key], (uintptr_t)block);
                     for (int i = 0; i < 0x10000; ++i) {
                         memprot[key][i] |= block[i];
                     }
@@ -1162,7 +1165,7 @@ void init_custommem_helper(box64context_t* ctx)
 #ifdef ARM64
     if(box64_dynarec)
         for(int i=0; i<(1<<JMPTABL_SHIFT); ++i) {
-            box64_jmptbldefault0[i] = (uintptr_t)arm64_next;
+            box64_jmptbldefault0[i] = (uintptr_t)native_next;
             box64_jmptbldefault1[i] = box64_jmptbldefault0;
             box64_jmptbldefault2[i] = box64_jmptbldefault1;
             box64_jmptbl3[i] = box64_jmptbldefault2;
diff --git a/src/dynarec/arm64_emitter.h b/src/dynarec/arm64/arm64_emitter.h
index b69ef087..b69ef087 100755
--- a/src/dynarec/arm64_emitter.h
+++ b/src/dynarec/arm64/arm64_emitter.h
diff --git a/src/dynarec/arm64_epilog.S b/src/dynarec/arm64/arm64_epilog.S
index 4b73803a..4b73803a 100755
--- a/src/dynarec/arm64_epilog.S
+++ b/src/dynarec/arm64/arm64_epilog.S
diff --git a/src/dynarec/arm64_lock.S b/src/dynarec/arm64/arm64_lock.S
index 9d097ff5..9d097ff5 100755
--- a/src/dynarec/arm64_lock.S
+++ b/src/dynarec/arm64/arm64_lock.S
diff --git a/src/dynarec/arm64_lock.h b/src/dynarec/arm64/arm64_lock.h
index 8f6bd14d..8f6bd14d 100755
--- a/src/dynarec/arm64_lock.h
+++ b/src/dynarec/arm64/arm64_lock.h
diff --git a/src/dynarec/arm64_next.S b/src/dynarec/arm64/arm64_next.S
index 5e890137..5e890137 100755
--- a/src/dynarec/arm64_next.S
+++ b/src/dynarec/arm64/arm64_next.S
diff --git a/src/dynarec/arm64_printer.c b/src/dynarec/arm64/arm64_printer.c
index b07d40a4..b07d40a4 100755
--- a/src/dynarec/arm64_printer.c
+++ b/src/dynarec/arm64/arm64_printer.c
diff --git a/src/dynarec/arm64_printer.h b/src/dynarec/arm64/arm64_printer.h
index 2475f631..2475f631 100644
--- a/src/dynarec/arm64_printer.h
+++ b/src/dynarec/arm64/arm64_printer.h
diff --git a/src/dynarec/arm64_prolog.S b/src/dynarec/arm64/arm64_prolog.S
index 21961e5b..21961e5b 100755
--- a/src/dynarec/arm64_prolog.S
+++ b/src/dynarec/arm64/arm64_prolog.S
diff --git a/src/dynarec/dynarec_arm64_00.c b/src/dynarec/arm64/dynarec_arm64_00.c
index 28720e31..3e6098de 100755
--- a/src/dynarec/dynarec_arm64_00.c
+++ b/src/dynarec/arm64/dynarec_arm64_00.c
@@ -17,10 +17,10 @@
 #include "bridge.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_functions.h"
 #include "dynarec_arm64_helper.h"
 
@@ -644,12 +644,12 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
             GETFLAGS;   \
             if(dyn->insts[ninst].x64.jmp_insts==-1) {   \
                 /* out of the block */                  \
-                i32 = dyn->insts[ninst+1].address-(dyn->arm_size); \
+                i32 = dyn->insts[ninst+1].address-(dyn->native_size); \
                 Bcond(NO, i32);     \
                 jump_to_next(dyn, addr+i8, 0, ninst); \
             } else {    \
                 /* inside the block */  \
-                i32 = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->arm_size);    \
+                i32 = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->native_size);    \
                 Bcond(YES, i32);    \
             }
 
@@ -2001,12 +2001,12 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
             JUMP(addr+i8);                                              \
             if(dyn->insts[ninst].x64.jmp_insts==-1) {               \
                 /* out of the block */                              \
-                i32 = dyn->insts[ninst+1].address-(dyn->arm_size);  \
+                i32 = dyn->insts[ninst+1].address-(dyn->native_size);  \
                 if(Z) {CBNZx(xRCX, i32);} else {CBZx(xRCX, i32);};  \
                 jump_to_next(dyn, addr+i8, 0, ninst);               \
             } else {                                                \
                 /* inside the block */                              \
-                i32 = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->arm_size);    \
+                i32 = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->native_size);    \
                 if(Z) {CBZx(xRCX, i32);} else {CBNZx(xRCX, i32);};  \
             }
         case 0xE0:
@@ -2129,7 +2129,7 @@ uintptr_t dynarec64_00(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
                 jump_to_next(dyn, addr+i32, 0, ninst);
             } else {
                 // inside the block
-                tmp = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->arm_size);
+                tmp = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->native_size);
                 if(tmp==4) {
                     NOP;
                 } else {
diff --git a/src/dynarec/dynarec_arm64_0f.c b/src/dynarec/arm64/dynarec_arm64_0f.c
index 0a204193..b726db9a 100755
--- a/src/dynarec/dynarec_arm64_0f.c
+++ b/src/dynarec/arm64/dynarec_arm64_0f.c
@@ -15,12 +15,12 @@
 #include "callback.h"

 #include "emu/x64run_private.h"

 #include "x64trace.h"

-#include "dynarec_arm64.h"

-#include "dynarec_arm64_private.h"

-#include "arm64_printer.h"

+#include "dynarec_native.h"

 #include "my_cpuid.h"

 #include "emu/x87emu_private.h"

 

+#include "arm64_printer.h"

+#include "dynarec_arm64_private.h"

 #include "dynarec_arm64_functions.h"

 #include "dynarec_arm64_helper.h"

 

@@ -1018,12 +1018,12 @@ uintptr_t dynarec64_0F(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
             GETFLAGS;   \

             if(dyn->insts[ninst].x64.jmp_insts==-1) {   \

                 /* out of the block */                  \

-                i32 = dyn->insts[ninst+1].address-(dyn->arm_size); \

+                i32 = dyn->insts[ninst+1].address-(dyn->native_size); \

                 Bcond(NO, i32);     \

                 jump_to_next(dyn, addr+i32_, 0, ninst); \

             } else {    \

                 /* inside the block */  \

-                i32 = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->arm_size);    \

+                i32 = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->native_size);    \

                 Bcond(YES, i32);    \

             }   \

 

diff --git a/src/dynarec/dynarec_arm64_64.c b/src/dynarec/arm64/dynarec_arm64_64.c
index 871d0e20..d604047c 100644
--- a/src/dynarec/dynarec_arm64_64.c
+++ b/src/dynarec/arm64/dynarec_arm64_64.c
@@ -15,10 +15,10 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_helper.h"
 #include "dynarec_arm64_functions.h"
 
diff --git a/src/dynarec/dynarec_arm64_66.c b/src/dynarec/arm64/dynarec_arm64_66.c
index 1715d845..6e8c3b65 100755
--- a/src/dynarec/dynarec_arm64_66.c
+++ b/src/dynarec/arm64/dynarec_arm64_66.c
@@ -15,10 +15,10 @@
 #include "callback.h"

 #include "emu/x64run_private.h"

 #include "x64trace.h"

-#include "dynarec_arm64.h"

-#include "dynarec_arm64_private.h"

-#include "arm64_printer.h"

+#include "dynarec_native.h"

 

+#include "arm64_printer.h"

+#include "dynarec_arm64_private.h"

 #include "dynarec_arm64_helper.h"

 #include "dynarec_arm64_functions.h"

 

diff --git a/src/dynarec/dynarec_arm64_660f.c b/src/dynarec/arm64/dynarec_arm64_660f.c
index fd0fd355..39143bf9 100755
--- a/src/dynarec/dynarec_arm64_660f.c
+++ b/src/dynarec/arm64/dynarec_arm64_660f.c
@@ -15,10 +15,10 @@
 #include "callback.h"

 #include "emu/x64run_private.h"

 #include "x64trace.h"

-#include "dynarec_arm64.h"

-#include "dynarec_arm64_private.h"

-#include "arm64_printer.h"

+#include "dynarec_native.h"

 

+#include "arm64_printer.h"

+#include "dynarec_arm64_private.h"

 #include "dynarec_arm64_functions.h"

 #include "dynarec_arm64_helper.h"

 

diff --git a/src/dynarec/dynarec_arm64_6664.c b/src/dynarec/arm64/dynarec_arm64_6664.c
index 9d65c104..422c673b 100644
--- a/src/dynarec/dynarec_arm64_6664.c
+++ b/src/dynarec/arm64/dynarec_arm64_6664.c
@@ -15,10 +15,10 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_helper.h"
 #include "dynarec_arm64_functions.h"
 
diff --git a/src/dynarec/dynarec_arm64_67.c b/src/dynarec/arm64/dynarec_arm64_67.c
index 4e0e0a26..0e846784 100755
--- a/src/dynarec/dynarec_arm64_67.c
+++ b/src/dynarec/arm64/dynarec_arm64_67.c
@@ -15,10 +15,10 @@
 #include "callback.h"

 #include "emu/x64run_private.h"

 #include "x64trace.h"

-#include "dynarec_arm64.h"

-#include "dynarec_arm64_private.h"

-#include "arm64_printer.h"

+#include "dynarec_native.h"

 

+#include "arm64_printer.h"

+#include "dynarec_arm64_private.h"

 #include "dynarec_arm64_helper.h"

 #include "dynarec_arm64_functions.h"

 

@@ -229,12 +229,12 @@ uintptr_t dynarec64_67(dynarec_arm_t* dyn, uintptr_t addr, uintptr_t ip, int nin
             JUMP(addr+i8);\

             if(dyn->insts[ninst].x64.jmp_insts==-1) {   \

                 /* out of the block */                  \

-                i32 = dyn->insts[ninst+1].address-(dyn->arm_size); \

+                i32 = dyn->insts[ninst+1].address-(dyn->native_size); \

                 Bcond(NO, i32);     \

                 jump_to_next(dyn, addr+i8, 0, ninst); \

             } else {    \

                 /* inside the block */  \

-                i32 = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->arm_size);    \

+                i32 = dyn->insts[dyn->insts[ninst].x64.jmp_insts].address-(dyn->native_size);    \

                 Bcond(YES, i32);    \

             }

         case 0xE0:

diff --git a/src/dynarec/dynarec_arm64_d8.c b/src/dynarec/arm64/dynarec_arm64_d8.c
index 9b65f764..2a963bb4 100644
--- a/src/dynarec/dynarec_arm64_d8.c
+++ b/src/dynarec/arm64/dynarec_arm64_d8.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
 #include "emu/x87emu_private.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_helper.h"
 #include "dynarec_arm64_functions.h"
 
diff --git a/src/dynarec/dynarec_arm64_d9.c b/src/dynarec/arm64/dynarec_arm64_d9.c
index 8089b68d..cd11b6f2 100644
--- a/src/dynarec/dynarec_arm64_d9.c
+++ b/src/dynarec/arm64/dynarec_arm64_d9.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
 #include "emu/x87emu_private.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_helper.h"
 #include "dynarec_arm64_functions.h"
 
diff --git a/src/dynarec/dynarec_arm64_db.c b/src/dynarec/arm64/dynarec_arm64_db.c
index 52204ffe..cbc2c0ef 100644
--- a/src/dynarec/dynarec_arm64_db.c
+++ b/src/dynarec/arm64/dynarec_arm64_db.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
 #include "emu/x87emu_private.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_helper.h"
 #include "dynarec_arm64_functions.h"
 
diff --git a/src/dynarec/dynarec_arm64_dc.c b/src/dynarec/arm64/dynarec_arm64_dc.c
index 0fa8ddb2..3877bcc9 100644
--- a/src/dynarec/dynarec_arm64_dc.c
+++ b/src/dynarec/arm64/dynarec_arm64_dc.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
 #include "emu/x87emu_private.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_helper.h"
 #include "dynarec_arm64_functions.h"
 
diff --git a/src/dynarec/dynarec_arm64_dd.c b/src/dynarec/arm64/dynarec_arm64_dd.c
index 4068af44..4b73cc97 100644
--- a/src/dynarec/dynarec_arm64_dd.c
+++ b/src/dynarec/arm64/dynarec_arm64_dd.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
 #include "emu/x87emu_private.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_helper.h"
 #include "dynarec_arm64_functions.h"
 
diff --git a/src/dynarec/dynarec_arm64_df.c b/src/dynarec/arm64/dynarec_arm64_df.c
index c1ace798..a90f3331 100644
--- a/src/dynarec/dynarec_arm64_df.c
+++ b/src/dynarec/arm64/dynarec_arm64_df.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
 #include "emu/x87emu_private.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_helper.h"
 #include "dynarec_arm64_functions.h"
 
diff --git a/src/dynarec/dynarec_arm64_emit_logic.c b/src/dynarec/arm64/dynarec_arm64_emit_logic.c
index 5255f47c..24453b44 100755
--- a/src/dynarec/dynarec_arm64_emit_logic.c
+++ b/src/dynarec/arm64/dynarec_arm64_emit_logic.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
+#include "dynarec_native.h"
 #include "../tools/bridge_private.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_functions.h"
 #include "dynarec_arm64_helper.h"
 
diff --git a/src/dynarec/dynarec_arm64_emit_math.c b/src/dynarec/arm64/dynarec_arm64_emit_math.c
index 97eedfe9..eb55a249 100755
--- a/src/dynarec/dynarec_arm64_emit_math.c
+++ b/src/dynarec/arm64/dynarec_arm64_emit_math.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
+#include "dynarec_native.h"
 #include "../tools/bridge_private.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_functions.h"
 #include "dynarec_arm64_helper.h"
 
diff --git a/src/dynarec/dynarec_arm64_emit_shift.c b/src/dynarec/arm64/dynarec_arm64_emit_shift.c
index 4382794d..51903720 100755
--- a/src/dynarec/dynarec_arm64_emit_shift.c
+++ b/src/dynarec/arm64/dynarec_arm64_emit_shift.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
+#include "dynarec_native.h"
 #include "../tools/bridge_private.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_functions.h"
 #include "dynarec_arm64_helper.h"
 
diff --git a/src/dynarec/dynarec_arm64_emit_tests.c b/src/dynarec/arm64/dynarec_arm64_emit_tests.c
index 14fb366e..301ab2f2 100755
--- a/src/dynarec/dynarec_arm64_emit_tests.c
+++ b/src/dynarec/arm64/dynarec_arm64_emit_tests.c
@@ -15,11 +15,11 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
+#include "dynarec_native.h"
 #include "../tools/bridge_private.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_functions.h"
 #include "dynarec_arm64_helper.h"
 
diff --git a/src/dynarec/dynarec_arm64_f0.c b/src/dynarec/arm64/dynarec_arm64_f0.c
index dbcf18ea..b127b0b3 100644
--- a/src/dynarec/dynarec_arm64_f0.c
+++ b/src/dynarec/arm64/dynarec_arm64_f0.c
@@ -15,10 +15,10 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "arm64_printer.h"
+#include "dynarec_native.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_helper.h"
 #include "dynarec_arm64_functions.h"
 
diff --git a/src/dynarec/dynarec_arm64_f20f.c b/src/dynarec/arm64/dynarec_arm64_f20f.c
index 2c2e5c63..cf047a10 100755
--- a/src/dynarec/dynarec_arm64_f20f.c
+++ b/src/dynarec/arm64/dynarec_arm64_f20f.c
@@ -15,10 +15,10 @@
 #include "callback.h"

 #include "emu/x64run_private.h"

 #include "x64trace.h"

-#include "dynarec_arm64.h"

-#include "dynarec_arm64_private.h"

-#include "arm64_printer.h"

+#include "dynarec_native.h"

 

+#include "arm64_printer.h"

+#include "dynarec_arm64_private.h"

 #include "dynarec_arm64_functions.h"

 #include "dynarec_arm64_helper.h"

 

diff --git a/src/dynarec/dynarec_arm64_f30f.c b/src/dynarec/arm64/dynarec_arm64_f30f.c
index b4413a60..5f489168 100755
--- a/src/dynarec/dynarec_arm64_f30f.c
+++ b/src/dynarec/arm64/dynarec_arm64_f30f.c
@@ -15,10 +15,10 @@
 #include "callback.h"

 #include "emu/x64run_private.h"

 #include "x64trace.h"

-#include "dynarec_arm64.h"

-#include "dynarec_arm64_private.h"

-#include "arm64_printer.h"

+#include "dynarec_native.h"

 

+#include "arm64_printer.h"

+#include "dynarec_arm64_private.h"

 #include "dynarec_arm64_functions.h"

 #include "dynarec_arm64_helper.h"

 

diff --git a/src/dynarec/dynarec_arm64_functions.c b/src/dynarec/arm64/dynarec_arm64_functions.c
index 5e6ecfd2..32bea7d6 100755
--- a/src/dynarec/dynarec_arm64_functions.c
+++ b/src/dynarec/arm64/dynarec_arm64_functions.c
@@ -22,7 +22,7 @@
 #include "emu/x87emu_private.h"
 #include "x64trace.h"
 #include "signals.h"
-#include "dynarec_arm64.h"
+#include "dynarec_native.h"
 #include "dynarec_arm64_private.h"
 #include "dynarec_arm64_functions.h"
 #include "custommem.h"
diff --git a/src/dynarec/dynarec_arm64_functions.h b/src/dynarec/arm64/dynarec_arm64_functions.h
index d4c861c9..d4c861c9 100755
--- a/src/dynarec/dynarec_arm64_functions.h
+++ b/src/dynarec/arm64/dynarec_arm64_functions.h
diff --git a/src/dynarec/dynarec_arm64_helper.c b/src/dynarec/arm64/dynarec_arm64_helper.c
index 8c65ac32..fc28663c 100755
--- a/src/dynarec/dynarec_arm64_helper.c
+++ b/src/dynarec/arm64/dynarec_arm64_helper.c
@@ -15,13 +15,13 @@
 #include "callback.h"
 #include "emu/x64run_private.h"
 #include "x64trace.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "dynablock_private.h"
-#include "arm64_printer.h"
+#include "dynarec_native.h"
+#include "../dynablock_private.h"
 #include "../tools/bridge_private.h"
 #include "custommem.h"
 
+#include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_functions.h"
 #include "dynarec_arm64_helper.h"
 
diff --git a/src/dynarec/dynarec_arm64_helper.h b/src/dynarec/arm64/dynarec_arm64_helper.h
index d15902f4..e1bbd5b9 100755
--- a/src/dynarec/dynarec_arm64_helper.h
+++ b/src/dynarec/arm64/dynarec_arm64_helper.h
@@ -312,138 +312,138 @@
 // R0 will not be pushed/popd if ret is -2. Flags are not save/restored
 #define CALL_S(F, ret) call_c(dyn, ninst, F, x7, ret, 0, 0)
 
-#define MARK    dyn->insts[ninst].mark = dyn->arm_size
+#define MARK    dyn->insts[ninst].mark = dyn->native_size
 #define GETMARK dyn->insts[ninst].mark
-#define MARK2   dyn->insts[ninst].mark2 = dyn->arm_size
+#define MARK2   dyn->insts[ninst].mark2 = dyn->native_size
 #define GETMARK2 dyn->insts[ninst].mark2
-#define MARK3   dyn->insts[ninst].mark3 = dyn->arm_size
+#define MARK3   dyn->insts[ninst].mark3 = dyn->native_size
 #define GETMARK3 dyn->insts[ninst].mark3
-#define MARKF   dyn->insts[ninst].markf = dyn->arm_size
+#define MARKF   dyn->insts[ninst].markf = dyn->native_size
 #define GETMARKF dyn->insts[ninst].markf
-#define MARKSEG dyn->insts[ninst].markseg = dyn->arm_size
+#define MARKSEG dyn->insts[ninst].markseg = dyn->native_size
 #define GETMARKSEG dyn->insts[ninst].markseg
-#define MARKLOCK dyn->insts[ninst].marklock = dyn->arm_size
+#define MARKLOCK dyn->insts[ninst].marklock = dyn->native_size
 #define GETMARKLOCK dyn->insts[ninst].marklock
 
 // Branch to MARK if cond (use j64)
 #define B_MARK(cond)                \
-    j64 = GETMARK-(dyn->arm_size);  \
+    j64 = GETMARK-(dyn->native_size);  \
     Bcond(cond, j64)
 // Branch to MARK unconditionnal (use j64)
 #define B_MARK_nocond               \
-    j64 = GETMARK-(dyn->arm_size);  \
+    j64 = GETMARK-(dyn->native_size);  \
     B(j64)
 // Branch to MARK if reg is 0 (use j64)
 #define CBZxw_MARK(reg)             \
-    j64 = GETMARK-(dyn->arm_size);  \
+    j64 = GETMARK-(dyn->native_size);  \
     CBZxw(reg, j64)
 // Branch to MARK if reg is not 0 (use j64)
 #define CBNZx_MARK(reg)             \
-    j64 = GETMARK-(dyn->arm_size);  \
+    j64 = GETMARK-(dyn->native_size);  \
     CBNZx(reg, j64)
 // Branch to MARK if reg is not 0 (use j64)
 #define CBNZw_MARK(reg)             \
-    j64 = GETMARK-(dyn->arm_size);  \
+    j64 = GETMARK-(dyn->native_size);  \
     CBNZw(reg, j64)
 // Test bit N of A and branch to MARK if not set
 #define TBZ_MARK(A, N)              \
-    j64 = GETMARK-(dyn->arm_size);  \
+    j64 = GETMARK-(dyn->native_size);  \
     TBZ(A, N, j64)
 // Test bit N of A and branch to MARK if set
 #define TBNZ_MARK(A, N)             \
-    j64 = GETMARK-(dyn->arm_size);  \
+    j64 = GETMARK-(dyn->native_size);  \
     TBNZ(A, N, j64)
 // Branch to MARK2 if cond (use j64)
 #define B_MARK2(cond)               \
-    j64 = GETMARK2-(dyn->arm_size); \
+    j64 = GETMARK2-(dyn->native_size); \
     Bcond(cond, j64)
 // Branch to MARK2 unconditionnal (use j64)
 #define B_MARK2_nocond              \
-    j64 = GETMARK2-(dyn->arm_size); \
+    j64 = GETMARK2-(dyn->native_size); \
     B(j64)
 // Branch to MARK2 if reg is not 0 (use j64)
 #define CBNZx_MARK2(reg)            \
-    j64 = GETMARK2-(dyn->arm_size); \
+    j64 = GETMARK2-(dyn->native_size); \
     CBNZx(reg, j64)
 // Test bit N of A and branch to MARK2 if set
 #define TBNZ_MARK2(A, N)            \
-    j64 = GETMARK2-(dyn->arm_size); \
+    j64 = GETMARK2-(dyn->native_size); \
     TBNZ(A, N, j64)
 // Branch to MARK3 if cond (use j64)
 #define B_MARK3(cond)               \
-    j64 = GETMARK3-(dyn->arm_size); \
+    j64 = GETMARK3-(dyn->native_size); \
     Bcond(cond, j64)
 // Test bit N of A and branch to MARK3 if not set
 #define TBZ_MARK2(A, N)            \
-    j64 = GETMARK2-(dyn->arm_size); \
+    j64 = GETMARK2-(dyn->native_size); \
     TBZ(A, N, j64)
 // Branch to MARK3 unconditionnal (use j64)
 #define B_MARK3_nocond              \
-    j64 = GETMARK3-(dyn->arm_size); \
+    j64 = GETMARK3-(dyn->native_size); \
     B(j64)
 // Branch to MARK3 if reg is not 0 (use j64)
 #define CBNZx_MARK3(reg)            \
-    j64 = GETMARK3-(dyn->arm_size); \
+    j64 = GETMARK3-(dyn->native_size); \
     CBNZx(reg, j64)
 // Branch to MARK3 if reg is 0 (use j64)
 #define CBZx_MARK3(reg)             \
-    j64 = GETMARK3-(dyn->arm_size); \
+    j64 = GETMARK3-(dyn->native_size); \
     CBZx(reg, j64)
 // Test bit N of A and branch to MARK3 if not set
 #define TBZ_MARK3(A, N)             \
-    j64 = GETMARK3-(dyn->arm_size); \
+    j64 = GETMARK3-(dyn->native_size); \
     TBZ(A, N, j64)
 // Test bit N of A and branch to MARK3 if set
 #define TBNZ_MARK3(A, N)            \
-    j64 = GETMARK3-(dyn->arm_size); \
+    j64 = GETMARK3-(dyn->native_size); \
     TBNZ(A, N, j64)
 // Branch to next instruction if cond (use j64)
 #define B_NEXT(cond)     \
-    j64 = (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->arm_size)):0; \
+    j64 = (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->native_size)):0; \
     Bcond(cond, j64)
 // Branch to next instruction unconditionnal (use j64)
 #define B_NEXT_nocond                                               \
-    j64 = (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->arm_size)):0;\
+    j64 = (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->native_size)):0;\
     B(j64)
 // Branch to next instruction if reg is 0 (use j64)
 #define CBZw_NEXT(reg)    \
-    j64 =  (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->arm_size)):0; \
+    j64 =  (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->native_size)):0; \
     CBZw(reg, j64)
 // Branch to next instruction if reg is 0 (use j64)
 #define CBZx_NEXT(reg)    \
-    j64 =  (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->arm_size)):0; \
+    j64 =  (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->native_size)):0; \
     CBZx(reg, j64)
 // Branch to next instruction if reg is not 0 (use j64)
 #define CBNZx_NEXT(reg)   \
-    j64 =  (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->arm_size)):0; \
+    j64 =  (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->native_size)):0; \
     CBNZx(reg, j64)
 // Test bit N of A and branch to next instruction if not set
 #define TBZ_NEXT(A, N)              \
-    j64 = (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->arm_size)):0; \
+    j64 = (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->native_size)):0; \
     TBZ(A, N, j64)
 // Test bit N of A and branch to next instruction if set
 #define TBNZ_NEXT(A, N)             \
-    j64 = (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->arm_size)):0; \
+    j64 = (dyn->insts)?(dyn->insts[ninst].epilog-(dyn->native_size)):0; \
     TBNZ(A, N, j64)
 // Branch to MARKSEG if cond (use j64)
 #define B_MARKSEG(cond)    \
-    j64 = GETMARKSEG-(dyn->arm_size);   \
+    j64 = GETMARKSEG-(dyn->native_size);   \
     Bcond(cond, j64)
 // Branch to MARKSEG if reg is 0 (use j64)
 #define CBZw_MARKSEG(reg)    \
-    j64 = GETMARKSEG-(dyn->arm_size);   \
+    j64 = GETMARKSEG-(dyn->native_size);   \
     CBZw(reg, j64)
 // Branch to MARKSEG if reg is not 0 (use j64)
 #define CBNZw_MARKSEG(reg)              \
-    j64 = GETMARKSEG-(dyn->arm_size);   \
+    j64 = GETMARKSEG-(dyn->native_size);   \
     CBNZw(reg, j64)
 // Branch to MARKLOCK if cond (use j64)
 #define B_MARKLOCK(cond)    \
-    j64 = GETMARKLOCK-(dyn->arm_size);   \
+    j64 = GETMARKLOCK-(dyn->native_size);   \
     Bcond(cond, j64)
 // Branch to MARKLOCK if reg is not 0 (use j64)
 #define CBNZx_MARKLOCK(reg)             \
-    j64 = GETMARKLOCK-(dyn->arm_size);  \
+    j64 = GETMARKLOCK-(dyn->native_size);  \
     CBNZx(reg, j64)
 
 #define IFX(A)  if((dyn->insts[ninst].x64.need_flags&(A)))
@@ -579,7 +579,7 @@
     if(((A)!=X_PEND) && dyn->state_flags!=SF_SET && dyn->state_flags!=SF_SET_PENDING) { \
         if(dyn->state_flags!=SF_PENDING) {              \
             LDRw_U12(x3, xEmu, offsetof(x64emu_t, df)); \
-            j64 = (GETMARKF)-(dyn->arm_size);           \
+            j64 = (GETMARKF)-(dyn->native_size);           \
             CBZw(x3, j64);                              \
         }                                               \
         CALL_(UpdateFlags, -1, 0);                      \
diff --git a/src/dynarec/dynarec_arm64_pass.c b/src/dynarec/arm64/dynarec_arm64_pass.c
index c4a31aaf..5492df01 100755
--- a/src/dynarec/dynarec_arm64_pass.c
+++ b/src/dynarec/arm64/dynarec_arm64_pass.c
@@ -16,12 +16,13 @@
 #include "emu/x64run_private.h"
 #include "x64trace.h"
 #include "dynablock.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
+#include "dynarec_native.h"
+#include "custommem.h"
+
 #include "arm64_printer.h"
+#include "dynarec_arm64_private.h"
 #include "dynarec_arm64_functions.h"
 #include "dynarec_arm64_helper.h"
-#include "custommem.h"
 
 #ifndef STEP
 #error No STEP defined
diff --git a/src/dynarec/dynarec_arm64_pass0.h b/src/dynarec/arm64/dynarec_arm64_pass0.h
index d4818ac5..d4818ac5 100755
--- a/src/dynarec/dynarec_arm64_pass0.h
+++ b/src/dynarec/arm64/dynarec_arm64_pass0.h
diff --git a/src/dynarec/dynarec_arm64_pass1.h b/src/dynarec/arm64/dynarec_arm64_pass1.h
index a4abcf19..a4abcf19 100755
--- a/src/dynarec/dynarec_arm64_pass1.h
+++ b/src/dynarec/arm64/dynarec_arm64_pass1.h
diff --git a/src/dynarec/dynarec_arm64_pass2.h b/src/dynarec/arm64/dynarec_arm64_pass2.h
index 1be5a0de..3d4b6f03 100755
--- a/src/dynarec/dynarec_arm64_pass2.h
+++ b/src/dynarec/arm64/dynarec_arm64_pass2.h
@@ -1,10 +1,10 @@
-#define INIT        dyn->arm_size = 0
+#define INIT        dyn->native_size = 0
 #define FINI        if(ninst) {dyn->insts[ninst].address = (dyn->insts[ninst-1].address+dyn->insts[ninst-1].size);}
 
 #define MESSAGE(A, ...)  
-#define EMIT(A)     dyn->insts[ninst].size+=4; dyn->arm_size+=4
+#define EMIT(A)     dyn->insts[ninst].size+=4; dyn->native_size+=4
 #define NEW_INST    if(ninst) {dyn->insts[ninst].address = (dyn->insts[ninst-1].address+dyn->insts[ninst-1].size);}
-#define INST_EPILOG dyn->insts[ninst].epilog = dyn->arm_size; 
+#define INST_EPILOG dyn->insts[ninst].epilog = dyn->native_size; 
 #define INST_NAME(name) 
 #define NEW_BARRIER_INST    if(ninst) ++dyn->sons_size
 #define TABLE64(A, V)   {Table64(dyn, (V)); EMIT(0);}
diff --git a/src/dynarec/dynarec_arm64_pass3.h b/src/dynarec/arm64/dynarec_arm64_pass3.h
index 25b852e3..00f39f74 100755
--- a/src/dynarec/dynarec_arm64_pass3.h
+++ b/src/dynarec/arm64/dynarec_arm64_pass3.h
@@ -3,7 +3,7 @@
 #define EMIT(A)     \
     if(box64_dynarec_dump) {dynarec_log(LOG_NONE, "\t%08x\t%s\n", (uint32_t)(A), arm64_print(A, (uintptr_t)dyn->block));} \
     *(uint32_t*)(dyn->block) = (uint32_t)(A);       \
-    dyn->block += 4; dyn->arm_size += 4;\
+    dyn->block += 4; dyn->native_size += 4;         \
     dyn->insts[ninst].size2 += 4
 
 #define MESSAGE(A, ...)  if(box64_dynarec_dump) dynarec_log(LOG_NONE, __VA_ARGS__)
@@ -14,7 +14,7 @@
         printf_x64_instruction(my_context->dec, &dyn->insts[ninst].x64, name); \
         dynarec_log(LOG_NONE, "%s%p: %d emited opcodes, state=%d/%d, set=%X, use=%X, need=%X%s\n", \
             (box64_dynarec_dump>1)?"\e[32m":"", \
-            (void*)(dyn->arm_start+dyn->insts[ninst].address),  \
+            (void*)(dyn->native_start+dyn->insts[ninst].address),  \
             dyn->insts[ninst].size/4,           \
             dyn->insts[ninst].x64.state_flags,  \
             dyn->state_flags,                   \
@@ -27,7 +27,7 @@
 #define NEW_BARRIER_INST                            \
     if(ninst) {                                     \
     dyn->sons_x64[dyn->sons_size] = (uintptr_t)ip;  \
-    dyn->sons_arm[dyn->sons_size] = dyn->block;     \
+    dyn->sons_native[dyn->sons_size] = dyn->block;  \
     MESSAGE(LOG_DUMP, "----> potential Son here\n");\
     ++dyn->sons_size;                               \
     }
diff --git a/src/dynarec/dynarec_arm64_private.h b/src/dynarec/arm64/dynarec_arm64_private.h
index cae1b4bd..252901a9 100755
--- a/src/dynarec/dynarec_arm64_private.h
+++ b/src/dynarec/arm64/dynarec_arm64_private.h
@@ -1,7 +1,7 @@
 #ifndef __DYNAREC_ARM_PRIVATE_H_
 #define __DYNAREC_ARM_PRIVATE_H_
 
-#include "dynarec_private.h"
+#include "../dynarec_private.h"
 
 typedef struct x64emu_s x64emu_t;
 typedef struct dynablock_s dynablock_t;
@@ -28,8 +28,8 @@ typedef struct dynarec_arm_s {
     uintptr_t           start;      // start of the block
     uint32_t            isize;      // size in byte of x64 instructions included
     void*               block;      // memory pointer where next instruction is emited
-    uintptr_t           arm_start;  // start of the arm code
-    size_t              arm_size;   // size of emitted arm code
+    uintptr_t           native_start;  // start of the arm code
+    size_t              native_size;   // size of emitted arm code
     int                 state_flags;// actual state for on-demand flags
     uintptr_t           last_ip;    // last set IP in RIP (or NULL if unclean state)
     int8_t              x87cache[8];// cache status for the 8 x87 register behind the fpu stack
@@ -49,7 +49,7 @@ typedef struct dynarec_arm_s {
     int                 next_sz;
     int                 next_cap;
     uintptr_t*          sons_x64;   // the x64 address of potential dynablock sons
-    void**              sons_arm;   // the arm address of potential dynablock sons
+    void**              sons_native;   // the arm address of potential dynablock sons
     int                 sons_size;  // number of potential dynablock sons
     dynablock_t*        dynablock;
 } dynarec_arm_t;
diff --git a/src/dynarec/dynablock.c b/src/dynarec/dynablock.c
index 8906db51..6bc61bf3 100755
--- a/src/dynarec/dynablock.c
+++ b/src/dynarec/dynablock.c
@@ -19,12 +19,10 @@
 #include "dynablock_private.h"
 #include "dynarec_private.h"
 #include "elfloader.h"
-#ifdef ARM64
-#include "dynarec_arm64.h"
-#include "arm64_lock.h"
-#else
-#error Unsupported architecture!
-#endif
+
+#include "dynarec_native.h"
+#include "native_lock.h"
+
 #include "custommem.h"
 #include "khash.h"
 
@@ -74,13 +72,13 @@ void FreeDynablock(dynablock_t* db, int need_lock)
         if(db->parent->direct) {
             uintptr_t addr = (uintptr_t)db->x64_addr;
             if(addr>=startdb && addr<enddb)
-                arm64_lock_xchg(&db->parent->direct[addr-startdb], 0);   // secured write
+                native_lock_xchg(&db->parent->direct[addr-startdb], 0);   // secured write
         }
         // remove jumptable
         setJumpTableDefault64(db->x64_addr);
         // remove and free the sons
         for (int i=0; i<db->sons_size; ++i) {
-            dynablock_t *son = (dynablock_t*)arm64_lock_xchg(&db->sons[i], 0);
+            dynablock_t *son = (dynablock_t*)native_lock_xchg(&db->sons[i], 0);
             FreeDynablock(son, 0);
         }
         // only the father free the DynarecMap
@@ -189,7 +187,7 @@ int FreeRangeDynablock(dynablocklist_t* dynablocks, uintptr_t addr, uintptr_t si
             end = enddb;
         if(end>startdb && start<enddb)
             for(uintptr_t i = start; i<end; ++i) {
-                db = (dynablock_t*)arm64_lock_xchg(&dynablocks->direct[i-startdb], 0);
+                db = (dynablock_t*)native_lock_xchg(&dynablocks->direct[i-startdb], 0);
                 if(db) {
                     if(db->father)
                         db = db->father;
@@ -274,7 +272,7 @@ dynablock_t *AddNewDynablock(dynablocklist_t* dynablocks, uintptr_t addr, int* c
     pthread_mutex_lock(&my_context->mutex_dyndump);
     if(!dynablocks->direct) {
         dynablock_t** p = (dynablock_t**)calloc(dynablocks->textsz, sizeof(dynablock_t*));
-        if(arm64_lock_storeifnull(&dynablocks->direct, p)!=p)
+        if(native_lock_storeifnull(&dynablocks->direct, p)!=p)
             free(p);    // someone already create the direct array, too late...
     }
 
@@ -283,7 +281,7 @@ dynablock_t *AddNewDynablock(dynablocklist_t* dynablocks, uintptr_t addr, int* c
 
     block = (dynablock_t*)calloc(1, sizeof(dynablock_t));
     block->parent = dynablocks; 
-    dynablock_t* tmp = (dynablock_t*)arm64_lock_storeifnull(&dynablocks->direct[addr-dynablocks->text], block);
+    dynablock_t* tmp = (dynablock_t*)native_lock_storeifnull(&dynablocks->direct[addr-dynablocks->text], block);
     if(tmp !=  block) {
         // a block appeard!
         pthread_mutex_unlock(&my_context->mutex_dyndump);
@@ -353,7 +351,7 @@ static dynablock_t* internalDBGetBlock(x64emu_t* emu, uintptr_t addr, uintptr_t
         pthread_mutex_unlock(&my_context->mutex_dyndump);
     if(!ret) {
         dynarec_log(LOG_DEBUG, "Fillblock of block %p for %p returned an error\n", block, (void*)addr);
-        void* old = (void*)arm64_lock_storeifref(&dynablocks->direct[addr-dynablocks->text], 0, block);
+        void* old = (void*)native_lock_storeifref(&dynablocks->direct[addr-dynablocks->text], 0, block);
         if(old!=block && old) {// put it back in place, strange things are happening here!
             dynarec_log(LOG_INFO, "Warning, a wild block appeared at %p: %p\n", (void*)addr, old);
             // doing nothing else, the block has not be writen
diff --git a/src/dynarec/dynarec_arch.h b/src/dynarec/dynarec_arch.h
new file mode 100755
index 00000000..ba059a90
--- /dev/null
+++ b/src/dynarec/dynarec_arch.h
@@ -0,0 +1,24 @@
+#ifndef __DYNAREC_ARCH__H_

+#define __DYNAREC_ARCH__H_

+

+#ifdef ARM64

+#include "arm64/dynarec_arm64_private.h"

+#include "arm64/dynarec_arm64_functions.h"

+

+#define instruction_native_t        instruction_arm64_t

+

+uintptr_t arm_pass0(dynarec_arm_t* dyn, uintptr_t addr);

+uintptr_t arm_pass1(dynarec_arm_t* dyn, uintptr_t addr);

+uintptr_t arm_pass2(dynarec_arm_t* dyn, uintptr_t addr);

+uintptr_t arm_pass3(dynarec_arm_t* dyn, uintptr_t addr);

+

+#define native_pass0    arm_pass0

+#define native_pass1    arm_pass1

+#define native_pass2    arm_pass2

+#define native_pass3    arm_pass3

+

+#else

+#error Unsupported platform

+#endif

+

+#endif //__DYNAREC_ARCH__H_
\ No newline at end of file
diff --git a/src/dynarec/dynarec_arm64.c b/src/dynarec/dynarec_native.c
index 18e05bce..2424e5ca 100755
--- a/src/dynarec/dynarec_arm64.c
+++ b/src/dynarec/dynarec_native.c
@@ -18,11 +18,11 @@
 #include "x64trace.h"
 #include "dynablock.h"
 #include "dynablock_private.h"
-#include "dynarec_arm64.h"
-#include "dynarec_arm64_private.h"
-#include "dynarec_arm64_functions.h"
 #include "elfloader.h"
 
+#include "dynarec_native.h"
+#include "dynarec_arch.h"
+
 void printf_x64_instruction(zydis_dec_t* dec, instruction_x64_t* inst, const char* name) {
     uint8_t *ip = (uint8_t*)inst->addr;
     if(ip[0]==0xcc && ip[1]=='S' && ip[2]=='C') {
@@ -278,14 +278,14 @@ uint32_t needed_flags(dynarec_arm_t *dyn, int ninst, uint32_t setf, int recurse)
     return needed;
 }
 
-instsize_t* addInst(instsize_t* insts, size_t* size, size_t* cap, int x64_size, int arm_size)
+instsize_t* addInst(instsize_t* insts, size_t* size, size_t* cap, int x64_size, int native_size)
 {
     // x64 instruction is <16 bytes
     int toadd;
-    if(x64_size>arm_size)
+    if(x64_size>native_size)
         toadd = 1 + x64_size/15;
     else
-        toadd = 1 + arm_size/15;
+        toadd = 1 + native_size/15;
     if((*size)+toadd>(*cap)) {
         *cap = (*size)+toadd;
         insts = (instsize_t*)realloc(insts, (*cap)*sizeof(instsize_t));
@@ -296,11 +296,11 @@ instsize_t* addInst(instsize_t* insts, size_t* size, size_t* cap, int x64_size,
         else
             insts[*size].x64 = x64_size;
         x64_size -= insts[*size].x64;
-        if(arm_size>15)
+        if(native_size>15)
             insts[*size].nat = 15;
         else
-            insts[*size].nat = arm_size;
-        arm_size -= insts[*size].nat;
+            insts[*size].nat = native_size;
+        native_size -= insts[*size].nat;
         ++(*size);
         --toadd;
     }
@@ -329,12 +329,6 @@ int Table64(dynarec_arm_t *dyn, uint64_t val)
     return delta;
 }
 
-
-uintptr_t arm_pass0(dynarec_arm_t* dyn, uintptr_t addr);
-uintptr_t arm_pass1(dynarec_arm_t* dyn, uintptr_t addr);
-uintptr_t arm_pass2(dynarec_arm_t* dyn, uintptr_t addr);
-uintptr_t arm_pass3(dynarec_arm_t* dyn, uintptr_t addr);
-
 __thread void* current_helper = NULL;
 
 void CancelBlock64()
@@ -347,7 +341,7 @@ void CancelBlock64()
     free(helper->insts);
     free(helper->table64);
     free(helper->sons_x64);
-    free(helper->sons_arm);
+    free(helper->sons_native);
     if(helper->dynablock && helper->dynablock->block)
         FreeDynarecMap(helper->dynablock, (uintptr_t)helper->dynablock->block, helper->dynablock->size);
 }
@@ -370,9 +364,9 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr) {
     helper.start = addr;
     uintptr_t start = addr;
     helper.cap = 64; // needs epilog handling
-    helper.insts = (instruction_arm64_t*)calloc(helper.cap, sizeof(instruction_arm64_t));
+    helper.insts = (instruction_native_t*)calloc(helper.cap, sizeof(instruction_native_t));
     // pass 0, addresses, x86 jump addresses, overall size of the block
-    uintptr_t end = arm_pass0(&helper, addr);
+    uintptr_t end = native_pass0(&helper, addr);
     // no need for next anymore
     free(helper.next);
     helper.next_sz = helper.next_cap = 0;
@@ -413,7 +407,7 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr) {
             }
         }
     // pass 1, flags
-    arm_pass1(&helper, addr);
+    native_pass1(&helper, addr);
     for(int i=0; i<helper.size; ++i)
         if(helper.insts[i].x64.set_flags && !helper.insts[i].x64.need_flags) {
             helper.insts[i].x64.need_flags = needed_flags(&helper, i+1, helper.insts[i].x64.set_flags, 0);
@@ -422,9 +416,9 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr) {
         }
     
     // pass 2, instruction size
-    arm_pass2(&helper, addr);
+    native_pass2(&helper, addr);
     // ok, now allocate mapped memory, with executable flag on
-    size_t sz = helper.arm_size + helper.table64size*sizeof(uint64_t);
+    size_t sz = helper.native_size + helper.table64size*sizeof(uint64_t);
     void* p = (void*)AllocDynarecMap(block, sz);
     if(p==NULL) {
         dynarec_log(LOG_INFO, "AllocDynarecMap(%p, %zu) failed, cancelling block\n", block, sz);
@@ -432,25 +426,25 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr) {
         return NULL;
     }
     helper.block = p;
-    helper.arm_start = (uintptr_t)p;
-    helper.tablestart = helper.arm_start + helper.arm_size;
+    helper.native_start = (uintptr_t)p;
+    helper.tablestart = helper.native_start + helper.native_size;
     if(helper.sons_size) {
         helper.sons_x64 = (uintptr_t*)calloc(helper.sons_size, sizeof(uintptr_t));
-        helper.sons_arm = (void**)calloc(helper.sons_size, sizeof(void*));
+        helper.sons_native = (void**)calloc(helper.sons_size, sizeof(void*));
     }
     // pass 3, emit (log emit arm opcode)
     if(box64_dynarec_dump) {
-        dynarec_log(LOG_NONE, "%s%04d|Emitting %zu bytes for %u x64 bytes", (box64_dynarec_dump>1)?"\e[01;36m":"", GetTID(), helper.arm_size, helper.isize); 
+        dynarec_log(LOG_NONE, "%s%04d|Emitting %zu bytes for %u x64 bytes", (box64_dynarec_dump>1)?"\e[01;36m":"", GetTID(), helper.native_size, helper.isize); 
         printFunctionAddr(helper.start, " => ");
         dynarec_log(LOG_NONE, "%s\n", (box64_dynarec_dump>1)?"\e[m":"");
     }
     int oldtable64size = helper.table64size;
-    size_t oldarmsize = helper.arm_size;
-    helper.arm_size = 0;
+    size_t oldarmsize = helper.native_size;
+    helper.native_size = 0;
     helper.table64size = 0; // reset table64 (but not the cap)
-    arm_pass3(&helper, addr);
-    if((oldarmsize!=helper.arm_size) || (oldtable64size<helper.table64size)) {
-        printf_log(LOG_NONE, "BOX64: Warning, size difference in block between pass2 (%zu) & pass3 (%zu)!\n", sz, helper.arm_size+helper.table64size*8);
+    native_pass3(&helper, addr);
+    if((oldarmsize!=helper.native_size) || (oldtable64size<helper.table64size)) {
+        printf_log(LOG_NONE, "BOX64: Warning, size difference in block between pass2 (%zu) & pass3 (%zu)!\n", sz, helper.native_size+helper.table64size*8);
         uint8_t *dump = (uint8_t*)helper.start;
         printf_log(LOG_NONE, "Dump of %d x64 opcodes:\n", helper.size);
         for(int i=0; i<helper.size; ++i) {
@@ -512,7 +506,7 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr) {
             int created = 1;
             dynablock_t *son = AddNewDynablock(block->parent, helper.sons_x64[i], &created);
             if(created) {    // avoid breaking a working block!
-                son->block = helper.sons_arm[i];
+                son->block = helper.sons_native[i];
                 son->x64_addr = (void*)helper.sons_x64[i];
                 son->x64_size = end-helper.sons_x64[i];
                 if(!son->x64_size) {printf_log(LOG_NONE, "Warning, son with null x64 size! (@%p / ARM=%p)", son->x64_addr, son->block);}
@@ -533,8 +527,8 @@ void* FillBlock64(dynablock_t* block, uintptr_t addr) {
     }
     free(helper.sons_x64);
     helper.sons_x64 = NULL;
-    free(helper.sons_arm);
-    helper.sons_arm = NULL;
+    free(helper.sons_native);
+    helper.sons_native = NULL;
     current_helper = NULL;
     //block->done = 1;
     return (void*)block;
diff --git a/src/dynarec/native_lock.h b/src/dynarec/native_lock.h
new file mode 100755
index 00000000..056947fd
--- /dev/null
+++ b/src/dynarec/native_lock.h
@@ -0,0 +1,25 @@
+#ifndef __NATIVE_LOCK__H__

+#define __NATIVE_LOCK__H__

+

+#ifdef ARM64

+#include "arm64/arm64_lock.h"

+

+#define native_lock_read_b(A)               arm64_lock_read_b(A)

+#define native_lock_write_b(A, B)           arm64_lock_write_b(A, B)

+#define native_lock_read_h(A)               arm64_lock_read_h(A)

+#define native_lock_write_h(A, B)           arm64_lock_write_h(A, B)

+#define native_lock_read_d(A)               arm64_lock_read_d(A)

+#define native_lock_write_d(A, B)           arm64_lock_write_d(A, B)

+#define native_lock_read_dd(A)              arm64_lock_read_dd(A)

+#define native_lock_write_dd(A, B)          arm64_lock_write_dd(A, B)

+#define native_lock_read_dq(A, B, C)        arm64_lock_read_dq(A, B, C)

+#define native_lock_write_dq(A, B, C)       arm64_lock_write_dq(A, B, C)

+#define native_lock_xchg(A, B)              arm64_lock_xchg(A, B)

+#define native_lock_storeifref(A, B, C)     arm64_lock_storeifref(A, B, C)

+#define native_lock_storeifnull(A, B)       arm64_lock_storeifnull(A, B)

+

+#else

+#error Unsupported architecture

+#endif

+

+#endif //#define __NATIVE_LOCK__H__
\ No newline at end of file
diff --git a/src/emu/x64run.c b/src/emu/x64run.c
index af5b0c8e..57238f86 100755
--- a/src/emu/x64run.c
+++ b/src/emu/x64run.c
@@ -21,7 +21,7 @@
 #include "bridge.h"
 #include "signals.h"
 #ifdef DYNAREC
-#include "../dynarec/arm64_lock.h"
+#include "../dynarec/native_lock.h"
 #endif
 
 #include "modrm.h"
diff --git a/src/emu/x64run0f.c b/src/emu/x64run0f.c
index 508b3484..7546957f 100644
--- a/src/emu/x64run0f.c
+++ b/src/emu/x64run0f.c
@@ -23,7 +23,7 @@
 #include "signals.h"

 #ifdef DYNAREC

 #include "custommem.h"

-#include "../dynarec/arm64_lock.h"

+#include "../dynarec/native_lock.h"

 #endif

 

 #include "modrm.h"

diff --git a/src/emu/x64run66.c b/src/emu/x64run66.c
index 72c83e47..3b4ebf4c 100644
--- a/src/emu/x64run66.c
+++ b/src/emu/x64run66.c
@@ -20,7 +20,7 @@
 #include "box64context.h"

 #include "bridge.h"

 #ifdef DYNAREC

-#include "../dynarec/arm64_lock.h"

+#include "../dynarec/native_lock.h"

 #endif

 

 #include "modrm.h"

diff --git a/src/emu/x64run66f0.c b/src/emu/x64run66f0.c
index 8de9e12a..3837eba1 100644
--- a/src/emu/x64run66f0.c
+++ b/src/emu/x64run66f0.c
@@ -19,7 +19,9 @@
 #include "x87emu_private.h"
 #include "box64context.h"
 #include "bridge.h"
-#include "dynarec/arm64_lock.h"
+#ifdef DYNAREC
+#include "dynarec/native_lock.h"
+#endif
 
 #include "modrm.h"
 
@@ -55,10 +57,10 @@ int Run66F0(x64emu_t *emu, rex_t rex)
                     GETGW;
 #ifdef DYNAREC
                     do {
-                        tmp16u = arm64_lock_read_h(EW);
+                        tmp16u = native_lock_read_h(EW);
                         cmp16(emu, R_AX, tmp16u);
                         if(ACCESS_FLAG(F_ZF)) {
-                            tmp32s = arm64_lock_write_h(EW, GW->word[0]);
+                            tmp32s = native_lock_write_h(EW, GW->word[0]);
                         } else {
                             R_AX = tmp16u;
                             tmp32s = 0;
@@ -89,14 +91,14 @@ int Run66F0(x64emu_t *emu, rex_t rex)
             GETGW;                                                  \
             if(rex.w) {                                             \
                 do {                                                \
-                    tmp64u = arm64_lock_read_dd(ED);                \
+                    tmp64u = native_lock_read_dd(ED);                \
                     tmp64u = OP##64(emu, tmp64u, GD->q[0]);         \
-                } while (arm64_lock_write_dd(ED, tmp64u));          \
+                } while (native_lock_write_dd(ED, tmp64u));          \
             } else {                                                \
                 do {                                                \
-                    tmp16u = arm64_lock_read_h(ED);                 \
+                    tmp16u = native_lock_read_h(ED);                 \
                     tmp16u = OP##16(emu, tmp16u, GW->word[0]);      \
-                } while (arm64_lock_write_d(ED, tmp16u));           \
+                } while (native_lock_write_d(ED, tmp16u));           \
                 if(MODREG)                                          \
                     EW->word[1] = 0;                                \
             }                                                       \
@@ -181,13 +183,13 @@ int Run66F0(x64emu_t *emu, rex_t rex)
                 }
             else
                 switch((nextop>>3)&7) {
-                    case 0: do { tmp16u2 = arm64_lock_read_h(ED); tmp16u2 = add16(emu, tmp16u2, tmp64u);} while(arm64_lock_write_h(ED, tmp16u2)); break;
-                    case 1: do { tmp16u2 = arm64_lock_read_h(ED); tmp16u2 =  or16(emu, tmp16u2, tmp64u);} while(arm64_lock_write_h(ED, tmp16u2)); break;
-                    case 2: do { tmp16u2 = arm64_lock_read_h(ED); tmp16u2 = adc16(emu, tmp16u2, tmp64u);} while(arm64_lock_write_h(ED, tmp16u2)); break;
-                    case 3: do { tmp16u2 = arm64_lock_read_h(ED); tmp16u2 = sbb16(emu, tmp16u2, tmp64u);} while(arm64_lock_write_h(ED, tmp16u2)); break;
-                    case 4: do { tmp16u2 = arm64_lock_read_h(ED); tmp16u2 = and16(emu, tmp16u2, tmp64u);} while(arm64_lock_write_h(ED, tmp16u2)); break;
-                    case 5: do { tmp16u2 = arm64_lock_read_h(ED); tmp16u2 = sub16(emu, tmp16u2, tmp64u);} while(arm64_lock_write_h(ED, tmp16u2)); break;
-                    case 6: do { tmp16u2 = arm64_lock_read_h(ED); tmp16u2 = xor16(emu, tmp16u2, tmp64u);} while(arm64_lock_write_h(ED, tmp16u2)); break;
+                    case 0: do { tmp16u2 = native_lock_read_h(ED); tmp16u2 = add16(emu, tmp16u2, tmp64u);} while(native_lock_write_h(ED, tmp16u2)); break;
+                    case 1: do { tmp16u2 = native_lock_read_h(ED); tmp16u2 =  or16(emu, tmp16u2, tmp64u);} while(native_lock_write_h(ED, tmp16u2)); break;
+                    case 2: do { tmp16u2 = native_lock_read_h(ED); tmp16u2 = adc16(emu, tmp16u2, tmp64u);} while(native_lock_write_h(ED, tmp16u2)); break;
+                    case 3: do { tmp16u2 = native_lock_read_h(ED); tmp16u2 = sbb16(emu, tmp16u2, tmp64u);} while(native_lock_write_h(ED, tmp16u2)); break;
+                    case 4: do { tmp16u2 = native_lock_read_h(ED); tmp16u2 = and16(emu, tmp16u2, tmp64u);} while(native_lock_write_h(ED, tmp16u2)); break;
+                    case 5: do { tmp16u2 = native_lock_read_h(ED); tmp16u2 = sub16(emu, tmp16u2, tmp64u);} while(native_lock_write_h(ED, tmp16u2)); break;
+                    case 6: do { tmp16u2 = native_lock_read_h(ED); tmp16u2 = xor16(emu, tmp16u2, tmp64u);} while(native_lock_write_h(ED, tmp16u2)); break;
                     case 7:                                                 cmp16(emu, ED->word[0], tmp64u); break;
                 }
 #else
@@ -217,29 +219,29 @@ int Run66F0(x64emu_t *emu, rex_t rex)
                             // unaligned
                             do {
                                 tmp64u = ED->q[0] & 0xffffffffffffff00LL;
-                                tmp64u |= arm64_lock_read_b(ED);
+                                tmp64u |= native_lock_read_b(ED);
                                 tmp64u = inc64(emu, tmp64u);
-                            } while(arm64_lock_write_b(ED, tmp64u&0xff));
+                            } while(native_lock_write_b(ED, tmp64u&0xff));
                             ED->q[0] = tmp64u;
                         }
                         else
                             do {
-                                tmp64u = arm64_lock_read_dd(ED);
-                            } while(arm64_lock_write_dd(ED, inc64(emu, tmp64u)));
+                                tmp64u = native_lock_read_dd(ED);
+                            } while(native_lock_write_dd(ED, inc64(emu, tmp64u)));
                     else {
                         if((uintptr_t)ED&1) { 
                             //meh.
                             do {
                                 tmp16u = ED->word[0];
                                 tmp16u &=~0xff;
-                                tmp16u |= arm64_lock_read_b(ED);
+                                tmp16u |= native_lock_read_b(ED);
                                 tmp16u = inc16(emu, tmp16u);
-                        } while(arm64_lock_write_b(ED, tmp16u&0xff));
+                        } while(native_lock_write_b(ED, tmp16u&0xff));
                             ED->word[0] = tmp16u;
                         } else {
                             do {
-                                tmp16u = arm64_lock_read_h(ED);
-                            } while(arm64_lock_write_h(ED, inc16(emu, tmp16u)));
+                                tmp16u = native_lock_read_h(ED);
+                            } while(native_lock_write_h(ED, inc16(emu, tmp16u)));
                         }
                     }
 #else
@@ -259,19 +261,19 @@ int Run66F0(x64emu_t *emu, rex_t rex)
                             // unaligned
                             do {
                                 tmp64u = ED->q[0] & 0xffffffffffffff00LL;
-                                tmp64u |= arm64_lock_read_b(ED);
+                                tmp64u |= native_lock_read_b(ED);
                                 tmp64u = dec64(emu, tmp64u);
-                            } while(arm64_lock_write_b(ED, tmp64u&0xff));
+                            } while(native_lock_write_b(ED, tmp64u&0xff));
                             ED->q[0] = tmp64u;
                         }
                         else
                             do {
-                                tmp64u = arm64_lock_read_dd(ED);
-                            } while(arm64_lock_write_dd(ED, dec64(emu, tmp64u)));
+                                tmp64u = native_lock_read_dd(ED);
+                            } while(native_lock_write_dd(ED, dec64(emu, tmp64u)));
                     else {
                         do {
-                            tmp16u = arm64_lock_read_h(ED);
-                        } while(arm64_lock_write_h(ED, dec16(emu, tmp16u)));
+                            tmp16u = native_lock_read_h(ED);
+                        } while(native_lock_write_h(ED, dec16(emu, tmp16u)));
                     }
 #else
                     pthread_mutex_lock(&emu->context->mutex_lock);
diff --git a/src/emu/x64run670f.c b/src/emu/x64run670f.c
index 28000ddd..1671da03 100644
--- a/src/emu/x64run670f.c
+++ b/src/emu/x64run670f.c
@@ -20,7 +20,7 @@
 #include "box64context.h"
 #include "bridge.h"
 #ifdef DYNAREC
-#include "../dynarec/arm64_lock.h"
+#include "../dynarec/native_lock.h"
 #endif
 
 #include "modrm.h"
diff --git a/src/emu/x64run6766.c b/src/emu/x64run6766.c
index 2702012c..2d53e3ff 100644
--- a/src/emu/x64run6766.c
+++ b/src/emu/x64run6766.c
@@ -20,7 +20,7 @@
 #include "box64context.h"
 #include "bridge.h"
 #ifdef DYNAREC
-#include "../dynarec/arm64_lock.h"
+#include "../dynarec/native_lock.h"
 #endif
 
 #include "modrm.h"
diff --git a/src/emu/x64runf0.c b/src/emu/x64runf0.c
index 634d3d40..91626429 100644
--- a/src/emu/x64runf0.c
+++ b/src/emu/x64runf0.c
@@ -21,7 +21,7 @@
 #include "my_cpuid.h"

 #include "bridge.h"

 #ifdef DYNAREC

-#include "../dynarec/arm64_lock.h"

+#include "../dynarec/native_lock.h"

 #endif

 

 #include "modrm.h"

@@ -53,9 +53,9 @@ int RunF0(x64emu_t *emu, rex_t rex)
             GETEB(0);                                               \

             GETGB;                                                  \

             do {                                                    \

-                tmp8u = arm64_lock_read_b(EB);                      \

+                tmp8u = native_lock_read_b(EB);                     \

                 tmp8u = OP##8(emu, tmp8u, GB);                      \

-            } while (arm64_lock_write_b(EB, tmp8u));                \

+            } while (native_lock_write_b(EB, tmp8u));               \

             break;                                                  \

         case B+1:                                                   \

             nextop = F8;                                            \

@@ -63,14 +63,14 @@ int RunF0(x64emu_t *emu, rex_t rex)
             GETGD;                                                  \

             if(rex.w) {                                             \

                 do {                                                \

-                    tmp64u = arm64_lock_read_dd(ED);                \

+                    tmp64u = native_lock_read_dd(ED);               \

                     tmp64u = OP##64(emu, tmp64u, GD->q[0]);         \

-                } while (arm64_lock_write_dd(ED, tmp64u));          \

+                } while (native_lock_write_dd(ED, tmp64u));         \

             } else {                                                \

                 do {                                                \

-                    tmp32u = arm64_lock_read_d(ED);                 \

+                    tmp32u = native_lock_read_d(ED);                \

                     tmp32u = OP##32(emu, tmp32u, GD->dword[0]);     \

-                } while (arm64_lock_write_d(ED, tmp32u));           \

+                } while (native_lock_write_d(ED, tmp32u));          \

                 if(MODREG)                                          \

                     ED->dword[1] = 0;                               \

             }                                                       \

@@ -190,14 +190,14 @@ int RunF0(x64emu_t *emu, rex_t rex)
                         }

                     } else

                         do {

-                            tmp64u = arm64_lock_read_dd(ED);

+                            tmp64u = native_lock_read_dd(ED);

                             if(tmp64u & (1LL<<tmp8u)) {

                                 SET_FLAG(F_CF);

                                 tmp32s = 0;

                             } else {

                                 tmp64u |= (1LL<<tmp8u);

                                 CLEAR_FLAG(F_CF);

-                                tmp32s = arm64_lock_write_dd(ED, tmp64u);

+                                tmp32s = native_lock_write_dd(ED, tmp64u);

                             }

                         } while(tmp32s);

                 } else {

@@ -212,14 +212,14 @@ int RunF0(x64emu_t *emu, rex_t rex)
                         ED->dword[1] = 0;

                     } else

                         do {

-                            tmp32u = arm64_lock_read_d(ED);

+                            tmp32u = native_lock_read_d(ED);

                             if(tmp32u & (1<<tmp8u)) {

                                 SET_FLAG(F_CF);

                                 tmp32s = 0;

                             } else {

                                 tmp32u |= (1<<tmp8u);

                                 CLEAR_FLAG(F_CF);

-                                tmp32s = arm64_lock_write_d(ED, tmp32u);

+                                tmp32s = native_lock_write_d(ED, tmp32u);

                             }

                         } while(tmp32s);

                 }

@@ -255,10 +255,10 @@ int RunF0(x64emu_t *emu, rex_t rex)
                     GETEB(0);

 #ifdef DYNAREC

                     do {

-                        tmp8u = arm64_lock_read_b(EB);

+                        tmp8u = native_lock_read_b(EB);

                         cmp8(emu, R_AL, tmp8u);

                         if(ACCESS_FLAG(F_ZF)) {

-                            tmp32s = arm64_lock_write_b(EB, GB);

+                            tmp32s = native_lock_write_b(EB, GB);

                         } else {

                             R_AL = tmp8u;

                             tmp32s = 0;

@@ -284,10 +284,10 @@ int RunF0(x64emu_t *emu, rex_t rex)
                         if(((uintptr_t)ED)&7) {

                             do {

                                 tmp64u = ED->q[0] & ~0xffLL;

-                                tmp64u |= arm64_lock_read_b(ED);

+                                tmp64u |= native_lock_read_b(ED);

                                 cmp64(emu, R_RAX, tmp64u);

                                 if(ACCESS_FLAG(F_ZF)) {

-                                    tmp32s = arm64_lock_write_b(ED, GD->q[0]&0xff);

+                                    tmp32s = native_lock_write_b(ED, GD->q[0]&0xff);

                                     if(!tmp32s)

                                         ED->q[0] = GD->q[0];

                                 } else {

@@ -297,10 +297,10 @@ int RunF0(x64emu_t *emu, rex_t rex)
                             } while(tmp32s);

                         } else

                             do {

-                                tmp64u = arm64_lock_read_dd(ED);

+                                tmp64u = native_lock_read_dd(ED);

                                 cmp64(emu, R_RAX, tmp64u);

                                 if(ACCESS_FLAG(F_ZF)) {

-                                    tmp32s = arm64_lock_write_dd(ED, GD->q[0]);

+                                    tmp32s = native_lock_write_dd(ED, GD->q[0]);

                                 } else {

                                     R_RAX = tmp64u;

                                     tmp32s = 0;

@@ -308,10 +308,10 @@ int RunF0(x64emu_t *emu, rex_t rex)
                             } while(tmp32s);

                     else {

                         do {

-                            tmp32u = arm64_lock_read_d(ED);

+                            tmp32u = native_lock_read_d(ED);

                             cmp32(emu, R_EAX, tmp32u);

                             if(ACCESS_FLAG(F_ZF)) {

-                                tmp32s = arm64_lock_write_d(ED, GD->dword[0]);

+                                tmp32s = native_lock_write_d(ED, GD->dword[0]);

                             } else {

                                 R_EAX = tmp32u;

                                 tmp32s = 0;

@@ -359,11 +359,11 @@ int RunF0(x64emu_t *emu, rex_t rex)
 #ifdef DYNAREC

                     if(rex.w)

                         do {

-                            tmp64u = arm64_lock_read_dd(ED);

+                            tmp64u = native_lock_read_dd(ED);

                             if(tmp64u & (1LL<<tmp8u)) {

                                 SET_FLAG(F_CF);

                                 tmp64u ^= (1LL<<tmp8u);

-                                tmp32s = arm64_lock_write_dd(ED, tmp64u);

+                                tmp32s = native_lock_write_dd(ED, tmp64u);

                             } else {

                                 CLEAR_FLAG(F_CF);

                                 tmp32s = 0;

@@ -371,11 +371,11 @@ int RunF0(x64emu_t *emu, rex_t rex)
                         } while(tmp32s);

                     else {

                         do {

-                            tmp32u = arm64_lock_read_d(ED);

+                            tmp32u = native_lock_read_d(ED);

                             if(tmp32u & (1<<tmp8u)) {

                                 SET_FLAG(F_CF);

                                 tmp32u ^= (1<<tmp8u);

-                                tmp32s = arm64_lock_write_d(ED, tmp32u);

+                                tmp32s = native_lock_write_d(ED, tmp32u);

                             } else {

                                 CLEAR_FLAG(F_CF);

                                 tmp32s = 0;

@@ -434,26 +434,26 @@ int RunF0(x64emu_t *emu, rex_t rex)
                                 if(rex.w) {

                                     tmp8u&=63;

                                     do {

-                                        tmp64u = arm64_lock_read_dd(ED);

+                                        tmp64u = native_lock_read_dd(ED);

                                         if(tmp64u & (1LL<<tmp8u)) {

                                             SET_FLAG(F_CF);

                                             tmp32s = 0;

                                         } else {

                                             tmp64u ^= (1LL<<tmp8u);

-                                            tmp32s = arm64_lock_write_dd(ED, tmp64u);

+                                            tmp32s = native_lock_write_dd(ED, tmp64u);

                                             CLEAR_FLAG(F_CF);

                                         }

                                     } while(tmp32s);

                                 } else {

                                     tmp8u&=31;

                                     do {

-                                        tmp32u = arm64_lock_read_d(ED);

+                                        tmp32u = native_lock_read_d(ED);

                                         if(tmp32u & (1<<tmp8u)) {

                                             SET_FLAG(F_CF);

                                             tmp32s = 0;

                                         } else {

                                             tmp32u ^= (1<<tmp8u);

-                                            tmp32s = arm64_lock_write_d(ED, tmp32u);

+                                            tmp32s = native_lock_write_d(ED, tmp32u);

                                             CLEAR_FLAG(F_CF);

                                         }

                                     } while(tmp32s);

@@ -488,11 +488,11 @@ int RunF0(x64emu_t *emu, rex_t rex)
                                 if(rex.w) {

                                     do {

                                         tmp8u&=63;

-                                        tmp64u = arm64_lock_read_dd(ED);

+                                        tmp64u = native_lock_read_dd(ED);

                                         if(tmp64u & (1LL<<tmp8u)) {

                                             SET_FLAG(F_CF);

                                             tmp64u ^= (1LL<<tmp8u);

-                                            tmp32s = arm64_lock_write_dd(ED, tmp64u);

+                                            tmp32s = native_lock_write_dd(ED, tmp64u);

                                         } else {

                                             tmp32s = 0;

                                             CLEAR_FLAG(F_CF);

@@ -501,11 +501,11 @@ int RunF0(x64emu_t *emu, rex_t rex)
                                 } else {

                                     tmp8u&=31;

                                     do {

-                                        tmp32u = arm64_lock_read_d(ED);

+                                        tmp32u = native_lock_read_d(ED);

                                         if(tmp32u & (1<<tmp8u)) {

                                             SET_FLAG(F_CF);

                                             tmp32u ^= (1<<tmp8u);

-                                            tmp32s = arm64_lock_write_d(ED, tmp32u);

+                                            tmp32s = native_lock_write_d(ED, tmp32u);

                                         } else {

                                             CLEAR_FLAG(F_CF);

                                             tmp32s = 0;

@@ -540,24 +540,24 @@ int RunF0(x64emu_t *emu, rex_t rex)
                                 if(rex.w) {

                                     tmp8u&=63;

                                     do {

-                                        tmp64u = arm64_lock_read_dd(ED);

+                                        tmp64u = native_lock_read_dd(ED);

                                         if(tmp64u & (1LL<<tmp8u))

                                             SET_FLAG(F_CF);

                                         else

                                             CLEAR_FLAG(F_CF);

                                         tmp64u ^= (1LL<<tmp8u);

-                                        tmp32s = arm64_lock_write_dd(ED, tmp64u);

+                                        tmp32s = native_lock_write_dd(ED, tmp64u);

                                     } while(tmp32s);

                                 } else {

                                     tmp8u&=31;

                                     do {

-                                        tmp32u = arm64_lock_read_d(ED);

+                                        tmp32u = native_lock_read_d(ED);

                                         if(tmp32u & (1<<tmp8u))

                                             SET_FLAG(F_CF);

                                         else

                                             CLEAR_FLAG(F_CF);

                                         tmp32u ^= (1<<tmp8u);

-                                        tmp32s = arm64_lock_write_d(ED, tmp32u);

+                                        tmp32s = native_lock_write_d(ED, tmp32u);

                                     } while(tmp32s);

                                 }

 #else

@@ -592,9 +592,9 @@ int RunF0(x64emu_t *emu, rex_t rex)
                     GETGB;

 #ifdef DYNAREC

                     do {

-                        tmp8u = arm64_lock_read_b(EB);

+                        tmp8u = native_lock_read_b(EB);

                         tmp8u2 = add8(emu, tmp8u, GB);

-                    } while(arm64_lock_write_b(EB, tmp8u2));

+                    } while(native_lock_write_b(EB, tmp8u2));

 #else

                     pthread_mutex_lock(&emu->context->mutex_lock);

                     tmp8u = add8(emu, EB->byte[0], GB);

@@ -610,23 +610,23 @@ int RunF0(x64emu_t *emu, rex_t rex)
 #ifdef DYNAREC

                     if(rex.w) {

                         do {

-                            tmp64u = arm64_lock_read_dd(ED);

+                            tmp64u = native_lock_read_dd(ED);

                             tmp64u2 = add64(emu, tmp64u, GD->q[0]);

-                        } while(arm64_lock_write_dd(ED, tmp64u2));

+                        } while(native_lock_write_dd(ED, tmp64u2));

                         GD->q[0] = tmp64u;

                     } else {

                         if(((uintptr_t)ED)&3) {

                             do {

                                 tmp32u = ED->dword[0] & ~0xff;

-                                tmp32u |= arm64_lock_read_b(ED);

+                                tmp32u |= native_lock_read_b(ED);

                                 tmp32u2 = add32(emu, tmp32u, GD->dword[0]);

-                            } while(arm64_lock_write_b(ED, tmp32u2&0xff));

+                            } while(native_lock_write_b(ED, tmp32u2&0xff));

                             ED->dword[0] = tmp32u2;

                         } else {

                             do {

-                                tmp32u = arm64_lock_read_d(ED);

+                                tmp32u = native_lock_read_d(ED);

                                 tmp32u2 = add32(emu, tmp32u, GD->dword[0]);

-                            } while(arm64_lock_write_d(ED, tmp32u2));

+                            } while(native_lock_write_d(ED, tmp32u2));

                         }

                         GD->q[0] = tmp32u;

                         if(MODREG)

@@ -660,10 +660,10 @@ int RunF0(x64emu_t *emu, rex_t rex)
 #ifdef DYNAREC

                             if(rex.w)

                                 do {

-                                    arm64_lock_read_dq(&tmp64u, &tmp64u2, ED);

+                                    native_lock_read_dq(&tmp64u, &tmp64u2, ED);

                                     if(R_RAX == tmp64u && R_RDX == tmp64u2) {

                                         SET_FLAG(F_ZF);

-                                        tmp32s = arm64_lock_write_dq(R_RBX, R_RCX, ED);

+                                        tmp32s = native_lock_write_dq(R_RBX, R_RCX, ED);

                                     } else {

                                         CLEAR_FLAG(F_ZF);

                                         R_RAX = tmp64u;

@@ -673,10 +673,10 @@ int RunF0(x64emu_t *emu, rex_t rex)
                                 } while(tmp32s);

                             else

                                 do {

-                                    tmp64u = arm64_lock_read_dd(ED);

+                                    tmp64u = native_lock_read_dd(ED);

                                     if((R_EAX == (tmp64u&0xffffffff)) && (R_EDX == ((tmp64u>>32)&0xffffffff))) {

                                         SET_FLAG(F_ZF);

-                                        tmp32s = arm64_lock_write_dd(ED, R_EBX|(((uint64_t)R_ECX)<<32));

+                                        tmp32s = native_lock_write_dd(ED, R_EBX|(((uint64_t)R_ECX)<<32));

                                     } else {

                                         CLEAR_FLAG(F_ZF);

                                         R_RAX = tmp64u&0xffffffff;

@@ -733,13 +733,13 @@ int RunF0(x64emu_t *emu, rex_t rex)
             tmp8u = F8;

 #ifdef DYNAREC

             switch((nextop>>3)&7) {

-                case 0: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = add8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

-                case 1: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 =  or8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

-                case 2: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = adc8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

-                case 3: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = sbb8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

-                case 4: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = and8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

-                case 5: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = sub8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

-                case 6: do { tmp8u2 = arm64_lock_read_b(EB); tmp8u2 = xor8(emu, tmp8u2, tmp8u);} while(arm64_lock_write_b(EB, tmp8u2)); break;

+                case 0: do { tmp8u2 = native_lock_read_b(EB); tmp8u2 = add8(emu, tmp8u2, tmp8u);} while(native_lock_write_b(EB, tmp8u2)); break;

+                case 1: do { tmp8u2 = native_lock_read_b(EB); tmp8u2 =  or8(emu, tmp8u2, tmp8u);} while(native_lock_write_b(EB, tmp8u2)); break;

+                case 2: do { tmp8u2 = native_lock_read_b(EB); tmp8u2 = adc8(emu, tmp8u2, tmp8u);} while(native_lock_write_b(EB, tmp8u2)); break;

+                case 3: do { tmp8u2 = native_lock_read_b(EB); tmp8u2 = sbb8(emu, tmp8u2, tmp8u);} while(native_lock_write_b(EB, tmp8u2)); break;

+                case 4: do { tmp8u2 = native_lock_read_b(EB); tmp8u2 = and8(emu, tmp8u2, tmp8u);} while(native_lock_write_b(EB, tmp8u2)); break;

+                case 5: do { tmp8u2 = native_lock_read_b(EB); tmp8u2 = sub8(emu, tmp8u2, tmp8u);} while(native_lock_write_b(EB, tmp8u2)); break;

+                case 6: do { tmp8u2 = native_lock_read_b(EB); tmp8u2 = xor8(emu, tmp8u2, tmp8u);} while(native_lock_write_b(EB, tmp8u2)); break;

                 case 7:               cmp8(emu, EB->byte[0], tmp8u); break;

             }

 #else

@@ -769,13 +769,13 @@ int RunF0(x64emu_t *emu, rex_t rex)
 #ifdef DYNAREC

             if(rex.w) {

                 switch((nextop>>3)&7) {

-                    case 0: do { tmp64u2 = arm64_lock_read_dd(ED); tmp64u2 = add64(emu, tmp64u2, tmp64u);} while(arm64_lock_write_dd(ED, tmp64u2)); break;

-                    case 1: do { tmp64u2 = arm64_lock_read_dd(ED); tmp64u2 =  or64(emu, tmp64u2, tmp64u);} while(arm64_lock_write_dd(ED, tmp64u2)); break;

-                    case 2: do { tmp64u2 = arm64_lock_read_dd(ED); tmp64u2 = adc64(emu, tmp64u2, tmp64u);} while(arm64_lock_write_dd(ED, tmp64u2)); break;

-                    case 3: do { tmp64u2 = arm64_lock_read_dd(ED); tmp64u2 = sbb64(emu, tmp64u2, tmp64u);} while(arm64_lock_write_dd(ED, tmp64u2)); break;

-                    case 4: do { tmp64u2 = arm64_lock_read_dd(ED); tmp64u2 = and64(emu, tmp64u2, tmp64u);} while(arm64_lock_write_dd(ED, tmp64u2)); break;

-                    case 5: do { tmp64u2 = arm64_lock_read_dd(ED); tmp64u2 = sub64(emu, tmp64u2, tmp64u);} while(arm64_lock_write_dd(ED, tmp64u2)); break;

-                    case 6: do { tmp64u2 = arm64_lock_read_dd(ED); tmp64u2 = xor64(emu, tmp64u2, tmp64u);} while(arm64_lock_write_dd(ED, tmp64u2)); break;

+                    case 0: do { tmp64u2 = native_lock_read_dd(ED); tmp64u2 = add64(emu, tmp64u2, tmp64u);} while(native_lock_write_dd(ED, tmp64u2)); break;

+                    case 1: do { tmp64u2 = native_lock_read_dd(ED); tmp64u2 =  or64(emu, tmp64u2, tmp64u);} while(native_lock_write_dd(ED, tmp64u2)); break;

+                    case 2: do { tmp64u2 = native_lock_read_dd(ED); tmp64u2 = adc64(emu, tmp64u2, tmp64u);} while(native_lock_write_dd(ED, tmp64u2)); break;

+                    case 3: do { tmp64u2 = native_lock_read_dd(ED); tmp64u2 = sbb64(emu, tmp64u2, tmp64u);} while(native_lock_write_dd(ED, tmp64u2)); break;

+                    case 4: do { tmp64u2 = native_lock_read_dd(ED); tmp64u2 = and64(emu, tmp64u2, tmp64u);} while(native_lock_write_dd(ED, tmp64u2)); break;

+                    case 5: do { tmp64u2 = native_lock_read_dd(ED); tmp64u2 = sub64(emu, tmp64u2, tmp64u);} while(native_lock_write_dd(ED, tmp64u2)); break;

+                    case 6: do { tmp64u2 = native_lock_read_dd(ED); tmp64u2 = xor64(emu, tmp64u2, tmp64u);} while(native_lock_write_dd(ED, tmp64u2)); break;

                     case 7:                cmp64(emu, ED->q[0], tmp64u); break;

                 }

             } else {

@@ -792,13 +792,13 @@ int RunF0(x64emu_t *emu, rex_t rex)
                     }

                 else

                     switch((nextop>>3)&7) {

-                        case 0: do { tmp32u2 = arm64_lock_read_d(ED); tmp32u2 = add32(emu, tmp32u2, tmp64u);} while(arm64_lock_write_d(ED, tmp32u2)); break;

-                        case 1: do { tmp32u2 = arm64_lock_read_d(ED); tmp32u2 =  or32(emu, tmp32u2, tmp64u);} while(arm64_lock_write_d(ED, tmp32u2)); break;

-                        case 2: do { tmp32u2 = arm64_lock_read_d(ED); tmp32u2 = adc32(emu, tmp32u2, tmp64u);} while(arm64_lock_write_d(ED, tmp32u2)); break;

-                        case 3: do { tmp32u2 = arm64_lock_read_d(ED); tmp32u2 = sbb32(emu, tmp32u2, tmp64u);} while(arm64_lock_write_d(ED, tmp32u2)); break;

-                        case 4: do { tmp32u2 = arm64_lock_read_d(ED); tmp32u2 = and32(emu, tmp32u2, tmp64u);} while(arm64_lock_write_d(ED, tmp32u2)); break;

-                        case 5: do { tmp32u2 = arm64_lock_read_d(ED); tmp32u2 = sub32(emu, tmp32u2, tmp64u);} while(arm64_lock_write_d(ED, tmp32u2)); break;

-                        case 6: do { tmp32u2 = arm64_lock_read_d(ED); tmp32u2 = xor32(emu, tmp32u2, tmp64u);} while(arm64_lock_write_d(ED, tmp32u2)); break;

+                        case 0: do { tmp32u2 = native_lock_read_d(ED); tmp32u2 = add32(emu, tmp32u2, tmp64u);} while(native_lock_write_d(ED, tmp32u2)); break;

+                        case 1: do { tmp32u2 = native_lock_read_d(ED); tmp32u2 =  or32(emu, tmp32u2, tmp64u);} while(native_lock_write_d(ED, tmp32u2)); break;

+                        case 2: do { tmp32u2 = native_lock_read_d(ED); tmp32u2 = adc32(emu, tmp32u2, tmp64u);} while(native_lock_write_d(ED, tmp32u2)); break;

+                        case 3: do { tmp32u2 = native_lock_read_d(ED); tmp32u2 = sbb32(emu, tmp32u2, tmp64u);} while(native_lock_write_d(ED, tmp32u2)); break;

+                        case 4: do { tmp32u2 = native_lock_read_d(ED); tmp32u2 = and32(emu, tmp32u2, tmp64u);} while(native_lock_write_d(ED, tmp32u2)); break;

+                        case 5: do { tmp32u2 = native_lock_read_d(ED); tmp32u2 = sub32(emu, tmp32u2, tmp64u);} while(native_lock_write_d(ED, tmp32u2)); break;

+                        case 6: do { tmp32u2 = native_lock_read_d(ED); tmp32u2 = xor32(emu, tmp32u2, tmp64u);} while(native_lock_write_d(ED, tmp32u2)); break;

                         case 7:                                                 cmp32(emu, ED->dword[0], tmp64u); break;

                     }

             }

@@ -859,11 +859,11 @@ int RunF0(x64emu_t *emu, rex_t rex)
                 }

             } else {

                 if(rex.w) {

-                    GD->q[0] = arm64_lock_xchg(ED, GD->q[0]);

+                    GD->q[0] = native_lock_xchg(ED, GD->q[0]);

                 } else {

                     do {

-                        tmp32u = arm64_lock_read_d(ED);

-                    } while(arm64_lock_write_d(ED, GD->dword[0]));

+                        tmp32u = native_lock_read_d(ED);

+                    } while(native_lock_write_d(ED, GD->dword[0]));

                     GD->q[0] = tmp32u;

                 }

             }

@@ -897,29 +897,29 @@ int RunF0(x64emu_t *emu, rex_t rex)
                             // unaligned

                             do {

                                 tmp64u = ED->q[0] & 0xffffffffffffff00LL;

-                                tmp64u |= arm64_lock_read_b(ED);

+                                tmp64u |= native_lock_read_b(ED);

                                 tmp64u = inc64(emu, tmp64u);

-                            } while(arm64_lock_write_b(ED, tmp64u&0xff));

+                            } while(native_lock_write_b(ED, tmp64u&0xff));

                             ED->q[0] = tmp64u;

                         }

                         else

                             do {

-                                tmp64u = arm64_lock_read_dd(ED);

-                            } while(arm64_lock_write_dd(ED, inc64(emu, tmp64u)));

+                                tmp64u = native_lock_read_dd(ED);

+                            } while(native_lock_write_dd(ED, inc64(emu, tmp64u)));

                     else {

                         if((uintptr_t)ED&3) { 

                             //meh.

                             do {

                                 tmp32u = ED->dword[0];

                                 tmp32u &=~0xff;

-                                tmp32u |= arm64_lock_read_b(ED);

+                                tmp32u |= native_lock_read_b(ED);

                                 tmp32u = inc32(emu, tmp32u);

-                        } while(arm64_lock_write_b(ED, tmp32u&0xff));

+                        } while(native_lock_write_b(ED, tmp32u&0xff));

                             ED->dword[0] = tmp32u;

                         } else {

                             do {

-                                tmp32u = arm64_lock_read_d(ED);

-                            } while(arm64_lock_write_d(ED, inc32(emu, tmp32u)));

+                                tmp32u = native_lock_read_d(ED);

+                            } while(native_lock_write_d(ED, inc32(emu, tmp32u)));

                         }

                         if(MODREG) ED->dword[1] = 0;

                     }

@@ -943,19 +943,19 @@ int RunF0(x64emu_t *emu, rex_t rex)
                             // unaligned

                             do {

                                 tmp64u = ED->q[0] & 0xffffffffffffff00LL;

-                                tmp64u |= arm64_lock_read_b(ED);

+                                tmp64u |= native_lock_read_b(ED);

                                 tmp64u = dec64(emu, tmp64u);

-                            } while(arm64_lock_write_b(ED, tmp64u&0xff));

+                            } while(native_lock_write_b(ED, tmp64u&0xff));

                             ED->q[0] = tmp64u;

                         }

                         else

                             do {

-                                tmp64u = arm64_lock_read_dd(ED);

-                            } while(arm64_lock_write_dd(ED, dec64(emu, tmp64u)));

+                                tmp64u = native_lock_read_dd(ED);

+                            } while(native_lock_write_dd(ED, dec64(emu, tmp64u)));

                     else {

                         do {

-                            tmp32u = arm64_lock_read_d(ED);

-                        } while(arm64_lock_write_d(ED, dec32(emu, tmp32u)));

+                            tmp32u = native_lock_read_d(ED);

+                        } while(native_lock_write_d(ED, dec32(emu, tmp32u)));

                         if(MODREG) ED->dword[1] = 0;

                     }

 #else

diff --git a/src/include/dynarec_arm64.h b/src/include/dynarec_native.h
index bc4cf3f6..bc4cf3f6 100755
--- a/src/include/dynarec_arm64.h
+++ b/src/include/dynarec_native.h