1 // Copyright (C) 2012 The Android Open Source Project 2 // All rights reserved. 3 // 4 // Redistribution and use in source and binary forms, with or without 5 // modification, are permitted provided that the following conditions 6 // are met: 7 // 1. Redistributions of source code must retain the above copyright 8 // notice, this list of conditions and the following disclaimer. 9 // 2. Redistributions in binary form must reproduce the above copyright 10 // notice, this list of conditions and the following disclaimer in the 11 // documentation and/or other materials provided with the distribution. 12 // 3. Neither the name of the project nor the names of its contributors 13 // may be used to endorse or promote products derived from this software 14 // without specific prior written permission. 15 // 16 // THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 // ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 // OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 // LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 // OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 // SUCH DAMAGE. 27 28 #ifndef __GABIXX_UNWIND_ITANIUM_H__ 29 #define __GABIXX_UNWIND_ITANIUM_H__ 30 31 #include <stdint.h> 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif 36 37 typedef enum { 38 _URC_NO_REASON = 0, 39 _URC_FOREIGN_EXCEPTION_CAUGHT = 1, 40 _URC_FATAL_PHASE2_ERROR = 2, 41 _URC_FATAL_PHASE1_ERROR = 3, 42 _URC_NORMAL_STOP = 4, 43 _URC_END_OF_STACK = 5, 44 _URC_HANDLER_FOUND = 6, 45 _URC_INSTALL_CONTEXT = 7, 46 _URC_CONTINUE_UNWIND = 8 47 } _Unwind_Reason_Code; 48 49 typedef int _Unwind_Action; 50 static const _Unwind_Action _UA_SEARCH_PHASE = 1; 51 static const _Unwind_Action _UA_CLEANUP_PHASE = 2; 52 static const _Unwind_Action _UA_HANDLER_FRAME = 4; 53 static const _Unwind_Action _UA_FORCE_UNWIND = 8; 54 55 struct _Unwind_Context; // system-specific opaque 56 struct _Unwind_Exception; 57 58 typedef void (*_Unwind_Exception_Cleanup_Fn) (_Unwind_Reason_Code reason, 59 struct _Unwind_Exception* exc); 60 61 typedef _Unwind_Reason_Code (*_Unwind_Stop_Fn) (int version, 62 _Unwind_Action actions, 63 uint64_t exceptionClass, 64 struct _Unwind_Exception*, 65 struct _Unwind_Context*, 66 void* stop_parameter); 67 68 struct _Unwind_Exception { 69 uint64_t exception_class; 70 _Unwind_Exception_Cleanup_Fn exception_cleanup; 71 72 /** 73 * The architectures supported by the following declarations are: 74 * x86 with LP32, x86_64 with LP64 75 * arm64 with LP64 76 * mips, mips64 77 */ 78 unsigned long private_1; 79 unsigned long private_2; 80 } 81 #if defined(__clang__) && defined(__mips__) 82 // FIXME: It seems that mipsel-linux-android-gcc will use 24 as the object size 83 // with or without the aligned attribute. However, clang (mipsel) will align 84 // the object size to 32 when we specify the aligned attribute, which may 85 // result in some sort of incompatibility. As a workaround, let's remove this 86 // attribute when we are compiling this file for MIPS architecture with clang. 87 // Add the attribute back when clang can have same behavior as gcc. 88 #else 89 __attribute__((__aligned__)) // must be double-word aligned 90 #endif 91 ; 92 93 _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception*); 94 void _Unwind_Resume(struct _Unwind_Exception*); 95 void _Unwind_DeleteException(struct _Unwind_Exception*); 96 97 uint64_t _Unwind_GetGR(struct _Unwind_Context*, int index); 98 void _Unwind_SetGR(struct _Unwind_Context*, int index, uint64_t new_value); 99 100 uint64_t _Unwind_GetIP(struct _Unwind_Context*); 101 void _Unwind_SetIP(struct _Unwind_Context*, uintptr_t new_value); 102 103 uint64_t _Unwind_GetRegionStart(struct _Unwind_Context*); 104 uint64_t _Unwind_GetLanguageSpecificData(struct _Unwind_Context*); 105 106 _Unwind_Reason_Code _Unwind_ForcedUnwind(struct _Unwind_Exception*, 107 _Unwind_Stop_Fn stop, 108 void* stop_parameter); 109 110 _Unwind_Reason_Code _Unwind_RaiseException(struct _Unwind_Exception*); 111 void _Unwind_Resume(struct _Unwind_Exception*); 112 void _Unwind_DeleteException(struct _Unwind_Exception*); 113 114 #ifdef __cplusplus 115 } // extern "C" 116 #endif 117 118 #endif // __GABIXX_UNWIND_ITANIUM_H__ 119