1 // Copyright 2017 The Fuchsia Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #pragma once
6 
7 // These get mangled so the raw pointer values don't leak into the heap.
8 #define JB_PC 0
9 #define JB_SP 1
10 #define JB_FP 2
11 #define JB_USP 3
12 #define JB_MANGLE_COUNT 4
13 
14 #ifdef __x86_64__
15 
16 // Other callee-saves registers.
17 #define JB_RBX (JB_MANGLE_COUNT + 0)
18 #define JB_R12 (JB_MANGLE_COUNT + 1)
19 #define JB_R13 (JB_MANGLE_COUNT + 2)
20 #define JB_R14 (JB_MANGLE_COUNT + 3)
21 #define JB_R15 (JB_MANGLE_COUNT + 4)
22 #define JB_COUNT (JB_MANGLE_COUNT + 5)
23 
24 #elif defined(__aarch64__)
25 
26 // Callee-saves registers are [x19,x28] and [d8,d15].
27 #define JB_X(n) (JB_MANGLE_COUNT + n - 19)
28 #define JB_D(n) (JB_X(29) + n - 8)
29 #define JB_COUNT JB_D(16)
30 
31 #else
32 
33 #error what architecture?
34 
35 #endif
36 
37 #ifndef __ASSEMBLER__
38 
39 #include <stdint.h>
40 
41 extern struct setjmp_manglers {
42     uintptr_t mangle[JB_MANGLE_COUNT];
43 } __setjmp_manglers __attribute__((visibility("hidden")));
44 
45 #endif
46