diff --git a/compat/BUILD.gn b/compat/BUILD.gn index 2436b846..a38724c7 100644 --- a/compat/BUILD.gn +++ b/compat/BUILD.gn @@ -57,7 +57,7 @@ template("compat_target") { # static_library. group(target_name) { forward_variables_from(invoker, "*") - not_needed(["configs"]) + not_needed([ "configs" ]) } } else { static_library(target_name) { @@ -71,7 +71,8 @@ compat_target("compat") { if (crashpad_is_mac || crashpad_is_ios) { sources += [ - "mac/AvailabilityMacros.h", + "mac/Availability.h", + "mac/AvailabilityVersions.h", "mac/kern/exc_resource.h", "mac/mach-o/loader.h", "mac/mach/i386/thread_state.h", diff --git a/compat/compat.gyp b/compat/compat.gyp index b99d6905..1c2eeaf4 100644 --- a/compat/compat.gyp +++ b/compat/compat.gyp @@ -38,7 +38,8 @@ 'linux/signal.h', 'linux/sys/ptrace.h', 'linux/sys/user.h', - 'mac/AvailabilityMacros.h', + 'mac/Availability.h', + 'mac/AvailabilityVersions.h', 'mac/kern/exc_resource.h', 'mac/mach/i386/thread_state.h', 'mac/mach/mach.h', diff --git a/compat/mac/Availability.h b/compat/mac/Availability.h new file mode 100644 index 00000000..b8f8f2d6 --- /dev/null +++ b/compat/mac/Availability.h @@ -0,0 +1,28 @@ +// Copyright 2020 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CRASHPAD_COMPAT_MAC_AVAILABILITY_H_ +#define CRASHPAD_COMPAT_MAC_AVAILABILITY_H_ + +// Until the 10.15 SDK, the contents of was in-line in +// , but since then, it was broken out into its own header. +// This compat version of allows these macros to always appear +// to be provided by the new header, , even when an +// older SDK is in use. + +#include_next + +#include + +#endif // CRASHPAD_COMPAT_MAC_AVAILABILITY_H_ diff --git a/compat/mac/AvailabilityMacros.h b/compat/mac/AvailabilityMacros.h deleted file mode 100644 index a83d2a42..00000000 --- a/compat/mac/AvailabilityMacros.h +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright 2014 The Crashpad Authors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef CRASHPAD_COMPAT_MAC_AVAILABILITYMACROS_H_ -#define CRASHPAD_COMPAT_MAC_AVAILABILITYMACROS_H_ - -#include_next - -// 10.7 SDK - -#ifndef MAC_OS_X_VERSION_10_7 -#define MAC_OS_X_VERSION_10_7 1070 -#endif - -// 10.8 SDK - -#ifndef MAC_OS_X_VERSION_10_8 -#define MAC_OS_X_VERSION_10_8 1080 -#endif - -// 10.9 SDK - -#ifndef MAC_OS_X_VERSION_10_9 -#define MAC_OS_X_VERSION_10_9 1090 -#endif - -// 10.10 SDK - -#ifndef MAC_OS_X_VERSION_10_10 -#define MAC_OS_X_VERSION_10_10 101000 -#endif - -// 10.11 SDK - -#ifndef MAC_OS_X_VERSION_10_11 -#define MAC_OS_X_VERSION_10_11 101100 -#endif - -// 10.12 SDK - -#ifndef MAC_OS_X_VERSION_10_12 -#define MAC_OS_X_VERSION_10_12 101200 -#endif - -// 10.13 SDK - -#ifndef MAC_OS_X_VERSION_10_13 -#define MAC_OS_X_VERSION_10_13 101300 -#endif - -// 10.14 SDK - -#ifndef MAC_OS_X_VERSION_10_14 -#define MAC_OS_X_VERSION_10_14 101400 -#endif - -// 10.15 SDK - -#ifndef MAC_OS_X_VERSION_10_15 -#define MAC_OS_X_VERSION_10_15 101500 -#endif - -#endif // CRASHPAD_COMPAT_MAC_AVAILABILITYMACROS_H_ diff --git a/compat/mac/AvailabilityVersions.h b/compat/mac/AvailabilityVersions.h new file mode 100644 index 00000000..8e932c57 --- /dev/null +++ b/compat/mac/AvailabilityVersions.h @@ -0,0 +1,86 @@ +// Copyright 2020 The Crashpad Authors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef CRASHPAD_COMPAT_MAC_AVAILABILITYVERSIONS_H_ +#define CRASHPAD_COMPAT_MAC_AVAILABILITYVERSIONS_H_ + +#if __has_include_next() +#include_next +#endif + +// 10.7 SDK + +#ifndef __MAC_10_7 +#define __MAC_10_7 1070 +#endif + +// 10.8 SDK + +#ifndef __MAC_10_8 +#define __MAC_10_8 1080 +#endif + +// 10.9 SDK + +#ifndef __MAC_10_9 +#define __MAC_10_9 1090 +#endif + +// 10.10 SDK + +#ifndef __MAC_10_10 +#define __MAC_10_10 101000 +#endif + +// 10.11 SDK + +#ifndef __MAC_10_11 +#define __MAC_10_11 101100 +#endif + +// 10.12 SDK + +#ifndef __MAC_10_12 +#define __MAC_10_12 101200 +#endif + +// 10.13 SDK + +#ifndef __MAC_10_13 +#define __MAC_10_13 101300 +#endif + +// 10.14 SDK + +#ifndef __MAC_10_14 +#define __MAC_10_14 101400 +#endif + +// 10.15 SDK + +#ifndef __MAC_10_15 +#define __MAC_10_15 101500 +#endif + +// 11.0 SDK + +#ifndef __MAC_10_16 +#define __MAC_10_16 101600 +#endif + +#ifndef __MAC_11_0 +#define __MAC_11_0 110000 +#endif + +#endif // CRASHPAD_COMPAT_MAC_AVAILABILITYVERSIONS_H_ diff --git a/minidump/minidump_misc_info_writer.cc b/minidump/minidump_misc_info_writer.cc index d2d85115..13435604 100644 --- a/minidump/minidump_misc_info_writer.cc +++ b/minidump/minidump_misc_info_writer.cc @@ -31,7 +31,7 @@ #include "util/numeric/safe_assignment.h" #if defined(OS_APPLE) -#include +#include #elif defined(OS_ANDROID) #include #endif @@ -66,20 +66,19 @@ std::string BuildString(const SystemSnapshot* system_snapshot) { return machine_description; } -#if defined(OS_APPLE) -// Converts the value of the MAC_OS_VERSION_MIN_REQUIRED or -// MAC_OS_X_VERSION_MAX_ALLOWED macro from to a number +#if defined(OS_MAC) +// Converts the value of the __MAC_OS_X_VERSION_MIN_REQUIRED or +// __MAC_OS_X_VERSION_MAX_ALLOWED macro from to a number // identifying the minor macOS version that it represents. For example, with an -// argument of MAC_OS_X_VERSION_10_6, this function will return 6. +// argument of __MAC_10_6, this function will return 6. int AvailabilityVersionToMacOSXMinorVersion(int availability) { - // Through MAC_OS_X_VERSION_10_9, the minor version is the tens digit. + // Through __MAC_10_9, the minor version is the tens digit. if (availability >= 1000 && availability <= 1099) { return (availability / 10) % 10; } - // After MAC_OS_X_VERSION_10_9, the older format was insufficient to represent - // versions. Since then, the minor version is the thousands and hundreds - // digits. + // After __MAC_10_9, the older format was insufficient to represent versions. + // Since then, the minor version is the thousands and hundreds digits. if (availability >= 100000 && availability <= 109999) { return (availability / 100) % 100; } @@ -136,11 +135,11 @@ std::string MinidumpMiscInfoDebugBuildString() { PACKAGE_VERSION, kOS); -#if defined(OS_APPLE) +#if defined(OS_MAC) debug_build_string += base::StringPrintf( ",%d,%d", - AvailabilityVersionToMacOSXMinorVersion(MAC_OS_X_VERSION_MIN_REQUIRED), - AvailabilityVersionToMacOSXMinorVersion(MAC_OS_X_VERSION_MAX_ALLOWED)); + AvailabilityVersionToMacOSXMinorVersion(__MAC_OS_X_VERSION_MIN_REQUIRED), + AvailabilityVersionToMacOSXMinorVersion(__MAC_OS_X_VERSION_MAX_ALLOWED)); #elif defined(OS_ANDROID) debug_build_string += base::StringPrintf(",%d", __ANDROID_API__); #endif diff --git a/snapshot/mac/mach_o_image_reader_test.cc b/snapshot/mac/mach_o_image_reader_test.cc index 53826bfc..f1f3b1de 100644 --- a/snapshot/mac/mach_o_image_reader_test.cc +++ b/snapshot/mac/mach_o_image_reader_test.cc @@ -14,7 +14,7 @@ #include "snapshot/mac/mach_o_image_reader.h" -#include +#include #include #include #include @@ -606,7 +606,7 @@ TEST(MachOImageReader, Self_DyldImages) { ASSERT_NO_FATAL_FAILURE(ExpectSymbolTable(mach_header, &image_reader)); } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7 // If dyld is new enough to record UUIDs, check the UUID of any module that // it says has one. Note that dyld doesn’t record UUIDs of anything that // loaded out of the shared cache, but it should at least have a UUID for the diff --git a/snapshot/mac/process_reader_mac.cc b/snapshot/mac/process_reader_mac.cc index ca2c1f7b..fafa615c 100644 --- a/snapshot/mac/process_reader_mac.cc +++ b/snapshot/mac/process_reader_mac.cc @@ -14,7 +14,7 @@ #include "snapshot/mac/process_reader_mac.h" -#include +#include #include #include @@ -213,7 +213,7 @@ mach_vm_address_t ProcessReaderMac::DyldAllImageInfo( // This may look for the module that matches the executable path in the same // data set that vmmap uses. -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7 // The task_dyld_info_data_t struct grew in 10.7, adding the format field. // Don’t check this field if it’s not present, which can happen when either // the SDK used at compile time or the kernel at run time are too old and diff --git a/snapshot/mac/process_reader_mac_test.cc b/snapshot/mac/process_reader_mac_test.cc index 2d64ff10..32332287 100644 --- a/snapshot/mac/process_reader_mac_test.cc +++ b/snapshot/mac/process_reader_mac_test.cc @@ -14,9 +14,9 @@ #include "snapshot/mac/process_reader_mac.h" -#include -#include +#include #include +#include #include #include #include @@ -569,12 +569,12 @@ class ScopedOpenCLNoOpKernel { cl_int rv = clGetPlatformIDs(1, &platform_id, nullptr); ASSERT_EQ(rv, CL_SUCCESS) << "clGetPlatformIDs"; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_10 && \ - MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_10 -// cl_device_id is really available in OpenCL.framework back to 10.5, but in -// the 10.10 SDK and later, OpenCL.framework includes , -// which has its own cl_device_id that was introduced in 10.10. That -// triggers erroneous availability warnings. +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_10 && \ + __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_10 + // cl_device_id is really available in OpenCL.framework back to 10.5, but in + // the 10.10 SDK and later, OpenCL.framework includes , + // which has its own cl_device_id that was introduced in 10.10. That + // triggers erroneous availability warnings. #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunguarded-availability" #define DISABLED_WUNGUARDED_AVAILABILITY @@ -640,7 +640,7 @@ class ScopedOpenCLNoOpKernel { // OpenCL kernels that run on the CPU do not result in cl_kernels images // appearing on that OS version. bool ExpectCLKernels() { -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7 return true; #else return MacOSXMinorVersion() >= 7; diff --git a/snapshot/mac/process_types_test.cc b/snapshot/mac/process_types_test.cc index 0ad28697..5e5ebf18 100644 --- a/snapshot/mac/process_types_test.cc +++ b/snapshot/mac/process_types_test.cc @@ -14,7 +14,7 @@ #include "snapshot/mac/process_types.h" -#include +#include #include #include @@ -68,7 +68,7 @@ TEST(ProcessTypes, DyldImagesSelf) { if (self_image_infos->version >= 2) { EXPECT_TRUE(self_image_infos->libSystemInitialized); } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7 if (self_image_infos->version >= 9) { EXPECT_EQ(self_image_infos->dyldAllImageInfosAddress, self_image_infos); } @@ -90,7 +90,7 @@ TEST(ProcessTypes, DyldImagesSelf) { // This field is only present in the OS X 10.7 SDK (at build time) and kernel // (at run time). -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7 if (MacOSXMinorVersion() >= 7) { #if !defined(ARCH_CPU_64_BITS) EXPECT_EQ(dyld_info.all_image_info_format, TASK_DYLD_ALL_IMAGE_INFO_32); @@ -103,15 +103,15 @@ TEST(ProcessTypes, DyldImagesSelf) { ProcessReaderMac process_reader; ASSERT_TRUE(process_reader.Initialize(mach_task_self())); -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_15 constexpr uint32_t kDyldAllImageInfosVersionInSDK = 16; -#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 +#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12 constexpr uint32_t kDyldAllImageInfosVersionInSDK = 15; -#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 +#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9 constexpr uint32_t kDyldAllImageInfosVersionInSDK = 14; -#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7 constexpr uint32_t kDyldAllImageInfosVersionInSDK = 12; -#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 +#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_6 constexpr uint32_t kDyldAllImageInfosVersionInSDK = 7; #else constexpr uint32_t kDyldAllImageInfosVersionInSDK = 1; @@ -126,11 +126,11 @@ TEST(ProcessTypes, DyldImagesSelf) { // test can only be performed if the run-time OS natively uses the same format // structure as the SDK. bool test_expected_size_for_version_matches_sdk_sizeof; -#if MAC_OS_X_VERSION_MAX_ALLOWED == MAC_OS_X_VERSION_10_12 +#if __MAC_OS_X_VERSION_MAX_ALLOWED == __MAC_10_12 test_expected_size_for_version_matches_sdk_sizeof = mac_os_x_minor_version == 12; -#elif MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13 && \ - MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_15 +#elif __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_13 && \ + __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_15 test_expected_size_for_version_matches_sdk_sizeof = mac_os_x_minor_version >= 13 && mac_os_x_minor_version <= 14; #else @@ -257,7 +257,7 @@ TEST(ProcessTypes, DyldImagesSelf) { EXPECT_EQ(proctype_image_infos.systemOrderFlag, implicit_cast(self_image_infos->systemOrderFlag)); } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7 if (proctype_image_infos.version >= 8) { EXPECT_EQ(proctype_image_infos.uuidArrayCount, implicit_cast(self_image_infos->uuidArrayCount)); @@ -299,7 +299,7 @@ TEST(ProcessTypes, DyldImagesSelf) { implicit_cast(self_image_infos->sharedCacheSlide)); } #endif -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9 if (proctype_image_infos.version >= 13) { EXPECT_EQ(memcmp(self_image_infos->sharedCacheUUID, proctype_image_infos.sharedCacheUUID, @@ -307,7 +307,7 @@ TEST(ProcessTypes, DyldImagesSelf) { 0); } #endif -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12 if (proctype_image_infos.version >= 15) { EXPECT_EQ(proctype_image_infos.infoArrayChangeTimestamp, self_image_infos->infoArrayChangeTimestamp); @@ -327,7 +327,7 @@ TEST(ProcessTypes, DyldImagesSelf) { } #endif -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_12 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_12 // As dyld_all_image_infos has evolved over time, new fields were added to the // reserved region. process_types::dyld_all_image_infos declares a recent // version of the structure, but an older SDK may declare an older version @@ -352,7 +352,7 @@ TEST(ProcessTypes, DyldImagesSelf) { } #endif -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_13 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_13 if (proctype_image_infos.version >= 15 && mac_os_x_minor_version >= 13) { EXPECT_EQ(proctype_image_infos.compact_dyld_image_info_addr, self_image_infos->compact_dyld_image_info_addr); @@ -361,7 +361,7 @@ TEST(ProcessTypes, DyldImagesSelf) { } #endif -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_15 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_15 if (proctype_image_infos.version >= 16) { EXPECT_EQ(proctype_image_infos.platform, self_image_infos->platform); } @@ -399,7 +399,7 @@ TEST(ProcessTypes, DyldImagesSelf) { } } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7 if (proctype_image_infos.version >= 8) { std::vector proctype_uuid_info_vector( proctype_image_infos.uuidArrayCount); diff --git a/snapshot/mac/system_snapshot_mac.cc b/snapshot/mac/system_snapshot_mac.cc index 62eb814c..e3bfc1ca 100644 --- a/snapshot/mac/system_snapshot_mac.cc +++ b/snapshot/mac/system_snapshot_mac.cc @@ -14,7 +14,7 @@ #include "snapshot/mac/system_snapshot_mac.h" -#include +#include #include #include #include @@ -364,7 +364,7 @@ bool SystemSnapshotMac::NXEnabled() const { // xnu-6153.11.26/bsd/kern/kern_sysctl.c (10.14.4 and 10.14.5 xnu source // are not yet available). In newer production kernels, NX is always // enabled. See 10.15.0 xnu-6153.11.26/osfmk/x86_64/pmap.c nx_enabled. -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_14 +#if __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_14 const bool nx_always_enabled = true; #else // DT >= 10.14 base::ScopedClearLastError reset_errno; diff --git a/test/mac/dyld.cc b/test/mac/dyld.cc index fb2156ed..ba1cb56f 100644 --- a/test/mac/dyld.cc +++ b/test/mac/dyld.cc @@ -14,10 +14,10 @@ #include "test/mac/dyld.h" -#include +#include #include -#include #include +#include #include #include "base/logging.h" @@ -25,7 +25,7 @@ #include "test/scoped_module_handle.h" #include "util/numeric/safe_assignment.h" -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13 +#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_13 extern "C" { // A non-public dyld API, declared in 10.12.4 @@ -41,14 +41,14 @@ namespace crashpad { namespace test { const dyld_all_image_infos* DyldGetAllImageInfos() { -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13 +#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_13 // When building with the pre-10.13 SDK, the weak_import declaration above is // available and a symbol will be present in the SDK to link against. If the // old interface is also available at run time (running on pre-10.13), use it. if (_dyld_get_all_image_infos) { return _dyld_get_all_image_infos(); } -#elif MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_13 +#elif __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_13 // When building with the 10.13 SDK or later, but able to run on pre-10.13, // look for _dyld_get_all_image_infos in the same module that provides // _dyld_image_count. There’s no symbol in the SDK to link against, so this is diff --git a/test/mac/mach_multiprocess.cc b/test/mac/mach_multiprocess.cc index eaa6a174..01b242a6 100644 --- a/test/mac/mach_multiprocess.cc +++ b/test/mac/mach_multiprocess.cc @@ -14,7 +14,7 @@ #include "test/mac/mach_multiprocess.h" -#include +#include #include #include @@ -150,7 +150,7 @@ void MachMultiprocess::MultiprocessParent() { // and other processes will be able to look it up and send messages to it, // these checks disambiguate genuine failures later on in the test from those // that would occur if an errant process sends a message to this service. -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 +#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8 uid_t audit_auid; uid_t audit_euid; gid_t audit_egid; diff --git a/util/mach/exc_server_variants.cc b/util/mach/exc_server_variants.cc index e4c2d19e..ed3dda7a 100644 --- a/util/mach/exc_server_variants.cc +++ b/util/mach/exc_server_variants.cc @@ -14,7 +14,7 @@ #include "util/mach/exc_server_variants.h" -#include +#include #include #include @@ -682,7 +682,7 @@ kern_return_t ExcServerSuccessfulReturnValue(exception_type_t exception, exception_behavior_t behavior, bool set_thread_state) { if (exception == EXC_CRASH -#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 +#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_11 && MacOSXMinorVersion() >= 11 #endif ) { diff --git a/util/mach/exception_types.cc b/util/mach/exception_types.cc index 2a1f3c01..a959eb50 100644 --- a/util/mach/exception_types.cc +++ b/util/mach/exception_types.cc @@ -15,11 +15,10 @@ #include "util/mach/exception_types.h" #include -#include #include #include -#include #include +#include #include #include "base/check_op.h" @@ -29,7 +28,7 @@ #include "util/mach/mach_extensions.h" #include "util/numeric/in_range_cast.h" -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_9 extern "C" { @@ -83,13 +82,13 @@ namespace { // present on OS X 10.9 and later. If it’s not available, sets errno to ENOSYS // and returns -1. int ProcGetWakemonParams(pid_t pid, int* rate_hz, int* flags) { -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9 +#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_9 // proc_get_wakemon_params() isn’t in the SDK. Look it up dynamically. static ProcGetWakemonParamsType proc_get_wakemon_params = GetProcGetWakemonParams(); #endif -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 +#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9 // proc_get_wakemon_params() is definitely available if the deployment target // is 10.9 or newer. if (!proc_get_wakemon_params) { diff --git a/util/mach/mach_extensions.cc b/util/mach/mach_extensions.cc index cefb9bf3..4b38cd5b 100644 --- a/util/mach/mach_extensions.cc +++ b/util/mach/mach_extensions.cc @@ -15,7 +15,6 @@ #include "util/mach/mach_extensions.h" #include -#include #include #include "base/mac/mach_logging.h" @@ -50,7 +49,7 @@ exception_mask_t ExcMaskAll() { #error This code was not ported to iOS versions older than 7 #endif -#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 +#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9 const int mac_os_x_minor_version = MacOSXMinorVersion(); #endif @@ -67,7 +66,7 @@ exception_mask_t ExcMaskAll() { EXC_MASK_MACH_SYSCALL | EXC_MASK_RPC_ALERT | EXC_MASK_MACHINE; -#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 +#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8 if (mac_os_x_minor_version < 8) { return kExcMaskAll_10_6; } @@ -77,7 +76,7 @@ exception_mask_t ExcMaskAll() { // xnu-2050.48.11/osfmk/mach/exception_types.h. constexpr exception_mask_t kExcMaskAll_10_8 = kExcMaskAll_10_6 | EXC_MASK_RESOURCE; -#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_9 +#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_9 if (mac_os_x_minor_version < 9) { return kExcMaskAll_10_8; } @@ -97,7 +96,7 @@ exception_mask_t ExcMaskValid() { #error This code was not ported to iOS versions older than 9 #endif -#if !defined(OS_IOS) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 +#if !defined(OS_IOS) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_11 if (MacOSXMinorVersion() < 11) { return kExcMaskValid_10_6; } diff --git a/util/mach/mach_message.cc b/util/mach/mach_message.cc index 72d71e3e..1443e14c 100644 --- a/util/mach/mach_message.cc +++ b/util/mach/mach_message.cc @@ -14,7 +14,7 @@ #include "util/mach/mach_message.h" -#include +#include #include @@ -269,7 +269,7 @@ pid_t AuditPIDFromMachMessageTrailer(const mach_msg_trailer_t* trailer) { const mach_msg_audit_trailer_t* audit_trailer = reinterpret_cast(trailer); -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_8 +#if __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_8 pid_t audit_pid; audit_token_to_au32(audit_trailer->msgh_audit, nullptr, diff --git a/util/stdlib/objc.h b/util/stdlib/objc.h index faaa4538..b5e5b6c6 100644 --- a/util/stdlib/objc.h +++ b/util/stdlib/objc.h @@ -15,10 +15,10 @@ #ifndef CRASHPAD_UTIL_STDLIB_OBJC_H_ #define CRASHPAD_UTIL_STDLIB_OBJC_H_ -#include +#include #include -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_8 +#if __MAC_OS_X_VERSION_MAX_ALLOWED < __MAC_10_8 // In order for the @NO and @YES literals to work, NO and YES must be defined as // __objc_no and __objc_yes. See diff --git a/util/stdlib/strnlen.cc b/util/stdlib/strnlen.cc index 07b0db54..872c0eb4 100644 --- a/util/stdlib/strnlen.cc +++ b/util/stdlib/strnlen.cc @@ -14,9 +14,9 @@ #include "util/stdlib/strnlen.h" -#if defined(OS_MAC) && MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_7 +#if defined(OS_MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED < __MAC_10_7 -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7 // Redeclare a method only available on Mac OS X 10.7 and later to suppress a // -Wpartial-availability warning. extern "C" { @@ -27,7 +27,7 @@ size_t strnlen(const char* string, size_t max_length); namespace crashpad { size_t strnlen(const char* string, size_t max_length) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_7 if (::strnlen) { return ::strnlen(string, max_length); } diff --git a/util/stdlib/strnlen.h b/util/stdlib/strnlen.h index b88f2da2..59253b75 100644 --- a/util/stdlib/strnlen.h +++ b/util/stdlib/strnlen.h @@ -21,7 +21,7 @@ #include "build/build_config.h" #if defined(OS_MAC) -#include +#include #endif namespace crashpad { @@ -38,7 +38,7 @@ namespace crashpad { //! and not all systems’ standard libraries provide an implementation. size_t strnlen(const char* string, size_t max_length); -#if !defined(OS_MAC) || MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_7 +#if !defined(OS_MAC) || __MAC_OS_X_VERSION_MIN_REQUIRED >= __MAC_10_7 inline size_t strnlen(const char* string, size_t max_length) { return ::strnlen(string, max_length); }