Daily bump.
[official-gcc.git] / gcc / eh-common.h
blobc0ff7e73b1a4b235ad770bb3f0c63fa6d5746487
1 /* EH stuff
2 Copyright (C) 1997, 1998 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;
96 /* A pointer to a matching function is initialized at runtime by the
97 specific language if run-time exceptions are supported.
98 The function takes 3 parameters
99 1 - runtime exception that has been thrown info. (__eh_info *)
100 2 - Match info pointer from the region being considered (void *)
101 3 - exception table region is in (exception descriptor *)
104 typedef void * (*__eh_matcher) PROTO ((void *, void *, void *));
106 /* This value is to be checked as a 'match all' case in the runtime field. */
108 #define CATCH_ALL_TYPE ((void *) -1)
110 /* This is the runtime exception information. This forms the minimum required
111 information for an exception info pointer in an eh_context structure. */
114 typedef struct __eh_info
116 __eh_matcher match_function;
117 short language;
118 short version;
119 } __eh_info;
121 /* Convienient language codes for ID the originating language. Similar
122 to the codes in dwarf2.h. */
124 enum exception_source_language
126 EH_LANG_C89 = 0x0001,
127 EH_LANG_C = 0x0002,
128 EH_LANG_Ada83 = 0x0003,
129 EH_LANG_C_plus_plus = 0x0004,
130 EH_LANG_Cobol74 = 0x0005,
131 EH_LANG_Cobol85 = 0x0006,
132 EH_LANG_Fortran77 = 0x0007,
133 EH_LANG_Fortran90 = 0x0008,
134 EH_LANG_Pascal83 = 0x0009,
135 EH_LANG_Modula2 = 0x000a,
136 EH_LANG_Java = 0x000b,
137 EH_LANG_Mips_Assembler = 0x8001
140 #endif /* EH_TABLE_LOOKUP */