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 #include <cstddef>
29 
30 namespace CPPU_CURRENT_NAMESPACE
31 {
32 
33 void dummy_can_throw_anything( char const * );
34 
35 // ----- the following structure is compatible with the one declared in libunwind's unwind.h
36 
37 struct _Unwind_Exception
38 {
39     unsigned long exception_class;
40 
41     unsigned exception_class __attribute__((__mode__(__DI__)));
42     void * exception_cleanup;
43     uintptr_t private_1;
44     uintptr_t private_2;
45 } __attribute__((__aligned__));
46 
47 struct __cxa_exception
48 {
49 #if __LP64__ // ----- from libcxxabi/src/cxa_exception.hpp
50     // This is a new field to support C++ 0x exception_ptr.
51     // For binary compatibility it is at the start of this
52     // struct which is prepended to the object thrown in
53     // __cxa_allocate_exception.
54     size_t referenceCount;
55 #endif
56 
57     ::std::type_info *exceptionType;
58     void (*exceptionDestructor)(void *);
59 
60     ::std::unexpected_handler unexpectedHandler;
61     ::std::terminate_handler terminateHandler;
62 
63     __cxa_exception *nextException;
64 
65     int handlerCount;
66 
67     int handlerSwitchValue;
68     const unsigned char *actionRecord;
69     const unsigned char *languageSpecificData;
70     void *catchTemp;
71     void *adjustedPtr;
72 
73     _Unwind_Exception unwindHeader;
74 };
75 
76 extern "C" void *__cxa_allocate_exception(
77     std::size_t thrown_size ) throw();
78 extern "C" void __cxa_throw (
79     void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn));
80 
81 struct __cxa_eh_globals
82 {
83     __cxa_exception *caughtExceptions;
84     unsigned int uncaughtExceptions;
85 };
86 extern "C" __cxa_eh_globals *__cxa_get_globals () throw();
87 
88 // -----
89 
90 //==================================================================================================
91 void raiseException(
92     uno_Any * pUnoExc, uno_Mapping * pUno2Cpp );
93 //==================================================================================================
94 void fillUnoException(
95     __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno );
96 }
97 
98