xref: /trunk/main/bridges/source/cpp_uno/gcc3_freebsd_aarch64/share.hxx (revision 9c15e1abd703a7953928d7a80655ae1a76a41f6d)
1*9c15e1abSPedro Giffuni /*
2*9c15e1abSPedro Giffuni  * Licensed to the Apache Software Foundation (ASF) under one
3*9c15e1abSPedro Giffuni  * or more contributor license agreements.  See the NOTICE file
4*9c15e1abSPedro Giffuni  * distributed with this work for additional information
5*9c15e1abSPedro Giffuni  * regarding copyright ownership.  The ASF licenses this file
6*9c15e1abSPedro Giffuni  * to you under the Apache License, Version 2.0 (the
7*9c15e1abSPedro Giffuni  * "License"); you may not use this file except in compliance
8*9c15e1abSPedro Giffuni  * with the License.  You may obtain a copy of the License at
9*9c15e1abSPedro Giffuni  *
10*9c15e1abSPedro Giffuni  *   http://www.apache.org/licenses/LICENSE-2.0
11*9c15e1abSPedro Giffuni  *
12*9c15e1abSPedro Giffuni  * Unless required by applicable law or agreed to in writing,
13*9c15e1abSPedro Giffuni  * software distributed under the License is distributed on an
14*9c15e1abSPedro Giffuni  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15*9c15e1abSPedro Giffuni  * KIND, either express or implied.  See the License for the
16*9c15e1abSPedro Giffuni  * specific language governing permissions and limitations
17*9c15e1abSPedro Giffuni  * under the License.
18*9c15e1abSPedro Giffuni  */
19*9c15e1abSPedro Giffuni 
20*9c15e1abSPedro Giffuni 
21*9c15e1abSPedro Giffuni #include "uno/mapping.h"
22*9c15e1abSPedro Giffuni 
23*9c15e1abSPedro Giffuni #include <typeinfo>
24*9c15e1abSPedro Giffuni #include <exception>
25*9c15e1abSPedro Giffuni #include <cstddef>
26*9c15e1abSPedro Giffuni 
27*9c15e1abSPedro Giffuni namespace CPPU_CURRENT_NAMESPACE
28*9c15e1abSPedro Giffuni {
29*9c15e1abSPedro Giffuni 
30*9c15e1abSPedro Giffuni void dummy_can_throw_anything( char const * );
31*9c15e1abSPedro Giffuni 
32*9c15e1abSPedro Giffuni // Donor types for RTTI synthesis.  Their type_info objects are emitted by the
33*9c15e1abSPedro Giffuni // compiler, so they carry the real libc++abi vtables and the platform's own
34*9c15e1abSPedro Giffuni // uniqueness convention.  They must stay ordinary namespace-scope classes with
35*9c15e1abSPedro Giffuni // no virtual functions and a single public non-virtual base -- exactly the
36*9c15e1abSPedro Giffuni // shape of a generated UNO exception -- so that typeid(RttiDonorDerived) is a
37*9c15e1abSPedro Giffuni // __si_class_type_info and typeid(RttiDonorBase) a __class_type_info.
38*9c15e1abSPedro Giffuni // Do not move them into an anonymous namespace.
39*9c15e1abSPedro Giffuni struct RttiDonorBase { sal_Int32 dummy; };
40*9c15e1abSPedro Giffuni struct RttiDonorDerived : public RttiDonorBase { sal_Int32 dummy2; };
41*9c15e1abSPedro Giffuni 
42*9c15e1abSPedro Giffuni // Itanium ABI object layouts (http://itanium-cxx-abi.github.io/cxx-abi/abi.html#rtti).
43*9c15e1abSPedro Giffuni // libc++abi does not publish __cxxabiv1::__class_type_info, and declaring a
44*9c15e1abSPedro Giffuni // look-alike class is not an option: it would get its own vtable, and
45*9c15e1abSPedro Giffuni // __class_type_info::can_catch() dynamic_casts the thrown type to the real
46*9c15e1abSPedro Giffuni // libc++abi class, so no typed handler would ever match.  We therefore build
47*9c15e1abSPedro Giffuni // raw storage in the ABI layout and install a borrowed, genuine vtable.
48*9c15e1abSPedro Giffuni struct RttiClassLayout   { void const * pVtable; sal_uIntPtr nName; };
49*9c15e1abSPedro Giffuni struct RttiSiClassLayout { void const * pVtable; sal_uIntPtr nName; void const * pBase; };
50*9c15e1abSPedro Giffuni 
51*9c15e1abSPedro Giffuni extern "C" void *__cxa_allocate_exception(
52*9c15e1abSPedro Giffuni     std::size_t thrown_size ) throw();
53*9c15e1abSPedro Giffuni extern "C" void __cxa_free_exception( void *thrown_exception ) throw();
54*9c15e1abSPedro Giffuni extern "C" void __cxa_throw (
55*9c15e1abSPedro Giffuni     void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
56*9c15e1abSPedro Giffuni extern "C" std::type_info *__cxa_current_exception_type();
57*9c15e1abSPedro Giffuni 
58*9c15e1abSPedro Giffuni //==================================================================================================
59*9c15e1abSPedro Giffuni void raiseException(
60*9c15e1abSPedro Giffuni     uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
61*9c15e1abSPedro Giffuni //==================================================================================================
62*9c15e1abSPedro Giffuni void fillUnoException(
63*9c15e1abSPedro Giffuni     std::type_info const & type, void * exception, uno_Any *,
64*9c15e1abSPedro Giffuni     uno_Mapping * pCpp2Uno );
65*9c15e1abSPedro Giffuni }
66