tools/testing/selftests/bpf/progs/btf_dump_test_case_packing.c

Source file repositories/reference/linux-study-clean/tools/testing/selftests/bpf/progs/btf_dump_test_case_packing.c

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/btf_dump_test_case_packing.c
Extension
.c
Size
2732 bytes
Lines
154
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct packed_trailing_space {
	int a;
	short b;
} __attribute__((packed));

struct non_packed_trailing_space {
	int a;
	short b;
};

struct packed_fields {
	short a;
	int b;
} __attribute__((packed));

struct non_packed_fields {
	short a;
	int b;
};

struct nested_packed {
	char: 4;
	int a: 4;
	long b;
	struct {
		char c;
		int d;
	} __attribute__((packed)) e;
} __attribute__((packed));

union union_is_never_packed {
	int a: 4;
	char b;
	char c: 1;
};

union union_does_not_need_packing {
	struct {
		long a;
		int b;
	} __attribute__((packed));
	int c;
};

union jump_code_union {
	char code[5];
	struct {
		char jump;
		int offset;
	} __attribute__((packed));
};

/* ----- START-EXPECTED-OUTPUT ----- */
/*
 *struct nested_packed_but_aligned_struct {
 *	int x1;
 *	int x2;
 *};
 *
 *struct outer_implicitly_packed_struct {
 *	char y1;
 *	struct nested_packed_but_aligned_struct y2;
 *} __attribute__((packed));
 *
 */
/* ------ END-EXPECTED-OUTPUT ------ */

struct nested_packed_but_aligned_struct {
	int x1;
	int x2;
} __attribute__((packed));

struct outer_implicitly_packed_struct {
	char y1;
	struct nested_packed_but_aligned_struct y2;
};
/* ----- START-EXPECTED-OUTPUT ----- */
/*
 *struct usb_ss_ep_comp_descriptor {
 *	char: 8;
 *	char bDescriptorType;
 *	char bMaxBurst;
 *	short wBytesPerInterval;
 *};
 *
 *struct usb_host_endpoint {
 *	long: 64;
 *	char: 8;
 *	struct usb_ss_ep_comp_descriptor ss_ep_comp;
 *	long: 0;

Annotation

Implementation Notes