Add missing declaration
[ctfdump/.git] / ctf.h
CommitLineData
f8621c6a
MP
1/*
2 * Copyright (c) 2016 Martin Pieuchot <mpi@openbsd.org>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17/*
18 * CTF ``Compact ANSI-C Type Format'' ABI header file.
19 */
20
21struct ctf_header {
22 unsigned short cth_magic;
23 unsigned char cth_version;
24 unsigned char cth_flags;
25 unsigned int cth_parlabel;
26 unsigned int cth_parname;
27 unsigned int cth_lbloff;
28 unsigned int cth_objtoff;
29 unsigned int cth_funcoff;
30 unsigned int cth_typeoff;
31 unsigned int cth_stroff;
32 unsigned int cth_strlen;
33};
34
35#define CTF_F_COMPRESS (1 << 0) /* zlib compression */
36
37struct ctf_lblent {
38 unsigned int ctl_label;
39 unsigned int ctl_typeidx;
40};
41
42struct ctf_stype {
43 unsigned int cts_name;
44 unsigned short cts_info;
45 union {
46 unsigned short _size;
47 unsigned short _type;
48 } _ST;
49#define cts_size _ST._size
50#define cts_type _ST._type
51};
52
74b86e22
MP
53struct ctf_type {
54 struct ctf_stype _ctt_stype;
55#define ctt_name _ctt_stype.cts_name
56#define ctt_info _ctt_stype.cts_info
57#define ctt_size _ctt_stype.cts_size
58#define ctt_type _ctt_stype.cts_type
59 unsigned int ctt_lsizehi;
60 unsigned int ctt_lsizelo;
61};
62
f8621c6a
MP
63struct ctf_array {
64 unsigned short cta_contents;
65 unsigned short cta_index;
66 unsigned int cta_nelems;
67};
68
69struct ctf_member {
70 unsigned int ctm_name;
71 unsigned short ctm_type;
72 unsigned short ctm_offset;
73};
74
75struct ctf_lmember {
76 struct ctf_member _ctlm_member;
77#define ctlm_name _ctlm_member.ctm_name
78#define ctlm_type _ctlm_member.ctlm_type
79#define ctlm_pad0 _ctlm_member.ctm_offset
80 unsigned int ctlm_offsethi;
81 unsigned int ctlm_offsetlo;
82};
83
84#define CTF_LSTRUCT_THRESH 8192
85
86struct ctf_enum {
87 unsigned int cte_name;
88 int cte_value;
89};
90
91#define CTF_MAGIC 0xcff1
92#define CTF_VERSION 2
93
94#define CTF_MAX_NAME 0x7fffffff
acada86d 95#define CTF_MAX_VLEN 0x03ff
74b86e22 96#define CTF_MAX_SIZE 0xfffe
acada86d 97
f8621c6a
MP
98#define CTF_STRTAB_0 0
99#define CTF_STRTAB_1 1
100
acada86d
MP
101/*
102 * Info macro.
103 */
104#define CTF_INFO_VLEN(i) (((i) & CTF_MAX_VLEN))
105#define CTF_INFO_ISROOT(i) (((i) & 0x0400) >> 10)
106#define CTF_INFO_KIND(i) (((i) & 0xf800) >> 11)
107#define CTF_K_UNKNOWN 0
108#define CTF_K_INTEGER 1
109#define CTF_K_FLOAT 2
110#define CTF_K_POINTER 3
111#define CTF_K_ARRAY 4
112#define CTF_K_FUNCTION 5
113#define CTF_K_STRUCT 6
114#define CTF_K_UNION 7
115#define CTF_K_ENUM 8
116#define CTF_K_FORWARD 9
117#define CTF_K_TYPEDEF 10
118#define CTF_K_VOLATILE 11
119#define CTF_K_CONST 12
120#define CTF_K_RESTRICT 13
121#define CTF_K_MAX 31
122
f8621c6a
MP
123/*
124 * Name reference macro.
125 */
126#define CTF_NAME_STID(n) ((n) >> 31)
127#define CTF_NAME_OFFSET(n) ((n) & CTF_MAX_NAME)
74b86e22
MP
128
129/*
130 * Type macro.
131 */
132#define CTF_SIZE_TO_LSIZE_HI(s) ((uint32_t)((uint64_t)(s) >> 32))
133#define CTF_SIZE_TO_LSIZE_LO(s) ((uint32_t)(s))
134#define CTF_TYPE_LSIZE(t) \
135 (((uint64_t)(t)->ctt_lsizehi) << 32 | (t)->ctt_lsizelo)