oops - fixed typo in previous delta
[official-gcc.git] / gcc / eh-common.h
blob20adfd613f03005f578c66d8e6356246a7d5cba1
1 /* EH stuff
2 Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
4 This file is part of GNU CC.
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
9 later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
21 /* This file contains the structures required for the language
22 independant exception handling model. Both the static compiler and
23 the runtime library share this file. */
25 /* The runtime flag flag_new_exceptions is used to determine whether the
26 compiler supports the new runtime typechecking mechanism or not. Under
27 the new model, runtime info is contained in the exception table, and
28 the __throw() library routine determines which handler to call based
29 on the results of a call to a matching function provided by the expcetion
30 thrower. Otherwise the old scheme of calling any handler which matches
31 an exception range is used, and the handler is responsible for all
32 checking of runtime conditions. If the handler wasn't suppose to
33 get the exception, it performs a re-throw. */
36 /* The handler_label field MUST be the first field in this structure. The
37 __throw() library routine expects uses __eh_stub() from except.c, which
38 simply dereferences the context pointer to get the handler.
39 The routine get_dynamic_handler_chain() also has a dependancy on
40 the location of 'dynamic_handler_chain'. If its location is changed,
41 that routine must be modified as well. */
43 struct eh_context
45 void *handler_label;
46 void **dynamic_handler_chain;
47 /* This is language dependent part of the eh context. */
48 void *info;
49 /* This is used to remember where we threw for re-throws */
50 void *table_index; /* address of exception table entry to rethrow from */
53 #ifndef EH_TABLE_LOOKUP
55 typedef struct old_exception_table
57 void *start_region;
58 void *end_region;
59 void *exception_handler;
60 } old_exception_table;
62 typedef struct exception_table
64 void *start_region;
65 void *end_region;
66 void *exception_handler;
67 void *match_info; /* runtime type info */
68 } exception_table;
71 /* The language identifying portion of an exception table */
73 typedef struct exception_lang_info
75 short language;
76 short version;
77 } exception_lang_info;
79 /* This value in the first field of the exception descriptor
80 identifies the descriptor as the new model format. This value would never
81 be present in this location under the old model */
83 #define NEW_EH_RUNTIME ((void *) -2)
85 /* Each function has an exception_descriptor which contains the
86 language info, and a table of exception ranges and handlers */
88 typedef struct exception_descriptor
90 void *runtime_id_field;
91 exception_lang_info lang;
92 exception_table table[1];
93 } exception_descriptor;
95 struct __eh_info; /* forward declaration */
97 /* A pointer to a matching function is initialized at runtime by the
98 specific language if run-time exceptions are supported.
99 The function takes 3 parameters
100 1 - runtime exception that has been thrown info. (__eh_info *)
101 2 - Match info pointer from the region being considered (void *)
102 3 - exception table region is in (exception descriptor *)
105 typedef void * (*__eh_matcher) PARAMS ((struct __eh_info *, void *,
106 struct exception_descriptor *));
108 /* This value is to be checked as a 'match all' case in the runtime field. */
110 #define CATCH_ALL_TYPE ((void *) -1)
112 /* This is the runtime exception information. This forms the minimum required
113 information for an exception info pointer in an eh_context structure. */
116 typedef struct __eh_info
118 __eh_matcher match_function;
119 short language;
120 short version;
121 } __eh_info;
123 /* Convienient language codes for ID the originating language. Similar
124 to the codes in dwarf2.h. */
126 enum exception_source_language
128 EH_LANG_C89 = 0x0001,
129 EH_LANG_C = 0x0002,
130 EH_LANG_Ada83 = 0x0003,
131 EH_LANG_C_plus_plus = 0x0004,
132 EH_LANG_Cobol74 = 0x0005,
133 EH_LANG_Cobol85 = 0x0006,
134 EH_LANG_Fortran77 = 0x0007,
135 EH_LANG_Fortran90 = 0x0008,
136 EH_LANG_Pascal83 = 0x0009,
137 EH_LANG_Modula2 = 0x000a,
138 EH_LANG_Java = 0x000b,
139 EH_LANG_Mips_Assembler = 0x8001
142 #endif /* EH_TABLE_LOOKUP */