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