[PATCH 1/3] msvcr90: Implement _set_abort_behavior [try2]

Detlef Riekenberg wine.dev at web.de
Mon Jan 10 16:03:03 CST 2011


This let radiotracker go a step forward

try 2 includes the changes for msvcrt.spec

Please ignore 4/2 from my prev. patchset. I have a proper fix,
which uses the value from _set_error_mode

--
By by ... Detlef
---
 dlls/msvcr100/msvcr100.spec |    2 +-
 dlls/msvcr80/msvcr80.spec   |    2 +-
 dlls/msvcr90/msvcr90.spec   |    2 +-
 dlls/msvcrt/exit.c          |   31 +++++++++++++++++++++++++++----
 dlls/msvcrt/msvcrt.spec     |    1 +
 include/msvcrt/stdlib.h     |    3 +++
 6 files changed, 34 insertions(+), 7 deletions(-)

diff --git a/dlls/msvcr100/msvcr100.spec b/dlls/msvcr100/msvcr100.spec
index 0d1ffa1..1e898df 100644
--- a/dlls/msvcr100/msvcr100.spec
+++ b/dlls/msvcr100/msvcr100.spec
@@ -1068,7 +1068,7 @@
 @ stub _seh_longjmp_unwind4
 @ stdcall -i386 _seh_longjmp_unwind(ptr) msvcrt._seh_longjmp_unwind
 @ cdecl _set_SSE2_enable(long) msvcrt._set_SSE2_enable
-@ stub _set_abort_behavior
+@ cdecl _set_abort_behavior(long long) msvcrt._set_abort_behavior
 @ stub _set_controlfp
 @ cdecl _set_doserrno(long) msvcrt._set_doserrno
 @ cdecl _set_errno(long) msvcrt._set_errno
diff --git a/dlls/msvcr80/msvcr80.spec b/dlls/msvcr80/msvcr80.spec
index 63d8f14..d530f78 100644
--- a/dlls/msvcr80/msvcr80.spec
+++ b/dlls/msvcr80/msvcr80.spec
@@ -920,7 +920,7 @@
 @ stub _seh_longjmp_unwind4
 @ stdcall -i386 _seh_longjmp_unwind(ptr) msvcrt._seh_longjmp_unwind
 @ cdecl _set_SSE2_enable(long) msvcrt._set_SSE2_enable
-@ stub _set_abort_behavior
+@ cdecl _set_abort_behavior(long long) msvcrt._set_abort_behavior
 @ stub _set_amblksiz
 @ stub _set_controlfp
 @ cdecl _set_doserrno(long) msvcrt._set_doserrno
diff --git a/dlls/msvcr90/msvcr90.spec b/dlls/msvcr90/msvcr90.spec
index 3e8f0bf..c1d400a 100644
--- a/dlls/msvcr90/msvcr90.spec
+++ b/dlls/msvcr90/msvcr90.spec
@@ -906,7 +906,7 @@
 @ stub _seh_longjmp_unwind4
 @ stdcall -i386 _seh_longjmp_unwind(ptr) msvcrt._seh_longjmp_unwind
 @ cdecl _set_SSE2_enable(long) msvcrt._set_SSE2_enable
-@ stub _set_abort_behavior
+@ cdecl _set_abort_behavior(long long) msvcrt._set_abort_behavior
 @ stub _set_amblksiz
 @ stub _set_controlfp
 @ cdecl _set_doserrno(long) msvcrt._set_doserrno
diff --git a/dlls/msvcrt/exit.c b/dlls/msvcrt/exit.c
index 80749fc..15927e7 100644
--- a/dlls/msvcrt/exit.c
+++ b/dlls/msvcrt/exit.c
@@ -36,6 +36,11 @@ static MSVCRT_purecall_handler purecall_handler = NULL;
 
 static const char szMsgBoxTitle[] = "Wine C++ Runtime Library";
 
+#ifndef _WRITE_ABORT_MSG
+#define _WRITE_ABORT_MSG  1
+#define _CALL_REPORTFAULT 2
+#endif
+static unsigned int abort_behavior = _WRITE_ABORT_MSG | _CALL_REPORTFAULT;
 extern int MSVCRT_app_type;
 extern char *MSVCRT__pgmptr;
 
@@ -150,17 +155,35 @@ void CDECL _amsg_exit(int errnum)
 void CDECL MSVCRT_abort(void)
 {
   TRACE("()\n");
-  if (MSVCRT_app_type == 2)
+  if (abort_behavior & _WRITE_ABORT_MSG)
   {
-    DoMessageBox("Runtime error!", "abnormal program termination");
+    if (MSVCRT_app_type == 2)
+    {
+      DoMessageBox("Runtime error!", "abnormal program termination");
+    }
+    else
+      _cputs("\nabnormal program termination\n");
   }
-  else
-    _cputs("\nabnormal program termination\n");
+
+  if (abort_behavior & _CALL_REPORTFAULT)
+    TRACE("_CALL_REPORTFAULT not supported\n");
+
   MSVCRT_raise(MSVCRT_SIGABRT);
   /* in case raise() returns */
   MSVCRT__exit(3);
 }
 
+/* _set_abort_behavior - not exported in native msvcrt */
+unsigned int CDECL _set_abort_behavior(unsigned int newflag, unsigned int mask)
+{
+    unsigned int old = abort_behavior;
+
+    TRACE("(0x%x, 0x%x)\n", newflag, mask);
+
+    abort_behavior = (old ^ (old & mask)) | (newflag & mask);
+    return old;
+}
+
 /*********************************************************************
  *		_assert (MSVCRT.@)
  */
diff --git a/dlls/msvcrt/msvcrt.spec b/dlls/msvcrt/msvcrt.spec
index efec11f..172fd82 100644
--- a/dlls/msvcrt/msvcrt.spec
+++ b/dlls/msvcrt/msvcrt.spec
@@ -1482,6 +1482,7 @@
 @ cdecl _configthreadlocale(long)
 @ cdecl _wcstod_l(wstr ptr) MSVCRT__wcstod_l
 @ cdecl ___mb_cur_max_l_func(ptr)
+@ cdecl _set_abort_behavior(long long)
 @ cdecl _set_purecall_handler(ptr)
 @ cdecl _dupenv_s(ptr ptr str)
 @ cdecl _wdupenv_s(ptr ptr str)
diff --git a/include/msvcrt/stdlib.h b/include/msvcrt/stdlib.h
index 49783c0..e384eb0 100644
--- a/include/msvcrt/stdlib.h
+++ b/include/msvcrt/stdlib.h
@@ -73,6 +73,8 @@ typedef struct _ldiv_t {
 #define _OUT_TO_MSGBOX       2
 #define _REPORT_ERRMODE      3
 
+#define _WRITE_ABORT_MSG  1
+#define _CALL_REPORTFAULT 2
 
 #ifdef __cplusplus
 extern "C" {
@@ -160,6 +162,7 @@ int           __cdecl _putenv(const char*);
 unsigned int  __cdecl _rotl(unsigned int,int);
 unsigned int  __cdecl _rotr(unsigned int,int);
 void          __cdecl _searchenv(const char*,const char*,char*);
+unsigned int  __cdecl _set_abort_behavior(unsigned int, unsigned int);
 int           __cdecl _set_error_mode(int);
 void          __cdecl _seterrormode(int);
 void          __cdecl _sleep(__msvcrt_ulong);
-- 
1.7.1




More information about the wine-patches mailing list