[compiler-rt] 43bf902 - [compiler-rt][Darwin] Fix GetOSMajorKernelOffset() on watchOS

Julian Lettner via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 11:47:57 PDT 2020


Author: Julian Lettner
Date: 2020-07-31T11:47:09-07:00
New Revision: 43bf902c2e3416179cf41eba9307fc74bcba0ecd

URL: https://github.com/llvm/llvm-project/commit/43bf902c2e3416179cf41eba9307fc74bcba0ecd
DIFF: https://github.com/llvm/llvm-project/commit/43bf902c2e3416179cf41eba9307fc74bcba0ecd.diff

LOG: [compiler-rt][Darwin] Fix GetOSMajorKernelOffset() on watchOS

`TARGET_OS_IOS` and `TARGET_OS_WATCH` are not mutually exclusive.
`SANITIZER_IOS` is defined for all embedded platforms.  So the branch
for watchOS is never taken.  We could fix this by switching the order
of the branches (but the reason for doing so is non-obvious).  Instead,
lets use the Darwin-specific `TARGET_OS_*` macros which are mutually
exclusive.

Added: 
    

Modified: 
    compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
index a10ba774b955..21a9c01bf2a9 100644
--- a/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
+++ b/compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp
@@ -610,8 +610,8 @@ HandleSignalMode GetHandleSignalMode(int signum) {
 // XNU 17 -- macOS 10.13 -- iOS 11 -- tvOS 11 -- watchOS 4
 constexpr u16 GetOSMajorKernelOffset() {
   if (TARGET_OS_OSX) return 4;
-  if (SANITIZER_IOS || SANITIZER_TVOS) return 6;
-  if (SANITIZER_WATCHOS) return 13;
+  if (TARGET_OS_IOS || TARGET_OS_TV) return 6;
+  if (TARGET_OS_WATCH) return 13;
 }
 
 using VersStr = char[64];
@@ -661,9 +661,9 @@ static void MapToMacos(u16 *major, u16 *minor) {
   if (TARGET_OS_OSX)
     return;
 
-  if (SANITIZER_IOS || SANITIZER_TVOS)
+  if (TARGET_OS_IOS || TARGET_OS_TV)
     *major += 2;
-  else if (SANITIZER_WATCHOS)
+  else if (TARGET_OS_WATCH)
     *major += 9;
   else
     UNREACHABLE("unsupported platform");


        


More information about the llvm-commits mailing list