Update contrib.
3 * Copyright 2003 ARM Limited.
8 1. Subject to the provisions of clause 2, ARM hereby grants to LICENSEE a
9 perpetual, non-exclusive, nontransferable, royalty free, worldwide licence
10 to use this Example Implementation of Exception Handling solely for the
11 purpose of developing, having developed, manufacturing, having
12 manufactured, offering to sell, selling, supplying or otherwise
13 distributing products which comply with the Exception Handling ABI for the
14 ARM Architecture specification. All other rights are reserved to ARM or its
17 2. THIS EXAMPLE IMPLEMENTATION OF EXCEPTION HANDLING IS PROVIDED "AS IS"
18 WITH NO WARRANTIES EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT LIMITED
19 TO ANY WARRANTY OF SATISFACTORY QUALITY, MERCHANTABILITY, NONINFRINGEMENT
20 OR FITNESS FOR A PARTICULAR PURPOSE.
23 * RCS $Revision: 1.3 $
24 * Checkin $Date: 2003/10/23 13:57:32 $
25 * Revising $Author: agrant $
28 /* Environment definition - abstractions and requirements - to aid
29 * portability of the ARM exceptions code.
35 /* ---------------------------------------------------------------------- */
39 * The compiler is expected to define preprocessor symbols as follows:
40 * __cplusplus when compiling in C++ mode.
41 * __thumb when compiling to Thumb code.
43 * Some use is made of embedded assembly language, introduced by __asm.
44 * This is described in ARM's toolchain documentation. Some edits may be
45 * required for other compilers. The compiler should define one or more of:
46 * __TARGET_ARCH_4T __TARGET_ARCH_4TXM __TARGET_ARCH_5T __TARGET_ARCH_5TXM
47 * __TARGET_ARCH_5TE __TARGET_ARCH_6
48 * so the correct assembly wrappers are generated for certain functions.
50 * __APCS_INTERWORK should be defined if ARM/Thumb interworking is required.
52 * For all the above symbols, if your compiler does not provide appropriate
53 * definitions, add them here.
55 * Some source language extensions are also used.
58 /* ---------------------------------------------------------------------- */
62 * ARM's private make system contains an automated facility for compiling
63 * source files multiple times to create multiple object files. The source
64 * regions intended to constitute object file xxx.o are delimited by
65 * #ifdef xxx_c / #endif directives. The exact preprocessor symbols used
66 * for this conditionalisation are described in a comment at the start of
67 * each file. When porting to a different system, compilations must be
68 * performed with these preprocessor symbols appropriately defined
69 * (or remove the conditionalisation).
71 * ARM declares (or redeclares) some routines as weak in order that
72 * references to them are weak, so that the static linker will not load
73 * unwanted code. This is achieved by decorating routine declarations
74 * with appropriate language extensions. Note that compilers supporting
75 * similar features but via a different syntax may require edits to
78 * Define those decorations here (define as empty if not required):
81 #define WEAKDECL __weak /* token in C and C++ */
82 #define WEAKASMDECL [WEAK] /* token in assembler */
84 /* ---------------------------------------------------------------------- */
86 /* Source language support and language extensions */
88 /* It is possible to compile the C++ semantics code using a compiler
89 * which does not support C++ exceptions; this was useful to ARM whilst
90 * ARM's compiler was being developed, and the facility has not been
91 * removed. C++ exceptions syntax is conditionalised by
92 * #ifdef ARM_EXCEPTIONS_ENABLED / #endif. Define ARM_EXCEPTIONS_ENABLED
93 * by some means here if you want a usable library:
98 /* For conditionalisation, specifically on ARM_EXCEPTIONS_ENABLED */
103 /* The following definitions of syntax decoration may be empty if the
104 * facility is not required. Note that compilers supporting similar
105 * features but via a different syntax may require edits to the library
108 * Define the decorations here (define as empty if not required):
111 /* If the compiler understands noreturn functions: */
112 #define NORETURNDECL __declspec(noreturn)
114 /* ---------------------------------------------------------------------- */
118 /* The implementation requires types uint8_t, uint16_t, uint32_t and
119 * uint64_t to be defined as unsigned integers of the appropriate number
127 /* The C++ semantics support requires definition of the RTTI object
128 * layout. We use the same structures and names as the generic C++
131 * Define those structures here:
140 /* ---------------------------------------------------------------------- */
142 /* External requirements */
144 /* The C++ exception-handling 'globals' should be allocated per-thread.
145 * The Exceptions ABI does not specify how this happens, but it is
146 * intended that the details are localised to __cxa_get_globals.
148 * In the ARM implementation of __cxa_get_globals, it is assumed that a
149 * zero-initialised location in a known per-thread place is somehow
150 * obtainable, and can be assigned (by __cxa_get_globals) a pointer to
151 * the allocated globals data structure. The macro EH_GLOBALS should be
152 * defined here to yield a suitable address of type void*. This is used
153 * only in __cxa_get_globals.
160 /* for __user_libspace() machinery */
162 #define EH_GLOBALS libspace.eh_globals
167 /* A routine is required for C++ derived class to base class conversion.
168 * This is used once, in __cxa_type_match. It is likely that suitable
169 * code exists as part of the RTTI support code. Therefore access it
171 * DERIVED_TO_BASE_CONVERSION(PTR, P_NEW_PTR, CLASS_INFO, BASE_INFO)
172 * Convert PTR from a pointer to a derived class (described by
173 * CLASS_INFO) to a pointer to a base class (described by BASE_INFO)
174 * and store the resulting pointer in P_NEW_PTR. Return true (or
175 * non-zero) if the base class was found and the conversion was done,
176 * otherwise return false (or zero).
178 * Define the macro here:
182 /* In the ARM implementation, a suitable routine exists elsewhere in the
183 * C++ runtime library, where it is part of the dynamic_cast mechanism.
185 extern "C" int __derived_to_base_conversion(void** p_ptr, void** p_new_ptr,
186 const std::type_info * class_info,
187 const std::type_info * base_info,
188 char** access_flags, int use_access_flags);
190 #define DERIVED_TO_BASE_CONVERSION(PTR, P_NEW_PTR, CLASS_INFO, BASE_INFO) \
191 __derived_to_base_conversion(&(PTR), (P_NEW_PTR), (CLASS_INFO), (BASE_INFO), NULL, 0)
195 /* ---------------------------------------------------------------------- */
197 /* Runtime debug support
199 * Here we define the interface to a "bottleneck function" to be called
200 * by exception handling code at 'interesting' points during execution,
201 * and breakpointable by a debugger.
203 * This is not part of the Exceptions ABI but is expected to be
204 * standardised elsewhere, probably in a Debug ABI.
206 * If you don't want this, define DEBUGGER_BOTTLENECK as a dummy, e.g.
207 * #define DEBUGGER_BOTTLENECK(UCBP,LANG,ACTIVITY,ARG) (void)0
214 struct _Unwind_Control_Block;
217 _UASUBSYS_CPP = 0x00,
218 _UASUBSYS_UNWINDER = 0xff
219 } _Unwind_Activity_subsystem;
222 _UAACT_STARTING = 0x0,
224 _UAACT_BARRIERFOUND = 0x2,
225 _UAACT_PADENTRY = 0x3,
226 _UAACT_CPP_TYPEINFO = 0x80
227 } _Unwind_Activity_activity;
230 _UAARG_ENDING_UNSPECIFIED = 0x0,
231 _UAARG_ENDING_TABLECORRUPT = 0x1,
232 _UAARG_ENDING_NOUNWIND = 0x2,
233 _UAARG_ENDING_VRSFAILED = 0x3,
235 _UAARG_ENDING_CPP_BADOPCODE = 0x4,
237 _UAARG_ENDING_UNWINDER_LOOKUPFAILED = 0x4,
238 _UAARG_ENDING_UNWINDER_BUFFERFAILED = 0x5
239 } _Unwind_Activity_arg;
241 void _Unwind_Activity(struct _Unwind_Control_Block *ucbp, uint32_t reason, uint32_t arg);
242 #define DEBUGGER_BOTTLENECK(UCBP,LANG,ACTIVITY,ARG) \
243 _Unwind_Activity((UCBP),(((LANG)<<24)|ACTIVITY),(uint32_t)(ARG))
250 /* ---------------------------------------------------------------------- */
252 /* Printed diagnostics
254 * These may be useful for debugging purposes during development, provided
255 * the execution environment supports diagnostics via printf.
257 * #define PR_DIAGNOSTICS for printed diagnostics from the personality routine.
258 * #define VRS_DIAGNOSTICS for printed diagnostics about VRS operations.
259 * #define UNWIND_ACTIVITY_DIAGNOSTICS for printed information from _Unwind_Activity.
262 /* ---------------------------------------------------------------------- */
264 #endif /* defined UNWINDENV_H */