blob: 9681298a6068b1381ca91a0ea0b913b07c920b52 [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 };
59
60 struct __cxa_dependent_exception {
61#if __LP64__
62 void* primaryException;
63#endif
64
65 // Unused dummy data (should be set to null)
66 std::type_info *exceptionType;
67 void (*exceptionDestructor)(void *);
68
69 std::unexpected_handler unexpectedHandler;
70 std::terminate_handler terminateHandler;
71
72 __cxa_exception *nextException;
73
74 int handlerCount;
75
76#ifdef __ARM_EABI_UNWINDER__
77 __cxa_exception* nextPropagatingException;
78 int propagationCount;
79#else
80 int handlerSwitchValue;
81 const unsigned char *actionRecord;
82 const unsigned char *languageSpecificData;
83 void * catchTemp;
84 void *adjustedPtr;
85#endif
86
87#if !__LP64__
88 void* primaryException;
89#endif
90
91 _Unwind_Exception unwindHeader;
92 };
93
94 struct __cxa_eh_globals {
95 __cxa_exception * caughtExceptions;
96 unsigned int uncaughtExceptions;
97#ifdef __ARM_EABI_UNWINDER__
98 __cxa_exception* propagatingExceptions;
99#endif
100 };
101
102 extern "C" __cxa_eh_globals * __cxa_get_globals () throw();
103 extern "C" __cxa_eh_globals * __cxa_get_globals_fast () throw();
104
105 extern "C" void * __cxa_allocate_dependent_exception () throw();
106 extern "C" void __cxa_free_dependent_exception (void * dependent_exception) throw();
107
108}