blob: 8f795f0d1004eaebb62265dd2258bbb936a7be91 [file] [log] [blame]
Howard Hinnantb487f892011-12-06 18:01:47 +00001//===------------------------- cxa_exception.hpp --------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//
9// This file implements the "Exception Handling APIs"
10// http://www.codesourcery.com/public/cxx-abi/abi-eh.html
11//
12//===----------------------------------------------------------------------===//
13
Marshall Clow20253612011-07-20 14:53:53 +000014#include <exception> // for std::unexpected_handler and std::terminate_handler
15#include <cxxabi.h>
16#include "unwind.h"
17
18namespace __cxxabiv1 {
19
20 struct __cxa_exception {
21#if __LP64__
22 // This is a new field to support C++ 0x exception_ptr.
23 // For binary compatibility it is at the start of this
24 // struct which is prepended to the object thrown in
25 // __cxa_allocate_exception.
26 size_t referenceCount;
27#endif
28
29 // Manage the exception object itself.
30 std::type_info *exceptionType;
31 void (*exceptionDestructor)(void *);
32 std::unexpected_handler unexpectedHandler;
33 std::terminate_handler terminateHandler;
34
35 __cxa_exception *nextException;
36
37 int handlerCount;
38
39#ifdef __ARM_EABI_UNWINDER__
40 __cxa_exception* nextPropagatingException;
41 int propagationCount;
42#else
43 int handlerSwitchValue;
44 const unsigned char *actionRecord;
45 const unsigned char *languageSpecificData;
46 void *catchTemp;
47 void *adjustedPtr;
48#endif
49
50#if !__LP64__
51 // This is a new field to support C++ 0x exception_ptr.
52 // For binary compatibility it is placed where the compiler
53 // previously adding padded to 64-bit align unwindHeader.
54 size_t referenceCount;
55#endif
56
57 _Unwind_Exception unwindHeader;
58 };
Howard Hinnanta6baba12011-12-08 19:35:18 +000059
60// http://sourcery.mentor.com/archives/cxx-abi-dev/msg01924.html
Marshall Clow20253612011-07-20 14:53:53 +000061
62 struct __cxa_dependent_exception {
63#if __LP64__
64 void* primaryException;
65#endif
66
67 // Unused dummy data (should be set to null)
68 std::type_info *exceptionType;
69 void (*exceptionDestructor)(void *);
70
71 std::unexpected_handler unexpectedHandler;
72 std::terminate_handler terminateHandler;
73
74 __cxa_exception *nextException;
75
76 int handlerCount;
77
78#ifdef __ARM_EABI_UNWINDER__
79 __cxa_exception* nextPropagatingException;
80 int propagationCount;
81#else
82 int handlerSwitchValue;
83 const unsigned char *actionRecord;
84 const unsigned char *languageSpecificData;
85 void * catchTemp;
86 void *adjustedPtr;
87#endif
88
89#if !__LP64__
90 void* primaryException;
91#endif
92
93 _Unwind_Exception unwindHeader;
94 };
95
96 struct __cxa_eh_globals {
97 __cxa_exception * caughtExceptions;
98 unsigned int uncaughtExceptions;
99#ifdef __ARM_EABI_UNWINDER__
100 __cxa_exception* propagatingExceptions;
101#endif
102 };
103
104 extern "C" __cxa_eh_globals * __cxa_get_globals () throw();
105 extern "C" __cxa_eh_globals * __cxa_get_globals_fast () throw();
106
107 extern "C" void * __cxa_allocate_dependent_exception () throw();
108 extern "C" void __cxa_free_dependent_exception (void * dependent_exception) throw();
109
110}