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 "winbase.h"
#include "winerror.h"
#include "winternl.h"
#include "wine/winbase16.h"
#include "wine/exception.h"
#include "wine/library.h"

View File

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

View File

@ -23,7 +23,6 @@
#include <setjmp.h>
#include <windef.h>
#include <winternl.h>
#include <excpt.h>
/* 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;
#else
NT_TIB *teb = (NT_TIB *)NtCurrentTeb();
frame->Prev = (void *)teb->ExceptionList;
teb->ExceptionList = (void *)frame;
frame->Prev = teb->ExceptionList;
teb->ExceptionList = frame;
return frame->Prev;
#endif
}
@ -202,7 +201,7 @@ static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTR
#else
NT_TIB *teb = (NT_TIB *)NtCurrentTeb();
teb->ExceptionList = (void *)frame->Prev;
teb->ExceptionList = frame->Prev;
return frame->Prev;
#endif
}
@ -230,6 +229,30 @@ extern void __wine_enter_vm86( CONTEXT *context );
#ifndef USE_COMPILER_EXCEPTIONS
extern void WINAPI RtlUnwind(PVOID,PVOID,PEXCEPTION_RECORD,PVOID);
/* wrapper for RtlUnwind since it clobbers registers on Windows */
static inline void __wine_rtl_unwind( EXCEPTION_REGISTRATION_RECORD* frame, EXCEPTION_RECORD *record )
{
#if defined(__GNUC__) && defined(__i386__)
int dummy1, dummy2, dummy3;
__asm__ __volatile__("pushl %%ebp\n\t"
"pushl %%ebx\n\t"
"pushl $0\n\t"
"pushl %2\n\t"
"pushl $0\n\t"
"pushl %1\n\t"
"call *%0\n\t"
"popl %%ebx\n\t"
"popl %%ebp"
: "=a" (dummy1), "=S" (dummy2), "=D" (dummy3)
: "0" (RtlUnwind), "1" (frame), "2" (record)
: "ecx", "edx", "memory" );
#else
RtlUnwind( frame, 0, record, 0 );
#endif
}
static inline void DECLSPEC_NORETURN __wine_unwind_frame( EXCEPTION_RECORD *record,
EXCEPTION_REGISTRATION_RECORD *frame )
{
@ -239,26 +262,7 @@ static inline void DECLSPEC_NORETURN __wine_unwind_frame( EXCEPTION_RECORD *reco
wine_frame->ExceptionCode = record->ExceptionCode;
wine_frame->ExceptionRecord = wine_frame;
#if defined(__GNUC__) && defined(__i386__)
{
/* RtlUnwind clobbers registers on Windows */
int dummy1, dummy2, dummy3;
__asm__ __volatile__("pushl %%ebp\n\t"
"pushl %%ebx\n\t"
"pushl $0\n\t"
"pushl %2\n\t"
"pushl $0\n\t"
"pushl %1\n\t"
"call *%0\n\t"
"popl %%ebx\n\t"
"popl %%ebp"
: "=a" (dummy1), "=S" (dummy2), "=D" (dummy3)
: "0" (RtlUnwind), "1" (frame), "2" (record)
: "ecx", "edx", "memory" );
}
#else
RtlUnwind( frame, 0, record, 0 );
#endif
__wine_rtl_unwind( frame, record );
__wine_pop_frame( frame );
siglongjmp( wine_frame->jmp, 1 );
}