在 2021-06-16 00:04, Biswapriyo Nath 写道:
I don't consider myself expert on this topic. But while _exploring_ something, I found these (MxCsr and FpCsr) are missing from JUMP_BUFFER. Is this right? wine also don't have these. Wondering why? Thought attached.
This patch looks correct but is incomplete, because FP and SSE control registers have to be restored in `longjmp.S`.
I actually have a testcase for this which can prove that the UCRTAPP behavior is incorrect. See comments in attached file for details.
-- Best regards, Liu Hao
// Note this testcase does not work on x86. // // cl test.c && ./test.exe // gcc test.c && ./a.exe // gcc test.c -nodefaultlibs -lmingwex -lmingw32 \ // -lgcc -lgcc_s -lucrtapp -lkernel32 && ./a.exe // // Expected outputs: // // before setjmp, rounding was set to 0200 // after setjmp, rounding is 0200 // before long jmp, rounding was set to 0100 // after longjmp, rounding is 0200 #define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> #include <float.h> #include <setjmp.h> #ifdef _MSC_VER #pragma fenv_access (on) #else #pragma STDC FENV_ACCESS on #endif int main(void) { jmp_buf buf; unsigned r; r = _controlfp(_RC_UP, _MCW_RC); printf("before setjmp, rounding was set to %.4x\n", r & _MCW_RC); if(setjmp(buf) == 0) { r = _controlfp(0, 0); printf("after setjmp, rounding is %.4x\n", r & _MCW_RC); r = _controlfp(_RC_DOWN, _MCW_RC); printf("before long jmp, rounding was set to %.4x\n", r & _MCW_RC); longjmp(buf, 1); } r = _controlfp(0, 0); printf("after longjmp, rounding is %.4x\n", r & _MCW_RC); }
OpenPGP_signature
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list Mingw-w64-public@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mingw-w64-public