xref: /freebsd/contrib/llvm-project/libunwind/src/Unwind-EHABI.h (revision 349cc55c9796c4596a5b9904cd3281af295f878f)
1*349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
20b57cec5SDimitry Andric //
30b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
40b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
50b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
60b57cec5SDimitry Andric //
70b57cec5SDimitry Andric //
80b57cec5SDimitry Andric //===----------------------------------------------------------------------===//
90b57cec5SDimitry Andric 
100b57cec5SDimitry Andric #ifndef __UNWIND_EHABI_H__
110b57cec5SDimitry Andric #define __UNWIND_EHABI_H__
120b57cec5SDimitry Andric 
130b57cec5SDimitry Andric #include <__libunwind_config.h>
140b57cec5SDimitry Andric 
150b57cec5SDimitry Andric #if defined(_LIBUNWIND_ARM_EHABI)
160b57cec5SDimitry Andric 
170b57cec5SDimitry Andric #include <stdint.h>
180b57cec5SDimitry Andric #include <unwind.h>
190b57cec5SDimitry Andric 
200b57cec5SDimitry Andric // Unable to unwind in the ARM index table (section 5 EHABI).
210b57cec5SDimitry Andric #define UNW_EXIDX_CANTUNWIND 0x1
220b57cec5SDimitry Andric 
signExtendPrel31(uint32_t data)230b57cec5SDimitry Andric static inline uint32_t signExtendPrel31(uint32_t data) {
240b57cec5SDimitry Andric   return data | ((data & 0x40000000u) << 1);
250b57cec5SDimitry Andric }
260b57cec5SDimitry Andric 
readPrel31(const uint32_t * data)270b57cec5SDimitry Andric static inline uint32_t readPrel31(const uint32_t *data) {
280b57cec5SDimitry Andric   return (((uint32_t)(uintptr_t)data) + signExtendPrel31(*data));
290b57cec5SDimitry Andric }
300b57cec5SDimitry Andric 
310b57cec5SDimitry Andric #if defined(__cplusplus)
320b57cec5SDimitry Andric extern "C" {
330b57cec5SDimitry Andric #endif
340b57cec5SDimitry Andric 
350b57cec5SDimitry Andric extern _Unwind_Reason_Code __aeabi_unwind_cpp_pr0(
360b57cec5SDimitry Andric     _Unwind_State state, _Unwind_Control_Block *ucbp, _Unwind_Context *context);
370b57cec5SDimitry Andric 
380b57cec5SDimitry Andric extern _Unwind_Reason_Code __aeabi_unwind_cpp_pr1(
390b57cec5SDimitry Andric     _Unwind_State state, _Unwind_Control_Block *ucbp, _Unwind_Context *context);
400b57cec5SDimitry Andric 
410b57cec5SDimitry Andric extern _Unwind_Reason_Code __aeabi_unwind_cpp_pr2(
420b57cec5SDimitry Andric     _Unwind_State state, _Unwind_Control_Block *ucbp, _Unwind_Context *context);
430b57cec5SDimitry Andric 
440b57cec5SDimitry Andric #if defined(__cplusplus)
450b57cec5SDimitry Andric } // extern "C"
460b57cec5SDimitry Andric #endif
470b57cec5SDimitry Andric 
480b57cec5SDimitry Andric #endif // defined(_LIBUNWIND_ARM_EHABI)
490b57cec5SDimitry Andric 
500b57cec5SDimitry Andric #endif  // __UNWIND_EHABI_H__
51