btrfs: [] on the end of a struct field is a variable length array.
[haiku.git] / headers / libs / libunwind / libunwind-mips.h
blob4591d062b265c1c115fe0654725d2dc30df31ca3
1 /* libunwind - a platform-independent unwind library
2 Copyright (C) 2008 CodeSourcery
4 This file is part of libunwind.
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files (the
8 "Software"), to deal in the Software without restriction, including
9 without limitation the rights to use, copy, modify, merge, publish,
10 distribute, sublicense, and/or sell copies of the Software, and to
11 permit persons to whom the Software is furnished to do so, subject to
12 the following conditions:
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
25 #ifndef LIBUNWIND_H
26 #define LIBUNWIND_H
28 #if defined(__cplusplus) || defined(c_plusplus)
29 extern "C" {
30 #endif
32 #include <inttypes.h>
33 #include <ucontext.h>
35 #ifdef mips
36 # undef mips
37 #endif
39 #define UNW_TARGET mips
40 #define UNW_TARGET_MIPS 1
42 #define _U_TDEP_QP_TRUE 0 /* see libunwind-dynamic.h */
44 /* This needs to be big enough to accommodate "struct cursor", while
45 leaving some slack for future expansion. Changing this value will
46 require recompiling all users of this library. Stack allocation is
47 relatively cheap and unwind-state copying is relatively rare, so we
48 want to err on making it rather too big than too small. */
50 /* FIXME for MIPS. Too big? What do other things use for similar tasks? */
51 #define UNW_TDEP_CURSOR_LEN 4096
53 /* The size of a "word" varies on MIPS. This type is used for memory
54 addresses and register values. To allow a single library to support
55 multiple ABIs, and to support N32 at all, we must use a 64-bit type
56 even when addresses are only 32 bits. */
57 typedef uint64_t unw_word_t;
58 typedef int32_t unw_sword_t;
60 /* FIXME: MIPS ABIs. */
61 typedef long double unw_tdep_fpreg_t;
63 typedef enum
65 UNW_MIPS_R0,
66 UNW_MIPS_R1,
67 UNW_MIPS_R2,
68 UNW_MIPS_R3,
69 UNW_MIPS_R4,
70 UNW_MIPS_R5,
71 UNW_MIPS_R6,
72 UNW_MIPS_R7,
73 UNW_MIPS_R8,
74 UNW_MIPS_R9,
75 UNW_MIPS_R10,
76 UNW_MIPS_R11,
77 UNW_MIPS_R12,
78 UNW_MIPS_R13,
79 UNW_MIPS_R14,
80 UNW_MIPS_R15,
81 UNW_MIPS_R16,
82 UNW_MIPS_R17,
83 UNW_MIPS_R18,
84 UNW_MIPS_R19,
85 UNW_MIPS_R20,
86 UNW_MIPS_R21,
87 UNW_MIPS_R22,
88 UNW_MIPS_R23,
89 UNW_MIPS_R24,
90 UNW_MIPS_R25,
91 UNW_MIPS_R26,
92 UNW_MIPS_R27,
93 UNW_MIPS_R28,
94 UNW_MIPS_R29,
95 UNW_MIPS_R30,
96 UNW_MIPS_R31,
98 UNW_MIPS_PC = 34,
100 /* FIXME: Other registers! */
102 /* For MIPS, the CFA is the value of SP (r29) at the call site in the
103 previous frame. */
104 UNW_MIPS_CFA,
106 UNW_TDEP_LAST_REG = UNW_MIPS_R31,
108 UNW_TDEP_IP = UNW_MIPS_R31,
109 UNW_TDEP_SP = UNW_MIPS_R29,
110 UNW_TDEP_EH = UNW_MIPS_R0 /* FIXME. */
112 mips_regnum_t;
114 typedef enum
116 UNW_MIPS_ABI_O32,
117 UNW_MIPS_ABI_N32,
118 UNW_MIPS_ABI_N64
120 mips_abi_t;
122 #define UNW_TDEP_NUM_EH_REGS 2 /* FIXME for MIPS. */
124 typedef struct unw_tdep_save_loc
126 /* Additional target-dependent info on a save location. */
128 unw_tdep_save_loc_t;
130 /* On x86, we can directly use ucontext_t as the unwind context. FIXME for
131 MIPS. */
132 typedef ucontext_t unw_tdep_context_t;
134 #include "libunwind-dynamic.h"
136 typedef struct
138 /* no mips-specific auxiliary proc-info */
140 unw_tdep_proc_info_t;
142 #include "libunwind-common.h"
144 /* There is no getcontext() on MIPS. Use a stub version which only saves GP
145 registers. FIXME: Not ideal, may not be sufficient for all libunwind
146 use cases. */
147 #define unw_tdep_getcontext UNW_ARCH_OBJ(getcontext)
148 extern int unw_tdep_getcontext (ucontext_t *uc);
150 #define unw_tdep_is_fpreg UNW_ARCH_OBJ(is_fpreg)
151 extern int unw_tdep_is_fpreg (int);
153 #if defined(__cplusplus) || defined(c_plusplus)
155 #endif
157 #endif /* LIBUNWIND_H */