2000-02-18 03:38:33 +08:00
|
|
|
/*
|
|
|
|
* excpt.h
|
2004-04-21 06:49:32 +08:00
|
|
|
* This file has no copyright assigned and is placed in the Public Domain.
|
|
|
|
* This file is a part of the mingw-runtime package.
|
|
|
|
* No warranty is given; refer to the file DISCLAIMER within the package.
|
2000-02-18 03:38:33 +08:00
|
|
|
*
|
|
|
|
* Support for operating system level structured exception handling.
|
|
|
|
*
|
|
|
|
* NOTE: This is very preliminary stuff. I am also pretty sure it is
|
|
|
|
* completely Intel specific.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _EXCPT_H_
|
|
|
|
#define _EXCPT_H_
|
|
|
|
|
|
|
|
/* All the headers include this file. */
|
|
|
|
#include <_mingw.h>
|
|
|
|
|
2002-06-18 Casper S. Hornstrup <chorns@users.sourceforge.net>
* include/_mingw.h (__MINGW_IMPORT): Check for prior definition before
defining.
* include/excpt.h (): Include windef.h not windows.h.
* include/fcntl.h (_O_SHORT_LIVED): Add define.
(_chmod): Add prototype.
(_creat): Correct prototype.
(SH_DENY*): Rename defines to _SH_DENY*.
(SH_DENY*): Add Non-ANSI names for _SH_DENY*.
include/stdio.h (_IOMYBUF, _IOEOF, _IOERR, _IOSTRG,
_IOAPPEND): Add defines.
(_wfindfirst): Correct prototype.
(_wfdopen): Add prototype.
* include/stdlib.h (_rotl, _rotr, _lrotl, _lrotr): Add
prototypes.
* include/string.h (_mbschr, _mbstok, _mbsncat): Remove
prototypes.
(_wcsdup): Correct prototype.
* include/mbstring.h: Remove comments about _mbschr, _mbstok,
_mbsncat being in string.h.
* include/wchar.h (_wfindfirst): Correct prototype.
* include/tchar.h (_tfdopen): Add _UNICODE mappings.
2002-06-18 12:13:18 +08:00
|
|
|
#include <windef.h>
|
2000-02-18 03:38:33 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: The constants structs and typedefs below should be defined in the
|
|
|
|
* Win32 API headers.
|
|
|
|
*/
|
|
|
|
#define EH_NONCONTINUABLE 0x01
|
|
|
|
#define EH_UNWINDING 0x02
|
|
|
|
#define EH_EXIT_UNWIND 0x04
|
|
|
|
#define EH_STACK_INVALID 0x08
|
|
|
|
#define EH_NESTED_CALL 0x10
|
|
|
|
|
|
|
|
#ifndef RC_INVOKED
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ExceptionContinueExecution,
|
|
|
|
ExceptionContinueSearch,
|
|
|
|
ExceptionNestedException,
|
|
|
|
ExceptionCollidedUnwind
|
|
|
|
} EXCEPTION_DISPOSITION;
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* End of stuff that should be in the Win32 API files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The type of function that is expected as an exception handler to be
|
|
|
|
* installed with _try1.
|
|
|
|
*/
|
|
|
|
typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)
|
|
|
|
(struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This is not entirely necessary, but it is the structure installed by
|
|
|
|
* the _try1 primitive below.
|
|
|
|
*/
|
|
|
|
typedef struct _EXCEPTION_REGISTRATION
|
|
|
|
{
|
|
|
|
struct _EXCEPTION_REGISTRATION* prev;
|
|
|
|
PEXCEPTION_HANDLER handler;
|
|
|
|
} EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION;
|
|
|
|
|
|
|
|
typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD;
|
|
|
|
typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* A macro which installs the supplied exception handler.
|
|
|
|
* Push the pointer to the new handler onto the stack,
|
|
|
|
* then push the pointer to the old registration structure (at fs:0)
|
|
|
|
* onto the stack, then put a pointer to the new registration
|
|
|
|
* structure (i.e. the current stack pointer) at fs:0.
|
|
|
|
*/
|
|
|
|
#define __try1(pHandler) \
|
|
|
|
__asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler));
|
|
|
|
|
|
|
|
/*
|
2001-12-05 23:01:06 +08:00
|
|
|
* A macro which (despite its name) *removes* an installed
|
2000-02-18 03:38:33 +08:00
|
|
|
* exception handler. Should be used only in conjunction with the above
|
|
|
|
* install routine __try1.
|
|
|
|
* Move the pointer to the old reg. struct (at the current stack
|
|
|
|
* position) to fs:0, replacing the pointer we installed above,
|
|
|
|
* then add 8 to the stack pointer to get rid of the space we
|
|
|
|
* used when we pushed on our new reg. struct above. Notice that
|
|
|
|
* the stack must be in the exact state at this point that it was
|
|
|
|
* after we did _try1 or this will smash things.
|
|
|
|
*/
|
|
|
|
#define __except1 \
|
|
|
|
__asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \
|
|
|
|
: : : "%eax");
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* Not RC_INVOKED */
|
|
|
|
|
|
|
|
#endif /* _EXCPT_H_ not defined */
|