about summary refs log tree commit diff stats
path: root/src/dynarec
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2023-11-17 16:21:38 +0100
committerptitSeb <sebastien.chev@gmail.com>2023-11-17 16:21:38 +0100
commit54be0c0dec8ad3c81caa0366f84c056717792cb2 (patch)
treeec3f895739734aba1a0b73eb622634cf39c1e8c4 /src/dynarec
parent20df2789b542b5c280d71b4ae0fa797a24f6d130 (diff)
downloadbox64-54be0c0dec8ad3c81caa0366f84c056717792cb2.tar.gz
box64-54be0c0dec8ad3c81caa0366f84c056717792cb2.zip
Saved defered flag status when processing signal / foreign function
Diffstat (limited to 'src/dynarec')
-rw-r--r--src/dynarec/dynarec.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/dynarec/dynarec.c b/src/dynarec/dynarec.c
index b832b1e5..16c1c464 100644
--- a/src/dynarec/dynarec.c
+++ b/src/dynarec/dynarec.c
@@ -81,6 +81,15 @@ void DynaCall(x64emu_t* emu, uintptr_t addr)
     uint64_t old_rsi = R_RSI;
     uint64_t old_rbp = R_RBP;
     uint64_t old_rip = R_RIP;
+    // save defered flags
+    deferred_flags_t old_df = emu->df;
+    multiuint_t old_op1 = emu->op1;
+    multiuint_t old_op2 = emu->op2;
+    multiuint_t old_res = emu->res;
+    multiuint_t old_op1_sav= emu->op1_sav;
+    multiuint_t old_res_sav= emu->res_sav;
+    deferred_flags_t old_df_sav= emu->df_sav;
+
     PushExit(emu);
     R_RIP = addr;
     emu->df = d_none;
@@ -91,6 +100,15 @@ void DynaCall(x64emu_t* emu, uintptr_t addr)
         if(emu->flags.quitonlongjmp==1)
             emu->flags.longjmp = 0;   // don't change anything because of the longjmp
     } else {
+        // restore defered flags
+        emu->df = old_df;
+        emu->op1 = old_op1;
+        emu->op2 = old_op2;
+        emu->res = old_res;
+        emu->op1_sav = old_op1_sav;
+        emu->res_sav = old_res_sav;
+        emu->df_sav = old_df_sav;
+        // and the old registers
         R_RBX = old_rbx;
         R_RDI = old_rdi;
         R_RSI = old_rsi;
@@ -100,6 +118,7 @@ void DynaCall(x64emu_t* emu, uintptr_t addr)
     }
 }
 
+int my_setcontext(x64emu_t* emu, void* ucp);
 void DynaRun(x64emu_t* emu)
 {
     // prepare setjump for signal handling
@@ -158,6 +177,10 @@ void DynaRun(x64emu_t* emu)
                 emu->fork = 0;
                 emu = x64emu_fork(emu, forktype);
             }
+            if(emu->quit && emu->uc_link) {
+                emu->quit = 0;
+                my_setcontext(emu, emu->uc_link);
+            }
         }
 #endif
         if(emu->flags.need_jmpbuf)