[compiler-rt][Darwin] Fix GetOSMajorKernelOffset() on watchOS
authorJulian Lettner <julian.lettner@apple.com>
Fri, 31 Jul 2020 18:38:10 +0000 (11:38 -0700)
committerJulian Lettner <julian.lettner@apple.com>
Fri, 31 Jul 2020 18:47:09 +0000 (11:47 -0700)
`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.

compiler-rt/lib/sanitizer_common/sanitizer_mac.cpp

index a10ba77..21a9c01 100644 (file)
@@ -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");