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 typedef unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__))); 36 37 // ----- the following structure is compatible with the one declared in libunwind's unwind.h 38 // (use forced types) 39 40 struct _Unwind_Exception 41 { 42 uint64_t exception_class; 43 void * exception_cleanup; 44 uintptr_t private_1; 45 uintptr_t private_2; 46 }; 47 48 struct __cxa_exception 49 { 50 #if __LP64__ 51 // From LLVM 10 - Added reserved member at top of struct. Who the hell does that? 52 // https://reviews.llvm.org/rG674ec1eb16678b8addc02a4b0534ab383d22fa77 53 // Sure would be nice to be able to test for CCNUMVER >= 1000000000 54 // and COM == CLANG here. 55 void *reserved; 56 // ----- from libcxxabi/src/cxa_exception.hpp 57 // This is a new field to support C++ 0x exception_ptr. 58 // For binary compatibility it is at the start of this 59 // struct which is prepended to the object thrown in 60 // __cxa_allocate_exception. 61 size_t referenceCount; 62 #endif 63 64 ::std::type_info *exceptionType; 65 void (*exceptionDestructor)(void *); 66 67 ::std::unexpected_handler unexpectedHandler; 68 ::std::terminate_handler terminateHandler; 69 70 __cxa_exception *nextException; 71 72 int handlerCount; 73 74 int handlerSwitchValue; 75 const unsigned char *actionRecord; 76 const unsigned char *languageSpecificData; 77 void *catchTemp; 78 void *adjustedPtr; 79 80 _Unwind_Exception unwindHeader; 81 }; 82 83 extern "C" void *__cxa_allocate_exception( 84 std::size_t thrown_size ) throw(); 85 extern "C" void __cxa_throw ( 86 void *thrown_exception, std::type_info *tinfo, void (*dest) (void *) ) __attribute__((noreturn)); 87 88 struct __cxa_eh_globals 89 { 90 __cxa_exception *caughtExceptions; 91 unsigned int uncaughtExceptions; 92 }; 93 extern "C" __cxa_eh_globals *__cxa_get_globals () throw(); 94 95 // ----- 96 97 // on OSX 64bit the class_type_info classes are specified 98 // in http://refspecs.linuxbase.org/cxxabi-1.86.html#rtti but 99 // these details are not generally available in a public header 100 // of most development environments. So we define them here. 101 // NOTE: https://www.hexblog.com/wp-content/uploads/2012/06/Recon-2012-Skochinsky-Compiler-Internals.pdf 102 class __class_type_info : public std::type_info 103 { 104 public: 105 explicit __class_type_info( const char* pRttiName) 106 : std::type_info( pRttiName) 107 {} 108 }; 109 110 class __si_class_type_info : public __class_type_info 111 { 112 public: 113 const __class_type_info* mpBaseType; 114 explicit __si_class_type_info( const char* pRttiName, __class_type_info* pBaseType) 115 : __class_type_info( pRttiName), mpBaseType( pBaseType) 116 {} 117 }; 118 119 //================================================================================================== 120 void raiseException( 121 uno_Any * pUnoExc, uno_Mapping * pUno2Cpp ); 122 //================================================================================================== 123 void fillUnoException( 124 __cxa_exception * header, uno_Any *, uno_Mapping * pCpp2Uno ); 125 } 126 127