]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/uclibc/lib/contrib/uclibc/libpthread/nptl/sysdeps/generic/unwind.h
81fc4db55903a52d2a35a76fb707b2fc0056317e
[l4.git] / l4 / pkg / uclibc / lib / contrib / uclibc / libpthread / nptl / sysdeps / generic / unwind.h
1 /* Exception handling and frame unwind runtime interface routines.
2    Copyright (C) 2001, 2003 Free Software Foundation, Inc.
3
4    This file is part of the GNU C Library.
5
6    The GNU C Library is free software; you can redistribute it and/or
7    modify it under the terms of the GNU Lesser General Public
8    License as published by the Free Software Foundation; either
9    version 2.1 of the License, or (at your option) any later version.
10
11    The GNU C Library 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 GNU
14    Lesser General Public License for more details.
15
16    You should have received a copy of the GNU Lesser General Public
17    License along with the GNU C Library; if not, write to the Free
18    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19    02111-1307 USA.  */
20
21 /* This is derived from the C++ ABI for IA-64.  Where we diverge
22    for cross-architecture compatibility are noted with "@@@".  */
23
24 #ifndef _UNWIND_H
25 #define _UNWIND_H       1
26
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30
31 /* Level 1: Base ABI  */
32
33 /* @@@ The IA-64 ABI uses uint64 throughout.  Most places this is
34    inefficient for 32-bit and smaller machines.  */
35 typedef unsigned _Unwind_Word __attribute__((__mode__(__word__)));
36 typedef signed _Unwind_Sword __attribute__((__mode__(__word__)));
37 #if defined(__ia64__) && defined(__hpux__)
38 typedef unsigned _Unwind_Ptr __attribute__((__mode__(__word__)));
39 #else
40 typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)));
41 #endif
42 typedef unsigned _Unwind_Internal_Ptr __attribute__((__mode__(__pointer__)));
43
44 /* @@@ The IA-64 ABI uses a 64-bit word to identify the producer and
45    consumer of an exception.  We'll go along with this for now even on
46    32-bit machines.  We'll need to provide some other option for
47    16-bit machines and for machines with > 8 bits per byte.  */
48 typedef unsigned _Unwind_Exception_Class __attribute__((__mode__(__DI__)));
49
50 /* The unwind interface uses reason codes in several contexts to
51    identify the reasons for failures or other actions.  */
52 typedef enum
53 {
54   _URC_NO_REASON = 0,
55   _URC_FOREIGN_EXCEPTION_CAUGHT = 1,
56   _URC_FATAL_PHASE2_ERROR = 2,
57   _URC_FATAL_PHASE1_ERROR = 3,
58   _URC_NORMAL_STOP = 4,
59   _URC_END_OF_STACK = 5,
60   _URC_HANDLER_FOUND = 6,
61   _URC_INSTALL_CONTEXT = 7,
62   _URC_CONTINUE_UNWIND = 8
63 } _Unwind_Reason_Code;
64
65
66 /* The unwind interface uses a pointer to an exception header object
67    as its representation of an exception being thrown. In general, the
68    full representation of an exception object is language- and
69    implementation-specific, but it will be prefixed by a header
70    understood by the unwind interface.  */
71
72 struct _Unwind_Exception;
73
74 typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code,
75                                               struct _Unwind_Exception *);
76
77 struct _Unwind_Exception
78 {
79   _Unwind_Exception_Class exception_class;
80   _Unwind_Exception_Cleanup_Fn exception_cleanup;
81   _Unwind_Word private_1;
82   _Unwind_Word private_2;
83
84   /* @@@ The IA-64 ABI says that this structure must be double-word aligned.
85      Taking that literally does not make much sense generically.  Instead we
86      provide the maximum alignment required by any type for the machine.  */
87 } __attribute__((__aligned__));
88
89
90 /* The ACTIONS argument to the personality routine is a bitwise OR of one
91    or more of the following constants.  */
92 typedef int _Unwind_Action;
93
94 #define _UA_SEARCH_PHASE        1
95 #define _UA_CLEANUP_PHASE       2
96 #define _UA_HANDLER_FRAME       4
97 #define _UA_FORCE_UNWIND        8
98 #define _UA_END_OF_STACK        16
99
100 /* This is an opaque type used to refer to a system-specific data
101    structure used by the system unwinder. This context is created and
102    destroyed by the system, and passed to the personality routine
103    during unwinding.  */
104 struct _Unwind_Context;
105
106 /* Raise an exception, passing along the given exception object.  */
107 extern _Unwind_Reason_Code _Unwind_RaiseException (struct _Unwind_Exception *);
108
109 /* Raise an exception for forced unwinding.  */
110
111 typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn)
112      (int, _Unwind_Action, _Unwind_Exception_Class,
113       struct _Unwind_Exception *, struct _Unwind_Context *, void *);
114
115 extern _Unwind_Reason_Code _Unwind_ForcedUnwind (struct _Unwind_Exception *,
116                                                  _Unwind_Stop_Fn,
117                                                  void *);
118
119 /* Helper to invoke the exception_cleanup routine.  */
120 extern void _Unwind_DeleteException (struct _Unwind_Exception *);
121
122 /* Resume propagation of an existing exception.  This is used after
123    e.g. executing cleanup code, and not to implement rethrowing.  */
124 extern void _Unwind_Resume (struct _Unwind_Exception *);
125
126 /* @@@ Use unwind data to perform a stack backtrace.  The trace callback
127    is called for every stack frame in the call chain, but no cleanup
128    actions are performed.  */
129 typedef _Unwind_Reason_Code (*_Unwind_Trace_Fn)
130      (struct _Unwind_Context *, void *);
131
132 extern _Unwind_Reason_Code _Unwind_Backtrace (_Unwind_Trace_Fn, void *);
133
134 /* These functions are used for communicating information about the unwind
135    context (i.e. the unwind descriptors and the user register state) between
136    the unwind library and the personality routine and landing pad.  Only
137    selected registers maybe manipulated.  */
138
139 extern _Unwind_Word _Unwind_GetGR (struct _Unwind_Context *, int);
140 extern void _Unwind_SetGR (struct _Unwind_Context *, int, _Unwind_Word);
141
142 extern _Unwind_Ptr _Unwind_GetIP (struct _Unwind_Context *);
143 extern void _Unwind_SetIP (struct _Unwind_Context *, _Unwind_Ptr);
144
145 /* @@@ Retrieve the CFA of the given context.  */
146 extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *);
147
148 extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *);
149
150 extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *);
151
152
153 /* The personality routine is the function in the C++ (or other language)
154    runtime library which serves as an interface between the system unwind
155    library and language-specific exception handling semantics.  It is
156    specific to the code fragment described by an unwind info block, and
157    it is always referenced via the pointer in the unwind info block, and
158    hence it has no ABI-specified name.
159
160    Note that this implies that two different C++ implementations can
161    use different names, and have different contents in the language
162    specific data area.  Moreover, that the language specific data
163    area contains no version info because name of the function invoked
164    provides more effective versioning by detecting at link time the
165    lack of code to handle the different data format.  */
166
167 typedef _Unwind_Reason_Code (*_Unwind_Personality_Fn)
168      (int, _Unwind_Action, _Unwind_Exception_Class,
169       struct _Unwind_Exception *, struct _Unwind_Context *);
170
171 /* @@@ The following alternate entry points are for setjmp/longjmp
172    based unwinding.  */
173
174 struct SjLj_Function_Context;
175 extern void _Unwind_SjLj_Register (struct SjLj_Function_Context *);
176 extern void _Unwind_SjLj_Unregister (struct SjLj_Function_Context *);
177
178 extern _Unwind_Reason_Code _Unwind_SjLj_RaiseException
179      (struct _Unwind_Exception *);
180 extern _Unwind_Reason_Code _Unwind_SjLj_ForcedUnwind
181      (struct _Unwind_Exception *, _Unwind_Stop_Fn, void *);
182 extern void _Unwind_SjLj_Resume (struct _Unwind_Exception *);
183
184 /* @@@ The following provide access to the base addresses for text
185    and data-relative addressing in the LDSA.  In order to stay link
186    compatible with the standard ABI for IA-64, we inline these.  */
187
188 #ifdef __ia64__
189 #include <stdlib.h>
190
191 static inline _Unwind_Ptr
192 _Unwind_GetDataRelBase (struct _Unwind_Context *_C)
193 {
194   /* The GP is stored in R1.  */
195   return _Unwind_GetGR (_C, 1);
196 }
197
198 static inline _Unwind_Ptr
199 _Unwind_GetTextRelBase (struct _Unwind_Context *_C)
200 {
201   abort ();
202   return 0;
203 }
204
205 /* @@@ Retrieve the Backing Store Pointer of the given context.  */
206 extern _Unwind_Word _Unwind_GetBSP (struct _Unwind_Context *);
207 #else
208 extern _Unwind_Ptr _Unwind_GetDataRelBase (struct _Unwind_Context *);
209 extern _Unwind_Ptr _Unwind_GetTextRelBase (struct _Unwind_Context *);
210 #endif
211
212 /* @@@ Given an address, return the entry point of the function that
213    contains it.  */
214 extern void * _Unwind_FindEnclosingFunction (void *pc);
215
216 #ifdef __cplusplus
217 }
218 #endif
219
220 #endif  /* unwind.h */