OSDN Git Service

[pf3gnuchains/gcc-fork.git] / gcc / eh-common.h
1 /* Copyright (C) 1997 Free Software Foundation, Inc.
2    This file is part of GNU CC.  */
3
4 /* This file contains the structures required for the language
5    independant exception handling model. Both the static compiler and
6    the runtime library share this file. */
7
8 /* The runtime flag flag_new_exceptions is used to determine whether the 
9    compiler supports the new runtime typechecking mechanism or not. Under
10    the new model, runtime info is contained in the exception table, and
11    the __throw() library routine determines which handler to call based
12    on the results of a call to a matching function provided by the expcetion
13    thrower.  Otherwise the old scheme of calling any handler which matches
14    an exception range is used, and the handler is responsible for all
15    checking of runtime conditions. If the handler wasn't suppose to
16    get the exception, it performs a re-throw. */
17
18
19 /* The handler_label field MUST be the first field in this structure. The 
20    __throw()  library routine expects uses __eh_stub() from except.c, which
21    simply dereferences the context pointer to get the handler.
22    The routine get_dynamic_handler_chain() also has a dependancy on
23    the location of 'dynamic_handler_chain'. If its location is changed, 
24    that routine must be modified as well. */
25
26 struct eh_context
27 {
28   void *handler_label;
29   void **dynamic_handler_chain;
30   /* This is language dependent part of the eh context. */
31   void *info;
32 };
33
34 #ifndef EH_TABLE_LOOKUP
35
36 typedef struct old_exception_table 
37 {
38   void *start_region;
39   void *end_region;
40   void *exception_handler;
41 } old_exception_table;
42
43 typedef struct exception_table 
44 {
45   void *start_region;
46   void *end_region;
47   void *exception_handler;
48   void *match_info;              /* runtime type info */
49 } exception_table;
50
51
52 /* The language identifying portion of an exception table */
53
54 typedef struct exception_lang_info 
55 {
56   short language;
57   short version;  
58 } exception_lang_info;
59
60 /* This value in the first field of the exception descriptor 
61    identifies the descriptor as the new model format. This value would never
62    be present in this location under the old model */
63
64 #define NEW_EH_RUNTIME  ((void *) -2)
65
66 /* Each function has an exception_descriptor which contains the
67    language info, and a table of exception ranges and handlers */
68
69 typedef struct exception_descriptor 
70 {
71   void *runtime_id_field;    
72   exception_lang_info lang;
73   exception_table table[1];
74 } exception_descriptor;
75
76
77 /* A pointer to a matching function is initialized at runtime by the 
78    specific language if run-time exceptions are supported. 
79    The function takes 3 parameters
80     1 - runtime exception that has been thrown info. (__eh_info *)
81     2 - Match info pointer from the region being considered (void *)
82     3 - exception table region is in (exception descriptor *)
83 */
84
85 typedef void * (*__eh_matcher)          PROTO ((void *, void *, void *));
86
87 /* This value is to be checked as a 'match all' case in the runtime field. */
88
89 #define CATCH_ALL_TYPE   ((void *) -1)
90
91 /* This is the runtime exception information. This forms the minimum required
92    information for an exception info pointer in an eh_context structure. */
93
94
95 typedef struct __eh_info 
96 {
97   __eh_matcher match_function;
98   short language;
99   short version;
100 } __eh_info;
101
102 /* Convienient language codes for ID the originating language. Similar
103    to the codes in dwarf2.h. */
104
105 enum exception_source_language
106   {
107     EH_LANG_C89 = 0x0001,
108     EH_LANG_C = 0x0002,
109     EH_LANG_Ada83 = 0x0003,
110     EH_LANG_C_plus_plus = 0x0004,
111     EH_LANG_Cobol74 = 0x0005,
112     EH_LANG_Cobol85 = 0x0006,
113     EH_LANG_Fortran77 = 0x0007,
114     EH_LANG_Fortran90 = 0x0008,
115     EH_LANG_Pascal83 = 0x0009,
116     EH_LANG_Modula2 = 0x000a,
117     EH_LANG_Java = 0x000b,
118     EH_LANG_Mips_Assembler = 0x8001
119   };
120
121 #endif  /* EH_TABLE_LOOKUP */
122
123