exception.h: Make the RtlUnwind wrapper available separately.

Also avoid dependency on winternl.h.
This commit is contained in:
Alexandre Julliard 2008-07-03 12:57:43 +02:00
parent 1894d708a4
commit 94e217891c
3 changed files with 30 additions and 25 deletions

View File

@ -34,6 +34,7 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winerror.h" #include "winerror.h"
#include "winternl.h"
#include "wine/winbase16.h" #include "wine/winbase16.h"
#include "wine/exception.h" #include "wine/exception.h"
#include "wine/library.h" #include "wine/library.h"

View File

@ -35,8 +35,8 @@
#include "ntstatus.h" #include "ntstatus.h"
#define WIN32_NO_STATUS #define WIN32_NO_STATUS
#include "windef.h" #include "windef.h"
#include "wine/exception.h"
#include "ntdll_misc.h" #include "ntdll_misc.h"
#include "wine/exception.h"
#include "wine/library.h" #include "wine/library.h"
#include "wine/unicode.h" #include "wine/unicode.h"
#include "wine/debug.h" #include "wine/debug.h"

View File

@ -23,7 +23,6 @@
#include <setjmp.h> #include <setjmp.h>
#include <windef.h> #include <windef.h>
#include <winternl.h>
#include <excpt.h> #include <excpt.h>
/* The following definitions allow using exceptions in Wine and Winelib code /* The following definitions allow using exceptions in Wine and Winelib code
@ -187,8 +186,8 @@ static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGIST
return prev; return prev;
#else #else
NT_TIB *teb = (NT_TIB *)NtCurrentTeb(); NT_TIB *teb = (NT_TIB *)NtCurrentTeb();
frame->Prev = (void *)teb->ExceptionList; frame->Prev = teb->ExceptionList;
teb->ExceptionList = (void *)frame; teb->ExceptionList = frame;
return frame->Prev; return frame->Prev;
#endif #endif
} }
@ -202,7 +201,7 @@ static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTR
#else #else
NT_TIB *teb = (NT_TIB *)NtCurrentTeb(); NT_TIB *teb = (NT_TIB *)NtCurrentTeb();
teb->ExceptionList = (void *)frame->Prev; teb->ExceptionList = frame->Prev;
return frame->Prev; return frame->Prev;
#endif #endif
} }
@ -230,18 +229,12 @@ extern void __wine_enter_vm86( CONTEXT *context );
#ifndef USE_COMPILER_EXCEPTIONS #ifndef USE_COMPILER_EXCEPTIONS
static inline void DECLSPEC_NORETURN __wine_unwind_frame( EXCEPTION_RECORD *record, extern void WINAPI RtlUnwind(PVOID,PVOID,PEXCEPTION_RECORD,PVOID);
EXCEPTION_REGISTRATION_RECORD *frame )
/* wrapper for RtlUnwind since it clobbers registers on Windows */
static inline void __wine_rtl_unwind( EXCEPTION_REGISTRATION_RECORD* frame, EXCEPTION_RECORD *record )
{ {
__WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
/* hack to make GetExceptionCode() work in handler */
wine_frame->ExceptionCode = record->ExceptionCode;
wine_frame->ExceptionRecord = wine_frame;
#if defined(__GNUC__) && defined(__i386__) #if defined(__GNUC__) && defined(__i386__)
{
/* RtlUnwind clobbers registers on Windows */
int dummy1, dummy2, dummy3; int dummy1, dummy2, dummy3;
__asm__ __volatile__("pushl %%ebp\n\t" __asm__ __volatile__("pushl %%ebp\n\t"
"pushl %%ebx\n\t" "pushl %%ebx\n\t"
@ -255,10 +248,21 @@ static inline void DECLSPEC_NORETURN __wine_unwind_frame( EXCEPTION_RECORD *reco
: "=a" (dummy1), "=S" (dummy2), "=D" (dummy3) : "=a" (dummy1), "=S" (dummy2), "=D" (dummy3)
: "0" (RtlUnwind), "1" (frame), "2" (record) : "0" (RtlUnwind), "1" (frame), "2" (record)
: "ecx", "edx", "memory" ); : "ecx", "edx", "memory" );
}
#else #else
RtlUnwind( frame, 0, record, 0 ); RtlUnwind( frame, 0, record, 0 );
#endif #endif
}
static inline void DECLSPEC_NORETURN __wine_unwind_frame( EXCEPTION_RECORD *record,
EXCEPTION_REGISTRATION_RECORD *frame )
{
__WINE_FRAME *wine_frame = (__WINE_FRAME *)frame;
/* hack to make GetExceptionCode() work in handler */
wine_frame->ExceptionCode = record->ExceptionCode;
wine_frame->ExceptionRecord = wine_frame;
__wine_rtl_unwind( frame, record );
__wine_pop_frame( frame ); __wine_pop_frame( frame );
siglongjmp( wine_frame->jmp, 1 ); siglongjmp( wine_frame->jmp, 1 );
} }