Protect against some memory leaks
[platform/upstream/libunwind.git] / include / libunwind-tilegx.h
1 /* libunwind - a platform-independent unwind library
2    Copyright (C) 2008 CodeSourcery
3    Copyright (C) 2014 Tilera Corp.
4
5 This file is part of libunwind.
6
7 Permission is hereby granted, free of charge, to any person obtaining
8 a copy of this software and associated documentation files (the
9 "Software"), to deal in the Software without restriction, including
10 without limitation the rights to use, copy, modify, merge, publish,
11 distribute, sublicense, and/or sell copies of the Software, and to
12 permit persons to whom the Software is furnished to do so, subject to
13 the following conditions:
14
15 The above copyright notice and this permission notice shall be
16 included in all copies or substantial portions of the Software.
17
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
25
26 #ifndef LIBUNWIND_H
27 #define LIBUNWIND_H
28
29 #if defined(__cplusplus) || defined(c_plusplus)
30 extern "C" {
31 #endif
32
33 #include <inttypes.h>
34 #include <ucontext.h>
35
36 #define UNW_TARGET           tilegx
37 #define UNW_TARGET_TILEGX    1
38
39 #define _U_TDEP_QP_TRUE        0    /* see libunwind-dynamic.h  */
40
41 /* This needs to be big enough to accommodate "struct cursor", while
42    leaving some slack for future expansion.  Changing this value will
43    require recompiling all users of this library.  Stack allocation is
44    relatively cheap and unwind-state copying is relatively rare, so we
45    want to err on making it rather too big than too small.  */
46
47 #define UNW_TDEP_CURSOR_LEN   4096
48
49 /* The size of a "word" varies on TILEGX.  This type is used for memory
50    addresses and register values. */
51 typedef uint64_t unw_word_t;
52 typedef int64_t unw_sword_t;
53
54 typedef long double unw_tdep_fpreg_t;
55
56 typedef enum
57 {
58   UNW_TILEGX_R0,
59   UNW_TILEGX_R1,
60   UNW_TILEGX_R2,
61   UNW_TILEGX_R3,
62   UNW_TILEGX_R4,
63   UNW_TILEGX_R5,
64   UNW_TILEGX_R6,
65   UNW_TILEGX_R7,
66   UNW_TILEGX_R8,
67   UNW_TILEGX_R9,
68   UNW_TILEGX_R10,
69   UNW_TILEGX_R11,
70   UNW_TILEGX_R12,
71   UNW_TILEGX_R13,
72   UNW_TILEGX_R14,
73   UNW_TILEGX_R15,
74   UNW_TILEGX_R16,
75   UNW_TILEGX_R17,
76   UNW_TILEGX_R18,
77   UNW_TILEGX_R19,
78   UNW_TILEGX_R20,
79   UNW_TILEGX_R21,
80   UNW_TILEGX_R22,
81   UNW_TILEGX_R23,
82   UNW_TILEGX_R24,
83   UNW_TILEGX_R25,
84   UNW_TILEGX_R26,
85   UNW_TILEGX_R27,
86   UNW_TILEGX_R28,
87   UNW_TILEGX_R29,
88   UNW_TILEGX_R30,
89   UNW_TILEGX_R31,
90   UNW_TILEGX_R32,
91   UNW_TILEGX_R33,
92   UNW_TILEGX_R34,
93   UNW_TILEGX_R35,
94   UNW_TILEGX_R36,
95   UNW_TILEGX_R37,
96   UNW_TILEGX_R38,
97   UNW_TILEGX_R39,
98   UNW_TILEGX_R40,
99   UNW_TILEGX_R41,
100   UNW_TILEGX_R42,
101   UNW_TILEGX_R43,
102   UNW_TILEGX_R44,
103   UNW_TILEGX_R45,
104   UNW_TILEGX_R46,
105   UNW_TILEGX_R47,
106   UNW_TILEGX_R48,
107   UNW_TILEGX_R49,
108   UNW_TILEGX_R50,
109   UNW_TILEGX_R51,
110   UNW_TILEGX_R52,
111   UNW_TILEGX_R53,
112   UNW_TILEGX_R54,
113   UNW_TILEGX_R55,
114
115   /* FIXME: Other registers!  */
116
117   UNW_TILEGX_PC,
118   /* For TILEGX, the CFA is the value of SP (r54) at the call site in the
119      previous frame.  */
120   UNW_TILEGX_CFA,
121
122   UNW_TDEP_LAST_REG = UNW_TILEGX_PC,
123
124   UNW_TDEP_IP = UNW_TILEGX_R55,  /* R55 is link register for Tilegx */
125   UNW_TDEP_SP = UNW_TILEGX_R54,
126   UNW_TDEP_EH = UNW_TILEGX_R0   /* FIXME.  */
127 } tilegx_regnum_t;
128
129 typedef enum
130 {
131   UNW_TILEGX_ABI_N64 = 2
132 } tilegx_abi_t;
133
134 #define UNW_TDEP_NUM_EH_REGS    2   /* FIXME for TILEGX.  */
135
136 typedef struct unw_tdep_save_loc
137 {
138   /* Additional target-dependent info on a save location.  */
139 } unw_tdep_save_loc_t;
140
141 typedef ucontext_t unw_tdep_context_t;
142
143 #include "libunwind-dynamic.h"
144
145 typedef struct
146 {
147     /* no tilegx-specific auxiliary proc-info */
148 } unw_tdep_proc_info_t;
149
150 #include "libunwind-common.h"
151
152 #define unw_tdep_getcontext  getcontext
153
154 #define unw_tdep_is_fpreg    UNW_ARCH_OBJ(is_fpreg)
155 extern int unw_tdep_is_fpreg (int);
156
157 #if defined(__cplusplus) || defined(c_plusplus)
158 }
159 #endif
160
161 #endif /* LIBUNWIND_H */