xref: /freebsd/contrib/llvm-project/compiler-rt/lib/builtins/unwind-ehabi-helpers.h (revision 0b57cec536236d46e3dba9bd041533462f33dbb7)
1*0b57cec5SDimitry Andric //===-- arm-ehabi-helpers.h - Supplementary ARM EHABI declarations --------===//
2*0b57cec5SDimitry Andric //
3*0b57cec5SDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*0b57cec5SDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5*0b57cec5SDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*0b57cec5SDimitry Andric //
7*0b57cec5SDimitry Andric //===--------------------------------------------------------------------===//
8*0b57cec5SDimitry Andric 
9*0b57cec5SDimitry Andric #ifndef UNWIND_EHABI_HELPERS_H
10*0b57cec5SDimitry Andric #define UNWIND_EHABI_HELPERS_H
11*0b57cec5SDimitry Andric 
12*0b57cec5SDimitry Andric #include <stdint.h>
13*0b57cec5SDimitry Andric // NOTE: see reasoning for this inclusion below
14*0b57cec5SDimitry Andric #include <unwind.h>
15*0b57cec5SDimitry Andric 
16*0b57cec5SDimitry Andric #if !defined(__ARM_EABI_UNWINDER__)
17*0b57cec5SDimitry Andric 
18*0b57cec5SDimitry Andric // NOTE: _URC_OK, _URC_FAILURE must be present as preprocessor tokens.  This
19*0b57cec5SDimitry Andric // allows for a substitution of a constant which can be cast into the
20*0b57cec5SDimitry Andric // appropriate enumerated type.  This header is expected to always be included
21*0b57cec5SDimitry Andric // AFTER unwind.h (which is why it is forcefully included above).  This ensures
22*0b57cec5SDimitry Andric // that we do not overwrite the token for the enumeration.  Subsequent uses of
23*0b57cec5SDimitry Andric // the token would be clean to rewrite with constant values.
24*0b57cec5SDimitry Andric //
25*0b57cec5SDimitry Andric // The typedef redeclaration should be safe.  Due to the protection granted to
26*0b57cec5SDimitry Andric // us by the `__ARM_EABI_UNWINDER__` above, we are guaranteed that we are in a
27*0b57cec5SDimitry Andric // header not vended by gcc.  The HP unwinder (being an itanium unwinder) does
28*0b57cec5SDimitry Andric // not support EHABI, and the GNU unwinder, derived from the HP unwinder, also
29*0b57cec5SDimitry Andric // does not support EHABI as of the introduction of this header.  As such, we
30*0b57cec5SDimitry Andric // are fairly certain that we are in the LLVM case.  Here, _Unwind_State is a
31*0b57cec5SDimitry Andric // typedef, and so we can get away with a redeclaration.
32*0b57cec5SDimitry Andric //
33*0b57cec5SDimitry Andric // Guarded redefinitions of the needed unwind state prevent the redefinition of
34*0b57cec5SDimitry Andric // those states.
35*0b57cec5SDimitry Andric 
36*0b57cec5SDimitry Andric #define _URC_OK 0
37*0b57cec5SDimitry Andric #define _URC_FAILURE 9
38*0b57cec5SDimitry Andric 
39*0b57cec5SDimitry Andric typedef uint32_t _Unwind_State;
40*0b57cec5SDimitry Andric 
41*0b57cec5SDimitry Andric #if !defined(_US_UNWIND_FRAME_STARTING)
42*0b57cec5SDimitry Andric #define _US_UNWIND_FRAME_STARTING ((_Unwind_State)1)
43*0b57cec5SDimitry Andric #endif
44*0b57cec5SDimitry Andric 
45*0b57cec5SDimitry Andric #if !defined(_US_ACTION_MASK)
46*0b57cec5SDimitry Andric #define _US_ACTION_MASK ((_Unwind_State)3)
47*0b57cec5SDimitry Andric #endif
48*0b57cec5SDimitry Andric 
49*0b57cec5SDimitry Andric #endif
50*0b57cec5SDimitry Andric 
51*0b57cec5SDimitry Andric #endif
52