LibreOffice Module bridges (master)  1
gcc3_linux_aarch64/abi.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #pragma once
21 
22 #include <sal/config.h>
23 
24 #include <cstddef>
25 #include <exception>
26 #include <typeinfo>
27 
28 #include <cxxabi.h>
29 #ifndef _GLIBCXX_CDTOR_CALLABI // new in GCC 4.7 cxxabi.h
30 #define _GLIBCXX_CDTOR_CALLABI
31 #endif
32 #include <unwind.h>
33 
34 #include <config_cxxabi.h>
35 #include <typelib/typedescription.h>
36 #include <uno/any2.h>
37 #include <uno/mapping.h>
38 
39 #if !HAVE_CXXABI_H_CLASS_TYPE_INFO
40 // <https://mentorembedded.github.io/cxx-abi/abi.html>,
41 // libstdc++-v3/libsupc++/cxxabi.h:
42 namespace __cxxabiv1 {
43 class __class_type_info: public std::type_info {
44 public:
45  explicit __class_type_info(char const * n): type_info(n) {}
46  ~__class_type_info() override;
47 };
48 }
49 #endif
50 
51 #if !HAVE_CXXABI_H_SI_CLASS_TYPE_INFO
52 // <https://mentorembedded.github.io/cxx-abi/abi.html>,
53 // libstdc++-v3/libsupc++/cxxabi.h:
54 namespace __cxxabiv1 {
55 class __si_class_type_info: public __class_type_info {
56 public:
59  char const * n, __class_type_info const *base):
60  __class_type_info(n), __base_type(base) {}
61  ~__si_class_type_info() override;
62 };
63 }
64 #endif
65 
66 #if !HAVE_CXXABI_H_CXA_EXCEPTION
67 // <https://mentorembedded.github.io/cxx-abi/abi-eh.html>,
68 // libcxxabi/src/cxa_exception.hpp:
69 namespace __cxxabiv1 {
70 struct __cxa_exception {
71 #if defined _LIBCPPABI_VERSION // detect libc++abi
72 #if defined __LP64__ || LIBCXXABI_ARM_EHABI
73 #ifdef MACOSX // on arm64
74  // This is a new field added with LLVM 10
75  // <https://github.com/llvm/llvm-project/commit/674ec1eb16678b8addc02a4b0534ab383d22fa77>
76  // "[libcxxabi] Insert padding in __cxa_exception struct for compatibility". For non-MACOSX,
77  // the HACK in call (bridges/source/cpp_uno/gcc3_linux_aarch64/uno2cpp.cxx) tries to find out at
78  // runtime whether a __cxa_exception has this member. Once we can be sure that we only run
79  // against new libcxxabi that has this member, we can drop the "#ifdef MACOSX" here and drop the
80  // hack in call.
81 
82  // Now _Unwind_Exception is marked with __attribute__((aligned)),
83  // which implies __cxa_exception is also aligned. Insert padding
84  // in the beginning of the struct, rather than before unwindHeader.
85  void *reserve;
86 #endif
87  std::size_t referenceCount;
88 #endif
89 #endif
90  std::type_info * exceptionType;
91  void (* exceptionDestructor)(void *);
92  void (*unexpectedHandler)(); // std::unexpected_handler dropped from C++17
93  std::terminate_handler terminateHandler;
94  __cxa_exception * nextException;
95  int handlerCount;
97  char const * actionRecord;
98  char const * languageSpecificData;
99  void * catchTemp;
100  void * adjustedPtr;
101  _Unwind_Exception unwindHeader;
102 };
103 }
104 #endif
105 
106 #if !HAVE_CXXABI_H_CXA_EH_GLOBALS
107 // <https://mentorembedded.github.io/cxx-abi/abi-eh.html>:
108 namespace __cxxabiv1 {
109 struct __cxa_eh_globals {
110  __cxa_exception * caughtExceptions;
111  unsigned int uncaughtExceptions;
112 };
113 }
114 #endif
115 
116 #if !HAVE_CXXABI_H_CXA_GET_GLOBALS
117 namespace __cxxabiv1 {
118 extern "C" __cxa_eh_globals * __cxa_get_globals() throw();
119 }
120 #endif
121 
122 #if !HAVE_CXXABI_H_CXA_CURRENT_EXCEPTION_TYPE
123 namespace __cxxabiv1 {
124 extern "C" std::type_info *__cxa_current_exception_type() throw();
125 }
126 #endif
127 
128 #if !HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION
129 namespace __cxxabiv1 {
130 extern "C" void * __cxa_allocate_exception(std::size_t thrown_size) throw();
131 }
132 #endif
133 
134 #if !HAVE_CXXABI_H_CXA_THROW
135 namespace __cxxabiv1 {
136 extern "C" void __cxa_throw(
137  void * thrown_exception, void * tinfo, void (* dest)(void *))
138  __attribute__((noreturn));
139 }
140 #endif
141 
142 namespace abi_aarch64 {
143 
144 void mapException(
145  __cxxabiv1::__cxa_exception * exception, std::type_info const * type, uno_Any * any, uno_Mapping * mapping);
146 
147 void raiseException(uno_Any * any, uno_Mapping * mapping);
148 
152 
154 
155 }
156 
157 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
__si_class_type_info(char const *n, __class_type_info const *base)
struct _uno_Mapping uno_Mapping
Definition: msvc/except.hxx:32
sal_Int64 n
_Unwind_Exception unwindHeader
Definition: unwind-cxx.h:124
std::type_info * __cxa_current_exception_type()
struct _uno_Any uno_Any
Definition: msvc/except.hxx:31
unsigned int uncaughtExceptions
Definition: unwind-cxx.h:131
unsigned _Unwind_Word __attribute__((__mode__(__word__)))
Definition: unwind-cxx.h:45
void const * base
struct _typelib_TypeDescription typelib_TypeDescription
Definition: msvc/except.hxx:52
void * __cxa_allocate_exception(size_t thrown_size)
void raiseException(uno_Any *pUnoExc, uno_Mapping *pUno2Cpp)
__cxa_eh_globals * __cxa_get_globals()
void(* exceptionDestructor)(void *)
Definition: unwind-cxx.h:87
std::type_info * exceptionType
Definition: unwind-cxx.h:86
void mapException(__cxxabiv1::__cxa_exception *exception, std::type_info const *type, uno_Any *any, uno_Mapping *mapping)
std::terminate_handler terminateHandler
Definition: unwind-cxx.h:92
__cxa_exception * caughtExceptions
Definition: unwind-cxx.h:130
ReturnKind getReturnKind(typelib_TypeDescription const *type)
void __cxa_throw(void *thrown_exception, std::type_info *tinfo, void(*dest)(void *)) __attribute__((noreturn))
__cxa_exception * nextException
Definition: unwind-cxx.h:95
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo