Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/Basic/Targets/BPF.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,
}

Builder.defineMacro("__BPF_FEATURE_ADDR_SPACE_CAST");
Builder.defineMacro("__BPF_FEATURE_MAY_GOTO");

if (CPU.empty())
CPU = "v3";
Expand All @@ -48,7 +49,6 @@ void BPFTargetInfo::getTargetDefines(const LangOptions &Opts,

std::string CpuVerNumStr = CPU.substr(1);
Builder.defineMacro("__BPF_CPU_VERSION__", CpuVerNumStr);
Builder.defineMacro("__BPF_FEATURE_MAY_GOTO");

int CpuVerNum = std::stoi(CpuVerNumStr);
if (CpuVerNum >= 2)
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 @@ -64,6 +64,9 @@ int s;
#ifdef __BPF_FEATURE_ADDR_SPACE_CAST
int t;
#endif
#ifdef __BPF_FEATURE_MAY_GOTO
int u;
#endif

// CHECK: int b;
// CHECK: int c;
Expand Down Expand Up @@ -98,6 +101,11 @@ int t;
// CPU_V3: int t;
// CPU_V4: int t;

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

// CPU_GENERIC: int g;

// CPU_PROBE: int f;
Loading