summaryrefslogtreecommitdiffstats
path: root/tools/perf/util
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util')
-rw-r--r--tools/perf/util/c++/clang-test.cpp17
-rw-r--r--tools/perf/util/util-cxx.h26
2 files changed, 40 insertions, 3 deletions
diff --git a/tools/perf/util/c++/clang-test.cpp b/tools/perf/util/c++/clang-test.cpp
index 0f484fb..d84e760 100644
--- a/tools/perf/util/c++/clang-test.cpp
+++ b/tools/perf/util/c++/clang-test.cpp
@@ -3,6 +3,10 @@
#include "llvm/IR/Function.h"
#include "llvm/IR/LLVMContext.h"
+#include <util-cxx.h>
+#include <tests/llvm.h>
+#include <string>
+
class perf_clang_scope {
public:
explicit perf_clang_scope() {perf_clang__init();}
@@ -14,17 +18,24 @@ extern "C" {
int test__clang_to_IR(void)
{
perf_clang_scope _scope;
+ unsigned int kernel_version;
+
+ if (fetch_kernel_version(&kernel_version, NULL, 0))
+ return -1;
+
+ std::string cflag_kver("-DLINUX_VERSION_CODE=" +
+ std::to_string(kernel_version));
std::unique_ptr<llvm::Module> M =
- perf::getModuleFromSource({"-DRESULT=1"},
+ perf::getModuleFromSource({cflag_kver.c_str()},
"perf-test.c",
- "int myfunc(void) {return RESULT;}");
+ test_llvm__bpf_base_prog);
if (!M)
return -1;
for (llvm::Function& F : *M)
- if (F.getName() == "myfunc")
+ if (F.getName() == "bpf_func__SyS_epoll_wait")
return 0;
return -1;
}
diff --git a/tools/perf/util/util-cxx.h b/tools/perf/util/util-cxx.h
new file mode 100644
index 0000000..0e0e019
--- /dev/null
+++ b/tools/perf/util/util-cxx.h
@@ -0,0 +1,26 @@
+/*
+ * Support C++ source use utilities defined in util.h
+ */
+
+#ifndef PERF_UTIL_UTIL_CXX_H
+#define PERF_UTIL_UTIL_CXX_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Now 'new' is the only C++ keyword found in util.h:
+ * in tools/include/linux/rbtree.h
+ *
+ * Other keywords, like class and delete, should be
+ * redefined if necessary.
+ */
+#define new _new
+#include "util.h"
+#undef new
+
+#ifdef __cplusplus
+}
+#endif
+#endif
OpenPOWER on IntegriCloud