xref: /trunk/main/bridges/source/cpp_uno/gcc3_freebsd_powerpc64/share.hxx (revision 66b843ff8f1eedd2e69941f1ea52fa080f01ec28)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #include "uno/mapping.h"
25 
26 #include <typeinfo>
27 #include <exception>
28 
29 #include <cxxabi.h>
30 #ifndef _GLIBCXX_CDTOR_CALLABI // new in GCC 4.7 cxxabi.h
31 #define _GLIBCXX_CDTOR_CALLABI
32 #endif
33 #include <cstddef>
34 
35 #ifndef CONFIG_CXXABI_H
36 #define CONFIG_CXXABI_H
37 
38 #define HAVE_CXXABI_H_BASE_CLASS_TYPE_INFO 0
39 #define HAVE_CXXABI_H_CLASS_TYPE_INFO 0
40 #define HAVE_CXXABI_H_CXA_ALLOCATE_EXCEPTION 0
41 #define HAVE_CXXABI_H_CXA_EH_GLOBALS 1
42 #define HAVE_CXXABI_H_CXA_EXCEPTION 1
43 #define HAVE_CXXABI_H_CXA_GET_GLOBALS 1
44 #define HAVE_CXXABI_H_CXA_CURRENT_EXCEPTION_TYPE 1
45 #define HAVE_CXXABI_H_CXA_THROW 0
46 #define HAVE_CXXABI_H_SI_CLASS_TYPE_INFO 0
47 #define HAVE_CXXABI_H_VMI_CLASS_TYPE_INFO 0
48 
49 #endif
50 
51 #if !HAVE_CXXABI_H_CLASS_TYPE_INFO
52 // <https://mentorembedded.github.io/cxx-abi/abi.html>,
53 // libstdc++-v3/libsupc++/cxxabi.h:
54 namespace __cxxabiv1 {
55 class __class_type_info: public std::type_info {
56 public:
57     explicit __class_type_info(char const * n): type_info(n) {}
58     ~__class_type_info();
59 };
60 }
61 #endif
62 
63 #if !HAVE_CXXABI_H_SI_CLASS_TYPE_INFO
64 // <https://mentorembedded.github.io/cxx-abi/abi.html>,
65 // libstdc++-v3/libsupc++/cxxabi.h:
66 namespace __cxxabiv1 {
67 class __si_class_type_info: public __class_type_info {
68 public:
69     __class_type_info const * __base_type;
70     explicit __si_class_type_info(
71         char const * n, __class_type_info const *base):
72         __class_type_info(n), __base_type(base) {}
73     ~__si_class_type_info();
74 };
75 }
76 #endif
77 
78 namespace CPPU_CURRENT_NAMESPACE
79 {
80 
81 void dummy_can_throw_anything( char const * );
82 
83 // ----- following decl from libstdc++-v3/libsupc++/unwind-cxx.h and unwind.h
84 
85 #ifdef __GLIBCXX__
86 struct _Unwind_Exception
87 {
88     unsigned exception_class __attribute__((__mode__(__DI__)));
89     void * exception_cleanup;
90     unsigned private_1 __attribute__((__mode__(__word__)));
91     unsigned private_2 __attribute__((__mode__(__word__)));
92 } __attribute__((__aligned__));
93 
94 struct __cxa_exception
95 {
96     ::std::type_info *exceptionType;
97     void (*exceptionDestructor)(void *);
98 
99     ::std::unexpected_handler unexpectedHandler;
100     ::std::terminate_handler terminateHandler;
101 
102     __cxa_exception *nextException;
103 
104     int handlerCount;
105 
106     int handlerSwitchValue;
107     const unsigned char *actionRecord;
108     const unsigned char *languageSpecificData;
109     void *catchTemp;
110     void *adjustedPtr;
111 
112     _Unwind_Exception unwindHeader;
113 };
114 #endif /* __GLIBCXX__ */
115 
116 extern "C" void *__cxa_allocate_exception(
117     std::size_t thrown_size ) throw();
118 extern "C" void __cxa_throw (
119     void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
120 
121 #ifdef __GLIBCXX__
122 struct __cxa_eh_globals
123 {
124     __cxa_exception *caughtExceptions;
125     unsigned int uncaughtExceptions;
126 };
127 extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
128 #endif /* __GLIBCXX__ */
129 
130 // -----
131 
132 //==================================================================================================
133 void raiseException(
134     uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
135 //==================================================================================================
136 #ifndef __GLIBCXX__
137 using __cxxabiv1:: __cxa_exception;
138 #endif /* __GLIBCXX__ */
139 
140 void fillUnoException(
141     __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
142 }
143 
144 namespace ppc64
145 {
146      enum ppclimits { MAX_GPR_REGS = 8, MAX_SSE_REGS = 13 };
147     bool return_in_hidden_param( typelib_TypeDescriptionReference *pTypeRef );
148 }
149