Hello,
On Thu, 11 Apr 2019, Michael Matz wrote:
I wonder why the result worked under wine then, though; strange.
Must be the very old wine version on the machine I initially used for
testing (where the program indeed works). With newer wine I can
reproduce the non-working.
So, with the hint of grischka I came up with the attached patch which
implements the plumbing in the startup files so that Christians example
signal.c works. It's not in any way a real implementation of SEH, but
that isn't necessary.
I'll wait for feedback on this and not yet commit to git.
Ciao,
Michael.
diff --git a/win32/lib/crt1.c b/win32/lib/crt1.c
index 0e04fc0..e0ec5d5 100644
--- a/win32/lib/crt1.c
+++ b/win32/lib/crt1.c
@@ -4,6 +4,7 @@
// _UNICODE for tchar.h, UNICODE for API
#include <tchar.h>
+#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
@@ -37,9 +38,19 @@ extern int _tmain(int argc, _TCHAR * argv[], _TCHAR * env[]);
/* Allow command-line globbing with "int _dowildcard = 1;" in the user source */
int _dowildcard;
+#ifdef __x86_64__
+static LONG WINAPI catch_sig(EXCEPTION_POINTERS *ex)
+{
+ return _XcptFilter(ex->ExceptionRecord->ExceptionCode, ex);
+}
+#endif
+
void _tstart(void)
{
__TRY__
+#ifdef __x86_64__
+ SetUnhandledExceptionFilter(catch_sig);
+#endif
_startupinfo start_info = {0};
// Sets the current application type
diff --git a/win32/lib/wincrt1.c b/win32/lib/wincrt1.c
index ce3a63f..bad3d95 100644
--- a/win32/lib/wincrt1.c
+++ b/win32/lib/wincrt1.c
@@ -26,6 +26,13 @@ int APIENTRY wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
typedef struct { int newmode; } _startupinfo;
int __cdecl __tgetmainargs(int *pargc, _TCHAR ***pargv, _TCHAR ***penv, int globb, _startupinfo*);
+#ifdef __x86_64__
+static LONG WINAPI catch_sig(EXCEPTION_POINTERS *ex)
+{
+ return _XcptFilter(ex->ExceptionRecord->ExceptionCode, ex);
+}
+#endif
+
static int go_winmain(TCHAR *arg1)
{
STARTUPINFO si;
@@ -54,6 +61,9 @@ static int go_winmain(TCHAR *arg1)
int _twinstart(void)
{
__TRY__
+#ifdef __x86_64__
+ SetUnhandledExceptionFilter(catch_sig);
+#endif
_startupinfo start_info_con = {0};
__set_app_type(__GUI_APP);
__tgetmainargs(&__argc, &__targv, &_tenviron, 0, &start_info_con);
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel