cbf7f63fdf053befb69ed99fdbfb11f728080e65
[folly.git] / folly / experimental / exception_tracer / ExceptionAbi.h
1 /*
2  * Copyright 2017 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 #pragma once
18
19 // A clone of the relevant parts of unwind-cxx.h from libstdc++
20 // The layout of these structures is defined by the ABI.
21
22 #include <exception>
23 #include <typeinfo>
24
25 #include <unwind.h>
26
27 namespace __cxxabiv1 {
28
29 struct __cxa_exception {
30   std::type_info* exceptionType;
31   void (*exceptionDestructor) (void*);
32   std::unexpected_handler unexpectedHandler;
33   std::terminate_handler terminateHandler;
34   __cxa_exception* nextException;
35
36   int handlerCount;
37   int handlerSwitchValue;
38   const char* actionRecord;
39   const char* languageSpecificData;
40   void* catchTemp;
41   void* adjustedPtr;
42
43   _Unwind_Exception unwindHeader;
44 };
45
46 struct __cxa_eh_globals {
47   __cxa_exception* caughtExceptions;
48   unsigned int uncaughtExceptions;
49 };
50
51 extern "C" {
52 __cxa_eh_globals* __cxa_get_globals(void) noexcept;
53 __cxa_eh_globals* __cxa_get_globals_fast(void) noexcept;
54 }
55
56 }  // namespace __cxxabiv1