diff --git a/dlls/ntdll/unix/signal_arm.c b/dlls/ntdll/unix/signal_arm.c index f024879b81f600b5ca9a8ab90b49bc8e1ef77da0..584c1f2f0bf7ba9cea4da7a88a7de9dc05e11d80 100644 --- a/dlls/ntdll/unix/signal_arm.c +++ b/dlls/ntdll/unix/signal_arm.c @@ -61,7 +61,6 @@ #include "windef.h" #include "winnt.h" #include "winternl.h" -#include "wine/exception.h" #include "wine/asm.h" #include "unix_private.h" #include "wine/debug.h" diff --git a/dlls/ntdll/unix/signal_arm64.c b/dlls/ntdll/unix/signal_arm64.c index 145277b54185d0f4b985ccc3d270ac3197331aa5..df0c7dad1dabfcb85909456cfea0e8a235f397aa 100644 --- a/dlls/ntdll/unix/signal_arm64.c +++ b/dlls/ntdll/unix/signal_arm64.c @@ -64,7 +64,6 @@ #include "windef.h" #include "winnt.h" #include "winternl.h" -#include "wine/exception.h" #include "wine/asm.h" #include "unix_private.h" #include "wine/debug.h" diff --git a/dlls/ntdll/unix/signal_i386.c b/dlls/ntdll/unix/signal_i386.c index e123f2c2a790f07acbae4d77e3547c6341a78d6b..a709c85b4da57af1c508378d1041d351d97a12da 100644 --- a/dlls/ntdll/unix/signal_i386.c +++ b/dlls/ntdll/unix/signal_i386.c @@ -60,7 +60,6 @@ #include "winternl.h" #include "ddk/wdm.h" #include "wine/asm.h" -#include "wine/exception.h" #include "unix_private.h" #include "wine/debug.h" diff --git a/dlls/ntdll/unix/signal_x86_64.c b/dlls/ntdll/unix/signal_x86_64.c index 9b18180301acca5f31ffddda1d95e50867a064e1..ffe7ef7db072a57bfdd90468a57f531766ed56c8 100644 --- a/dlls/ntdll/unix/signal_x86_64.c +++ b/dlls/ntdll/unix/signal_x86_64.c @@ -75,7 +75,6 @@ #include "windef.h" #include "winternl.h" #include "ddk/wdm.h" -#include "wine/exception.h" #include "wine/list.h" #include "wine/asm.h" #include "unix_private.h" diff --git a/dlls/ntdll/unix/thread.c b/dlls/ntdll/unix/thread.c index 839a75b4cac4c3a28965e6b3284f823d86179cf9..384ac1d41196ba1c8f289cb73b729351644f8d19 100644 --- a/dlls/ntdll/unix/thread.c +++ b/dlls/ntdll/unix/thread.c @@ -1737,6 +1737,16 @@ NTSTATUS get_thread_context( HANDLE handle, void *context, BOOL *self, USHORT ma } +/*********************************************************************** + * ntdll_set_exception_jmp_buf + */ +void ntdll_set_exception_jmp_buf( __wine_jmp_buf *jmp ) +{ + assert( !jmp || !ntdll_get_thread_data()->jmp_buf ); + ntdll_get_thread_data()->jmp_buf = jmp; +} + + BOOL get_thread_times(int unix_pid, int unix_tid, LARGE_INTEGER *kernel_time, LARGE_INTEGER *user_time) { #ifdef linux diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 63655f0c928d0187ffa4b9b4c23878310d6a2bf5..924aa78b306017a0f186a57dc312375c2cea626f 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -59,7 +59,6 @@ #include "windef.h" #include "winnt.h" #include "winternl.h" -#include "wine/exception.h" #include "wine/list.h" #include "wine/rbtree.h" #include "unix_private.h" @@ -104,35 +103,6 @@ struct file_view unsigned int protect; /* protection for all pages at allocation time and SEC_* flags */ }; -#undef __TRY -#undef __EXCEPT -#undef __ENDTRY - -#define __TRY \ - do { __wine_jmp_buf __jmp; \ - int __first = 1; \ - assert( !ntdll_get_thread_data()->jmp_buf ); \ - for (;;) if (!__first) \ - { \ - do { - -#define __EXCEPT \ - } while(0); \ - ntdll_get_thread_data()->jmp_buf = NULL; \ - break; \ - } else { \ - if (__wine_setjmpex( &__jmp, NULL )) { \ - do { - -#define __ENDTRY \ - } while (0); \ - break; \ - } \ - ntdll_get_thread_data()->jmp_buf = &__jmp; \ - __first = 0; \ - } \ - } while (0); - /* per-page protection flags */ #define VPROT_READ 0x01 #define VPROT_WRITE 0x02 diff --git a/include/wine/unixlib.h b/include/wine/unixlib.h index 4abc3172192e9cb0d032fe95d463f3b86a4db396..920e3d32dc51f40e4f305f3f49f298e5e27fe14d 100644 --- a/include/wine/unixlib.h +++ b/include/wine/unixlib.h @@ -26,6 +26,8 @@ typedef UINT64 unixlib_handle_t; extern NTSTATUS WINAPI __wine_unix_call( unixlib_handle_t handle, unsigned int code, void *args ); +#ifdef WINE_UNIX_LIB + /* some useful helpers from ntdll */ extern const char *ntdll_get_build_dir(void); extern const char *ntdll_get_data_dir(void); @@ -33,4 +35,49 @@ extern DWORD ntdll_umbstowcs( const char *src, DWORD srclen, WCHAR *dst, DWORD d extern int ntdll_wcstoumbs( const WCHAR *src, DWORD srclen, char *dst, DWORD dstlen, BOOL strict ); extern NTSTATUS ntdll_init_syscalls( ULONG id, SYSTEM_SERVICE_TABLE *table, void **dispatcher ); +/* exception handling */ + +#ifdef __i386__ +typedef struct { int reg[16]; } __wine_jmp_buf; +#elif defined(__x86_64__) +typedef struct { DECLSPEC_ALIGN(16) struct { unsigned __int64 Part[2]; } reg[16]; } __wine_jmp_buf; +#elif defined(__arm__) +typedef struct { int reg[28]; } __wine_jmp_buf; +#elif defined(__aarch64__) +typedef struct { __int64 reg[24]; } __wine_jmp_buf; +#else +typedef struct { int reg; } __wine_jmp_buf; +#endif + +extern int __cdecl __attribute__ ((__nothrow__,__returns_twice__)) __wine_setjmpex( __wine_jmp_buf *buf, + EXCEPTION_REGISTRATION_RECORD *frame ); +extern void DECLSPEC_NORETURN __cdecl __wine_longjmp( __wine_jmp_buf *buf, int retval ); +extern void ntdll_set_exception_jmp_buf( __wine_jmp_buf *jmp ); + +#define __TRY \ + do { __wine_jmp_buf __jmp; \ + int __first = 1; \ + for (;;) if (!__first) \ + { \ + do { + +#define __EXCEPT \ + } while(0); \ + ntdll_set_exception_jmp_buf( NULL ); \ + break; \ + } else { \ + if (__wine_setjmpex( &__jmp, NULL )) { \ + do { + +#define __ENDTRY \ + } while (0); \ + break; \ + } \ + ntdll_set_exception_jmp_buf( &__jmp ); \ + __first = 0; \ + } \ + } while (0); + +#endif /* WINE_UNIX_LIB */ + #endif /* __WINE_WINE_UNIXLIB_H */