[compiler-rt] 321a04b - [compiler-rt][hwasan] Check for SANITIZER_POSIX before including sanitizer_posix.h

Leonard Chan via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 29 14:25:22 PDT 2021


Author: Leonard Chan
Date: 2021-07-29T14:21:30-07:00
New Revision: 321a04bf62b247db853d136df43d3cdd58d88c53

URL: https://github.com/llvm/llvm-project/commit/321a04bf62b247db853d136df43d3cdd58d88c53
DIFF: https://github.com/llvm/llvm-project/commit/321a04bf62b247db853d136df43d3cdd58d88c53.diff

LOG: [compiler-rt][hwasan] Check for SANITIZER_POSIX before including sanitizer_posix.h

Rather than throwing an error. This way we can still use files like
hwasan_dynamic_shadow.cpp for other platforms without leading to a
preprocessor error.

Differential Revision: https://reviews.llvm.org/D106979

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_posix.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_posix.h b/compiler-rt/lib/sanitizer_common/sanitizer_posix.h
index b65dae644767..f91e26e74b87 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_posix.h
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_posix.h
@@ -20,10 +20,7 @@
 #include "sanitizer_platform_limits_posix.h"
 #include "sanitizer_platform_limits_solaris.h"
 
-#if !SANITIZER_POSIX
-// Make it hard to accidentally use any of functions declared in this file:
-#error This file should only be included on POSIX
-#endif
+#if SANITIZER_POSIX
 
 namespace __sanitizer {
 
@@ -126,4 +123,6 @@ void DecorateMapping(uptr addr, uptr size, const char *name);
 
 }  // namespace __sanitizer
 
+#endif  // SANITIZER_POSIX
+
 #endif  // SANITIZER_POSIX_H


        


More information about the llvm-commits mailing list