feature. See also
. The project being documented here (as the example) is the Zig library itself.
File
Code
const std = @import("../../../std.zig");
pub const magic = 0xeb9f;
pub const version = 1;
pub const ext = @import("btf_ext.zig");
pub const Header = extern struct {
magic: u16,
version: u8,
flags: u8,
hdr_len: u32,
type_off: u32,
type_len: u32,
str_off: u32,
str_len: u32,
};
pub const max_type = 0xfffff;
pub const max_name_offset = 0xffffff;
pub const max_vlen = 0xffff;
pub const Type = extern struct {
name_off: u32,
info: packed struct(u32) {
vlen: u16,
unused_1: u8,
kind: Kind,
unused_2: u2,
kind_flag: bool,
},
size_type: extern union { size: u32, typ: u32 },
};
pub const Kind = enum(u5) {
unknown,
int,
ptr,
array,
@"struct",
@"union",
@"enum",
fwd,
typedef,
@"volatile",
@"const",
restrict,
func,
func_proto,
@"var",
datasec,
float,
decl_tag,
type_tag,
enum64,
};
pub const IntInfo = packed struct(u32) {
bits: u8,
reserved_1: u8,
offset: u8,
encoding: enum(u4) {
signed = 1 << 0,
char = 1 << 1,
boolean = 1 << 2,
},
reserved_2: u4,
};
test "IntInfo is 32 bits" {
try std.testing.expectEqual(@bitSizeOf(IntInfo), 32);
}
pub const Enum = extern struct {
name_off: u32,
val: i32,
};
pub const Enum64 = extern struct {
name_off: u32,
val_lo32: i32,
val_hi32: i32,
};
pub const Array = extern struct {
typ: u32,
index_type: u32,
nelems: u32,
};
pub const Member = extern struct {
name_off: u32,
typ: u32,
offset: packed struct(u32) {
bit: u24,
bitfield_size: u8,
},
};
pub const Param = extern struct {
name_off: u32,
typ: u32,
};
pub const VarLinkage = enum {
static,
global_allocated,
global_extern,
};
pub const FuncLinkage = enum {
static,
global,
external,
};
pub const Var = extern struct {
linkage: u32,
};
pub const VarSecInfo = extern struct {
typ: u32,
offset: u32,
size: u32,
};
// additional information related to the tag applied location.
// If component_idx == -1, the tag is applied to a struct, union,
// variable or function. Otherwise, it is applied to a struct/union
// member or a func argument, and component_idx indicates which member
// or argument (0 ... vlen-1).
pub const DeclTag = extern struct {
component_idx: u32,
};