From: Paul Floyd Date: Fri, 27 Feb 2026 20:26:23 +0000 (+0100) Subject: Clean up setting carry flag in VG_(fixup_guest_state_after_syscall_interrupted) X-Git-Tag: VALGRIND_3_27_0~142 X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=9529ce722eea10a32cbeefe1bafc8745b565f8fa;p=thirdparty%2Fvalgrind.git Clean up setting carry flag in VG_(fixup_guest_state_after_syscall_interrupted) This wasn't consistent (not at all for Darwin, not checking SfNoWriteResult on Solaris and a bit long winded on FreeBSD). Simplify the code for all 3 platforms. --- diff --git a/coregrind/m_syswrap/syswrap-main.c b/coregrind/m_syswrap/syswrap-main.c index 07f193046..763833c52 100644 --- a/coregrind/m_syswrap/syswrap-main.c +++ b/coregrind/m_syswrap/syswrap-main.c @@ -3407,40 +3407,24 @@ VG_(fixup_guest_state_after_syscall_interrupted)( ThreadId tid, we expect our caller (the signal handler) will have fixed this up. */ /* XXX: needed? */ -#if defined(VGP_x86_freebsd) - /* On FreeBSD, the success/fail status is returned to the caller - and still has to be fixed up here. */ +#if defined(VGP_x86_freebsd) || defined(VGP_x86_solaris) || defined(VGP_x86_darwin) + /* The %eax and %edx values are committed but the carry flag is still + uncommitted. Save it now. */ if (!(sci->flags & SfNoWriteResult)) { - if (sr_isError(sres)) - LibVEX_GuestX86_put_eflag_c(1, &th_regs->vex); - else - LibVEX_GuestX86_put_eflag_c(0, &th_regs->vex); + LibVEX_GuestX86_put_eflag_c(sr_isError(sres), &th_regs->vex); } -#elif defined(VGP_amd64_freebsd) +#elif defined(VGP_amd64_freebsd) || defined(VGP_amd64_solaris) || defined(VGP_amd64_darwin) if (!(sci->flags & SfNoWriteResult)) { - if (sr_isError(sres)) - LibVEX_GuestAMD64_put_rflag_c(1, &th_regs->vex); - else - LibVEX_GuestAMD64_put_rflag_c(0, &th_regs->vex); + LibVEX_GuestAMD64_put_rflag_c(sr_isError(sres), &th_regs->vex); } #elif defined(VGP_arm64_freebsd) if (!(sci->flags & SfNoWriteResult)) { - if (sr_isError(sres)) - LibVEX_GuestARM64_put_nzcv_c(1, &th_regs->vex); - else - LibVEX_GuestARM64_put_nzcv_c(0, &th_regs->vex); + LibVEX_GuestARM64_put_nzcv_c(sr_isError(sres), &th_regs->vex); } #endif if (VG_(clo_trace_signals)) VG_(message)( Vg_DebugMsg, " completed and committed: nothing to do\n"); -# if defined(VGP_x86_solaris) - /* The %eax and %edx values are committed but the carry flag is still - uncommitted. Save it now. */ - LibVEX_GuestX86_put_eflag_c(sr_isError(sres), &th_regs->vex); -# elif defined(VGP_amd64_solaris) - LibVEX_GuestAMD64_put_rflag_c(sr_isError(sres), &th_regs->vex); -# endif getSyscallStatusFromGuestState( &sci->status, &th_regs->vex ); vg_assert(sci->status.what == SsComplete); VG_(post_syscall)(tid);