/*
* Wine exception handling
*
* Copyright (c) 1999 Alexandre Julliard
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
* Oracle LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Oracle elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#ifndef __WINE_WINE_EXCEPTION_H
#define __WINE_WINE_EXCEPTION_H
#include <setjmp.h>
#include <windef.h>
#include <excpt.h>
#ifdef __cplusplus
extern "C" {
#endif
/* The following definitions allow using exceptions in Wine and Winelib code
*
* They should be used like this:
*
* __TRY
* {
* do some stuff that can raise an exception
* }
* __EXCEPT(filter_func)
* {
* handle the exception here
* }
* __ENDTRY
*
* or
*
* __TRY
* {
* do some stuff that can raise an exception
* }
* __FINALLY(finally_func)
*
* The filter_func and finally_func functions must be defined like this:
*
* LONG CALLBACK filter_func( PEXCEPTION_POINTERS __eptr ) { ... }
*
* void CALLBACK finally_func( BOOL __normal ) { ... }
*
* The filter function must return one of the EXCEPTION_* code; it can
* use GetExceptionInformation() and GetExceptionCode() to retrieve the
* exception info.
*
* Warning: inside a __TRY or __EXCEPT block, 'break' or 'continue' statements
* break out of the current block. You cannot use 'return', 'goto'
* or 'longjmp' to leave a __TRY block, as this will surely crash.
* You can use them to leave a __EXCEPT block though.
*
* -- AJ
*/
/* Define this if you want to use your compiler built-in __try/__except support.
* This is only useful when compiling to a native Windows binary, as the built-in
* compiler exceptions will most certainly not work under Winelib.
*/
#ifdef USE_COMPILER_EXCEPTIONS
#else /* USE_COMPILER_EXCEPTIONS */
#ifndef __GNUC__
#endif
#if defined(__MINGW32__) || defined(__CYGWIN__)
#endif
#define __TRY \
do { __WINE_FRAME __f; \
int __first = 1; \
for (;;) if (!__first) \
{ \
do {
} while(0); \
break; \
} else { \
do {
/* convenience handler for page fault exceptions */
#define __EXCEPT_PAGE_FAULT \
} while(0); \
break; \
} else { \
do {
/* convenience handler for all exception */
#define __EXCEPT_ALL \
} while(0); \
break; \
} else { \
do {
#define __ENDTRY \
} while (0); \
break; \
} \
__first = 0; \
} \
} while (0);
} while(0); \
(func)(1); \
break; \
} else { \
__first = 0; \
} \
} while (0);
typedef struct __tagWINE_FRAME
{
union
{
/* exception data */
/* finally data */
} u;
/* hack to make GetExceptionCode() work in handler */
} __WINE_FRAME;
#endif /* USE_COMPILER_EXCEPTIONS */
static inline EXCEPTION_REGISTRATION_RECORD *__wine_push_frame( EXCEPTION_REGISTRATION_RECORD *frame )
{
"\n\tmovl %0,(%1)"
"\n\t.byte 0x64\n\tmovl %1,(0)"
return prev;
#else
#endif
}
static inline EXCEPTION_REGISTRATION_RECORD *__wine_pop_frame( EXCEPTION_REGISTRATION_RECORD *frame )
{
#else
#endif
}
{
return ret;
#else
return teb->ExceptionList;
#endif
}
/* Exception handling flags - from OS/2 2.0 exception handling */
/* Win32 seems to use the same flags as ExceptionFlags in an EXCEPTION_RECORD */
/* Wine-specific exceptions codes */
/* unhandled return status from vm86 mode */
#ifdef __cplusplus
}
#endif
#endif /* __WINE_WINE_EXCEPTION_H */