File: core-support.h

package info (click to toggle)
gcc-arm-none-eabi 15%3A14.2.rel1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,099,328 kB
  • sloc: cpp: 3,627,108; ansic: 2,571,498; ada: 834,230; f90: 235,082; makefile: 79,231; asm: 74,984; xml: 51,692; exp: 39,736; sh: 33,298; objc: 15,629; python: 15,069; fortran: 14,429; pascal: 7,003; awk: 5,070; perl: 3,106; ml: 285; lisp: 253; lex: 204; haskell: 135
file content (109 lines) | stat: -rw-r--r-- 2,329 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
struct my_struct {
 int a;
};

union my_union {
 int b;
 int c;
};

typedef struct my_struct named_struct_tdef;
typedef int (*func_tdef)(void *);

typedef struct {
 int d, e;
} *tdef_struct_ptr;

enum my_enum {
 MY_ENUM_VAL1 = 1,
 MY_ENUM_VAL2 = 2,
};
typedef enum { TE1, TE2, TE3 } enum_tdef;

typedef int int_tdef;
typedef void *void_ptr_tdef;
typedef int *restrict restrict_ptr_tdef;
typedef int (*func_tdef)(void *);
typedef char array_tdef[10];

struct my_complex_struct {
 int a;
 int b;
 union {
  int *a;
  struct my_struct *s;
 } c;
};

typedef struct {
  int a;
} anon_struct_tdef;

typedef struct my_struct *struct_ptr_tdef;

enum named_ue64 {
 UE64_VAL1 = 0x1ffffffffULL,
 UE64_VAL2 = 0x01fffffffULL,
 UE64_VAL3 = 0x001ffffffULL,
};

enum named_se64 {
 SE64_VAL1 = 0x1ffffffffLL,
 SE64_VAL2 = 0x01fffffffLL,
 SE64_VAL3 = -1,
};

enum named_ue {
 UE_VAL1 = 0x1ffffff,
 UE_VAL2 = 0x01fffff,
 UE_VAL3 = 0x001ffff,
};

enum named_se {
 SE_VAL1 = 0x1fffffff,
 SE_VAL2 = 0x01ffffff,
 SE_VAL3 = -1,
};


/* BPF specific code */

enum bpf_type_id_kind {
 BPF_TYPE_ID_LOCAL = 0,
 BPF_TYPE_ID_TARGET = 1,
};

enum bpf_type_info_kind {
 BPF_TYPE_EXISTS = 0,
 BPF_TYPE_SIZE = 1,
 BPF_TYPE_MATCHES = 2,
};

enum bpf_enum_value_kind {
 BPF_ENUMVAL_EXISTS = 0,
 BPF_ENUMVAL_VALUE = 1,
};

#define COMPOSE_VAR(t,s) t##s
#define bpf_type1(type, NR) ({ \
	extern  typeof(type) *COMPOSE_VAR(bpf_type_tmp_, NR); \
	COMPOSE_VAR(bpf_type_tmp_, NR); \
})
#define bpf_type(type) bpf_type1(type, __COUNTER__)

#define bpf_core_type_id_local(type)					    \
	__builtin_btf_type_id(*bpf_type(type), BPF_TYPE_ID_LOCAL)
#define bpf_core_type_id_target(type)					    \
	__builtin_btf_type_id(*bpf_type(type), BPF_TYPE_ID_TARGET)

#define bpf_core_type_exists(type)					    \
	__builtin_preserve_type_info(*bpf_type(type), BPF_TYPE_EXISTS)
#define bpf_core_type_matches(type)					    \
	__builtin_preserve_type_info(*bpf_type(type), BPF_TYPE_MATCHES)
#define bpf_core_type_size(type)					    \
	__builtin_preserve_type_info(*bpf_type(type), BPF_TYPE_SIZE)

#define bpf_core_enum_value_exists(enum_type, enum_value)		    \
	__builtin_preserve_enum_value(bpf_type(enum_type), enum_value, BPF_ENUMVAL_EXISTS)
#define bpf_core_enum_value(enum_type, enum_value)			    \
	__builtin_preserve_enum_value(bpf_type(enum_type), enum_value, BPF_ENUMVAL_VALUE)