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

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

File Facts

System
Linux kernel
Corpus path
tools/testing/selftests/bpf/progs/set_global_vars.c
Extension
.c
Size
2139 bytes
Lines
107
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 Struct {
	int:16;
	__u16 filler;
	struct {
		const __u16 filler2;
	};
	struct Struct2 {
		__u16 filler;
		volatile struct {
			const int:1;
			union {
				const volatile u8 var_u8[3];
				const volatile __s16 filler3;
				const int:1;
				s32 mat[7][5];
			} u;
		};
	} struct2[2][4];
};

const volatile __u32 stru = 0; /* same prefix as below */
const volatile struct Struct struct1[3];
const volatile struct Struct struct11[11][7];

struct Struct3 {
	struct {
		u8 var_u8_l;
	};
	struct {
		struct {
			u8 var_u8_h;
		};
	};
};

typedef struct Struct3 Struct3_t;

union Union {
	__u16 var_u16;
	Struct3_t struct3;
};

const volatile union Union union1 = {.var_u16 = -1};

SEC("socket")
int test_set_globals(void *ctx)
{
	volatile __s8 a;

	a = var_s64;
	a = var_u64;
	a = var_s32;
	a = var_u32;
	a = var_s16;
	a = var_u16;
	a = var_s8;
	a = var_u8;
	a = var_ea;
	a = var_eb;
	a = var_ec;
	a = var_b;
	a = struct1[2].struct2[1][2].u.var_u8[2];
	a = union1.var_u16;
	a = arr[3];
	a = arr[EA2];
	a = enum_arr[EC2];
	a = three_d[31][7][EA2];
	a = struct1[2].struct2[1][2].u.mat[5][3];
	a = struct11[7][5].struct2[0][1].u.mat[3][0];

	return a;
}

Annotation

Implementation Notes