在 2025-12-26 07:13, Pali Rohár 写道:
gcc does not support __try / __except syntax, so manually register SEH handler. This 32-bit x86 code should work with also other compilers as it uses only functions and structures provided by Windows SDK header files. --- mingw-w64-libraries/winpthreads/src/thread.c | 30 +++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)diff --git a/mingw-w64-libraries/winpthreads/src/thread.c b/mingw-w64-libraries/winpthreads/src/thread.c index f32dcc6ecb02..e2f9806ad579 100644 --- a/mingw-w64-libraries/winpthreads/src/thread.c +++ b/mingw-w64-libraries/winpthreads/src/thread.c @@ -86,6 +86,22 @@ SetThreadName_VEH (PEXCEPTION_POINTERS ExceptionInfo) return EXCEPTION_CONTINUE_SEARCH; }+#if !defined(_MSC_VER) && defined(__i386__)+static EXCEPTION_DISPOSITION __cdecl +SetThreadName_SEH (EXCEPTION_RECORD *ExceptionRecord, PVOID EstablisherFrame, CONTEXT *ContextRecord, PVOID DispatcherContext) +{ + /* Do not be confused with VEH handlers and CRT except filters which returns LONG value with UPPER_CASE constants. + * SEH handlers like this one return value from EXCEPTION_DISPOSITION enum which has CamelCase constants. + * UPPER_CASE EXCEPTION_CONTINUE_SEARCH and CamelCase ExceptionContinueSearch are different constants. + */ + if (ExceptionRecord != NULL && + ExceptionRecord->ExceptionCode == EXCEPTION_SET_THREAD_NAME) + return ExceptionContinueExecution; +
`ExceptionRecord` can't be null. Besides, it's necessary to check whether the
exception is non-continuable:
if (!(ExceptionRecord->ExceptionFlags & EXCEPTION_NONCONTINUABLE) &&
ExceptionRecord->ExceptionCode == EXCEPTION_SET_THREAD_NAME)
return ExceptionContinueExecution;
--
Best regards,
LIU Hao
OpenPGP_signature.asc
Description: OpenPGP digital signature
_______________________________________________ Mingw-w64-public mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/mingw-w64-public
