introduce isBpfSupported() helper

Test: build, atest
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: I9e2a7e049746ad193eea01e7c9d6786d27728c72
diff --git a/bpfloader/BpfLoader.cpp b/bpfloader/BpfLoader.cpp
index ac59a24..5390fb4 100644
--- a/bpfloader/BpfLoader.cpp
+++ b/bpfloader/BpfLoader.cpp
@@ -72,7 +72,7 @@
 }
 
 int main() {
-    if (android::bpf::getBpfSupportLevel() != android::bpf::BpfLevel::NONE) {
+    if (android::bpf::isBpfSupported()) {
         // Load all ELF objects, create programs and maps, and pin them
         loadAllElfObjects();
     }
diff --git a/libbpf_android/include/bpf/BpfUtils.h b/libbpf_android/include/bpf/BpfUtils.h
index dc56277..92cfa50 100644
--- a/libbpf_android/include/bpf/BpfUtils.h
+++ b/libbpf_android/include/bpf/BpfUtils.h
@@ -144,22 +144,26 @@
 }
 
 uint64_t getSocketCookie(int sockFd);
+int synchronizeKernelRCU();
 int setrlimitForTest();
 std::string BpfLevelToString(BpfLevel BpfLevel);
 BpfLevel getBpfSupportLevel();
-int synchronizeKernelRCU();
+
+static inline bool isBpfSupported() {
+    return getBpfSupportLevel() != BpfLevel::NONE;
+}
 
 #define SKIP_IF_BPF_NOT_SUPPORTED                                                    \
     do {                                                                             \
-        if (android::bpf::getBpfSupportLevel() == android::bpf::BpfLevel::NONE) {    \
+        if (!android::bpf::isBpfSupported()) {                                       \
             GTEST_LOG_(INFO) << "This test is skipped since bpf is not available\n"; \
             return;                                                                  \
         }                                                                            \
     } while (0)
 
-#define SKIP_IF_BPF_SUPPORTED                                                           \
-    do {                                                                                \
-        if (android::bpf::getBpfSupportLevel() != android::bpf::BpfLevel::NONE) return; \
+#define SKIP_IF_BPF_SUPPORTED                       \
+    do {                                            \
+        if (android::bpf::isBpfSupported()) return; \
     } while (0)
 
 }  // namespace bpf