[runtimes] Pass-through CLANG_RESOURCE_DIR to cmake invocations (#73185)
[llvm-project.git] / libunwind / src / cet_unwind.h
blobc364ed3e12feb3930ccdece29f209264ca185592
1 //===----------------------------------------------------------------------===//
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 //===----------------------------------------------------------------------===//
10 #ifndef LIBUNWIND_CET_UNWIND_H
11 #define LIBUNWIND_CET_UNWIND_H
13 #include "libunwind.h"
15 // Currently, CET is implemented on Linux x86 platforms.
16 #if defined(_LIBUNWIND_TARGET_LINUX) && defined(__CET__) && defined(__SHSTK__)
17 #define _LIBUNWIND_USE_CET 1
18 #endif
20 #if defined(_LIBUNWIND_USE_CET)
21 #include <cet.h>
22 #include <immintrin.h>
24 #define _LIBUNWIND_POP_CET_SSP(x) \
25 do { \
26 unsigned long ssp = _get_ssp(); \
27 if (ssp != 0) { \
28 unsigned int tmp = (x); \
29 while (tmp > 255) { \
30 _inc_ssp(255); \
31 tmp -= 255; \
32 } \
33 _inc_ssp(tmp); \
34 } \
35 } while (0)
36 #endif
38 extern void *__libunwind_cet_get_registers(unw_cursor_t *);
39 extern void *__libunwind_cet_get_jump_target(void);
41 #endif