[PATCH] D102067: [amdgpu-arch] Guard hsa.h with __has_include

Pushpinder Singh via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 10 00:34:04 PDT 2021


This revision was automatically updated to reflect the committed changes.
Closed by commit rGc711aa0f6f9d: [amdgpu-arch] Guard hsa.h with __has_include (authored by pdhaliwal).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102067/new/

https://reviews.llvm.org/D102067

Files:
  clang/tools/amdgpu-arch/AMDGPUArch.cpp


Index: clang/tools/amdgpu-arch/AMDGPUArch.cpp
===================================================================
--- clang/tools/amdgpu-arch/AMDGPUArch.cpp
+++ clang/tools/amdgpu-arch/AMDGPUArch.cpp
@@ -11,7 +11,24 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include <hsa.h>
+#if defined(__has_include)
+#if __has_include("hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa.h"
+#elif __has_include("hsa/hsa.h")
+#define HSA_HEADER_FOUND 1
+#include "hsa/hsa.h"
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+#else
+#define HSA_HEADER_FOUND 0
+#endif
+
+#if !HSA_HEADER_FOUND
+int main() { return 1; }
+#else
+
 #include <string>
 #include <vector>
 
@@ -57,3 +74,5 @@
   hsa_shut_down();
   return 0;
 }
+
+#endif


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102067.343982.patch
Type: text/x-patch
Size: 761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210510/71f36676/attachment.bin>


More information about the cfe-commits mailing list