4 * Support for operating system level structured exception handling.
6 * NOTE: This is very preliminary stuff. I am also pretty sure it is
7 * completely Intel specific.
9 * This file is part of the Mingw32 package.
12 * Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
13 * Based on code by Mikey <jeffdb@netzone.com>
15 * THIS SOFTWARE IS NOT COPYRIGHTED
17 * This source code is offered for use in the public domain. You may
18 * use, modify or distribute it freely.
20 * This code is distributed in the hope that it will be useful but
21 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
22 * DISCLAIMED. This includes but is not limited to warranties of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
34 #ifndef __STRICT_ANSI__
39 * NOTE: The constants structs and typedefs below should be defined in the
42 #define EH_NONCONTINUABLE 0x01
43 #define EH_UNWINDING 0x02
44 #define EH_EXIT_UNWIND 0x04
45 #define EH_STACK_INVALID 0x08
46 #define EH_NESTED_CALL 0x10
51 ExceptionContinueExecution,
52 ExceptionContinueSearch,
53 ExceptionNestedException,
54 ExceptionCollidedUnwind
55 } EXCEPTION_DISPOSITION;
59 * End of stuff that should be in the Win32 API files.
68 * The type of function that is expected as an exception handler to be
69 * installed with _try1.
71 typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER)
72 (struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*);
75 * This is not entirely necessary, but it is the structure installed by
76 * the _try1 primitive below.
78 typedef struct _EXCEPTION_REGISTRATION
80 struct _EXCEPTION_REGISTRATION* prev;
81 PEXCEPTION_HANDLER handler;
82 } EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION;
84 typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD;
85 typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD;
88 * A macro which installs the supplied exception handler.
89 * Push the pointer to the new handler onto the stack,
90 * then push the pointer to the old registration structure (at fs:0)
91 * onto the stack, then put a pointer to the new registration
92 * structure (i.e. the current stack pointer) at fs:0.
94 #define __try1(pHandler) \
95 __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler));
99 * A macro which (despite its name) *removes* an installed
100 * exception handler. Should be used only in conjunction with the above
101 * install routine __try1.
102 * Move the pointer to the old reg. struct (at the current stack
103 * position) to fs:0, replacing the pointer we installed above,
104 * then add 8 to the stack pointer to get rid of the space we
105 * used when we pushed on our new reg. struct above. Notice that
106 * the stack must be in the exact state at this point that it was
107 * after we did _try1 or this will smash things.
110 __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \
117 #endif /* Not RC_INVOKED */
119 #endif /* Not strict ANSI */
121 #endif /* _EXCPT_H_ not defined */