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