On Wed, 30 Mar 2022, LIU Hao wrote:
在 2022-03-30 04:53, Martin Storsjö 写道:
After some back-and-forth, we found that __mingw_setjmp/__mingw_longjmp do
work in this case, but it is not obvious how to satisfy the conditions in
the headers to switch to that implementation without switching the
exception model, which seems like it could have some serious side-effects.
I was wondering if it might make sense to add a check for a
user-controllable define to override the implementation (something like
USE_NO_MINGW_SETJMP_TWO_ARGS seems to be intended to do) for situations
where code is generated at runtime without SEH tables.
Yup, such a mechanism makes perfect sense to me. Either invent a new one,
or see if the existing ifdefs in the header can be fixed to work like it
seems to be intended.
Does it make sense to use `__builtin_setjmp()` and `__builtin_longjmp()`
here? I am not sure whether Clang supports these. On x86 they restore only
the BP and SP registers (other caller-saved registers are not preserved) and
do not unwind the stack, so technically they shall not appear in the same
function.
Clang does support them, but as they don't restore all registers, they
can't be used as a generic replacement for the proper user-facing
setjmp/longjmp. (I'm not quite sure exactly where/how they're supposed to
be used - I think they can be part of the sjlj unwinding mechanism, where
there's other compiler generated code that restores all the relevant
registers if needed.) Our own __mingw_setjmp/__mingw_longjmp backs up and
restores all the relevant registers though, so they're extremely failsafe
implementations for the userfacing setjmp/longjmp.
// Martin
_______________________________________________
Mingw-w64-public mailing list
Mingw-w64-public@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public