3fa10cc7b79b27c2e2f3f6c74ebcd53af75b15a8
[folly.git] / folly / experimental / exception_tracer / ExceptionAbi.h
1 /*
2  * Copyright 2013 Facebook, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #ifndef FOLLY_EXPERIMENTAL_EXCEPTION_TRACER_EXCEPTIONABI_H_
19 #define FOLLY_EXPERIMENTAL_EXCEPTION_TRACER_EXCEPTIONABI_H_
20
21 // A clone of the relevant parts of unwind-cxx.h from libstdc++
22 // The layout of these structures is defined by the ABI.
23
24 #include <exception>
25 #include <typeinfo>
26
27 #include <unwind.h>
28
29 namespace __cxxabiv1 {
30
31 struct __cxa_exception {
32   std::type_info* exceptionType;
33   void (*exceptionDestructor) (void*);
34   std::unexpected_handler unexpectedHandler;
35   std::terminate_handler terminateHandler;
36   __cxa_exception* nextException;
37
38   int handlerCount;
39   int handlerSwitchValue;
40   const char* actionRecord;
41   const char* languageSpecificData;
42   void* catchTemp;
43   void* adjustedPtr;
44
45   _Unwind_Exception unwindHeader;
46 };
47
48 struct __cxa_eh_globals {
49   __cxa_exception* caughtExceptions;
50   unsigned int uncaughtExceptions;
51 };
52
53 extern "C" {
54 __cxa_eh_globals* __cxa_get_globals(void) noexcept;
55 __cxa_eh_globals* __cxa_get_globals_fast(void) noexcept;
56 }
57
58 }  // namespace __cxxabiv1
59
60 #endif /* FOLLY_EXPERIMENTAL_EXCEPTION_TRACER_EXCEPTIONABI_H_ */
61