1diff --git a/lib/sanitizer_common/sanitizer_mac.cpp b/lib/sanitizer_common/sanitizer_mac.cpp
2--- a/lib/sanitizer_common/sanitizer_mac.cpp
3+++ b/lib/sanitizer_common/sanitizer_mac.cpp
4@@ -613,9 +613,15 @@ HandleSignalMode GetHandleSignalMode(int signum) {
5 // Offset example:
6 // XNU 17 -- macOS 10.13 -- iOS 11 -- tvOS 11 -- watchOS 4
7 constexpr u16 GetOSMajorKernelOffset() {
8- if (TARGET_OS_OSX) return 4;
9- if (TARGET_OS_IOS || TARGET_OS_TV) return 6;
10- if (TARGET_OS_WATCH) return 13;
11+#if TARGET_OS_OSX
12+ return 4;
13+#endif
14+#if TARGET_OS_IOS || TARGET_OS_TV
15+ return 6;
16+#endif
17+#if TARGET_OS_WATCH
18+ return 13;
19+#endif
20 }
21
22 using VersStr = char[64];
23@@ -627,13 +633,13 @@ static uptr ApproximateOSVersionViaKernelVersion(VersStr vers) {
24 u16 os_major = kernel_major - offset;
25
26 const char *format = "%d.0";
27- if (TARGET_OS_OSX) {
28- if (os_major >= 16) { // macOS 11+
29- os_major -= 5;
30- } else { // macOS 10.15 and below
31- format = "10.%d";
32- }
33+#if TARGET_OS_OSX
34+ if (os_major >= 16) { // macOS 11+
35+ os_major -= 5;
36+ } else { // macOS 10.15 and below
37+ format = "10.%d";
38 }
39+#endif
40 return internal_snprintf(vers, sizeof(VersStr), format, os_major);
41 }
42
43@@ -681,15 +687,14 @@ void ParseVersion(const char *vers, u16 *major, u16 *minor) {
44 // Aligned versions example:
45 // macOS 10.15 -- iOS 13 -- tvOS 13 -- watchOS 6
46 static void MapToMacos(u16 *major, u16 *minor) {
47- if (TARGET_OS_OSX)
48- return;
49-
50- if (TARGET_OS_IOS || TARGET_OS_TV)
51+#if !TARGET_OS_OSX
52+#if TARGET_OS_IOS || TARGET_OS_TV
53 *major += 2;
54- else if (TARGET_OS_WATCH)
55+#elif TARGET_OS_WATCH
56 *major += 9;
57- else
58+#else
59 UNREACHABLE("unsupported platform");
60+#endif
61
62 if (*major >= 16) { // macOS 11+
63 *major -= 5;
64@@ -697,6 +702,7 @@ static void MapToMacos(u16 *major, u16 *minor) {
65 *minor = *major;
66 *major = 10;
67 }
68+#endif
69 }
70
71 static MacosVersion GetMacosAlignedVersionInternal() {