Skip to content

Commit

Permalink
[BPF][CLANG] Front-end support for __BPF_FEATURE_ARENA_CAST macro
Browse files Browse the repository at this point in the history
`__BPF_FEATURE_ARENA_CAST` macro is defined if compiler supports
emission of `cast_kern` and `cast_user` BPF instructions.
  • Loading branch information
eddyz87 committed Mar 8, 2024
1 parent e8b41ad commit 1b29cfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/lib/Basic/Targets/BPF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro("__BPF_CPU_VERSION__", "0");
return;
}

Builder.defineMacro("__BPF_FEATURE_ARENA_CAST");

if (CPU.empty() || CPU == "generic" || CPU == "v1") {
Builder.defineMacro("__BPF_CPU_VERSION__", "1");
return;
Expand Down
8 changes: 8 additions & 0 deletions clang/test/Preprocessor/bpf-predefined-macros.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ int r;
#ifdef __BPF_FEATURE_ST
int s;
#endif
#ifdef __BPF_FEATURE_ARENA_CAST
int t;
#endif

// CHECK: int b;
// CHECK: int c;
Expand Down Expand Up @@ -90,6 +93,11 @@ int s;
// CPU_V4: int r;
// CPU_V4: int s;

// CPU_V1: int t;
// CPU_V2: int t;
// CPU_V3: int t;
// CPU_V4: int t;

// CPU_GENERIC: int g;

// CPU_PROBE: int f;

0 comments on commit 1b29cfe

Please sign in to comment.