Fixed compilation if mach-o/utils.h is unavailable.
Change-Id: Id22814308542503754600c2fa41e76bd6d1492c0 Reviewed-on: https://chromium-review.googlesource.com/c/breakpad/breakpad/+/5143028 Reviewed-by: Ivan Penkov <ivanpe@chromium.org>
This commit is contained in:
parent
7fb7589914
commit
83d9816eb4
1 changed files with 26 additions and 11 deletions
|
@ -37,9 +37,21 @@
|
||||||
#include <mach-o/fat.h>
|
#include <mach-o/fat.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <Availability.h>
|
||||||
|
#include <AvailabilityMacros.h>
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
#if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && defined(__IPHONE_16_0) && \
|
||||||
|
__IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_16_0) || \
|
||||||
|
(defined(MAC_OS_X_VERSION_MIN_REQUIRED) && defined(MAC_OS_VERSION_13_0) && \
|
||||||
|
MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_VERSION_13_0) || \
|
||||||
|
(defined(__TV_OS_VERSION_MIN_REQUIRED) && defined(__TV_OS_VERSION_16_0) && \
|
||||||
|
__TV_OS_VERSION_MIN_REQUIRED >= __TVOS_16_0)
|
||||||
|
#define HAS_MACHO_UTILS 1
|
||||||
#include <mach-o/utils.h>
|
#include <mach-o/utils.h>
|
||||||
|
#else
|
||||||
|
#define HAS_MACHO_UTILS 0
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
@ -95,40 +107,43 @@ ArchInfo GetLocalArchInfo(void) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
|
|
||||||
std::optional<ArchInfo> GetArchInfoFromName(const char* arch_name) {
|
std::optional<ArchInfo> GetArchInfoFromName(const char* arch_name) {
|
||||||
|
#if HAS_MACHO_UTILS
|
||||||
if (__builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, *)) {
|
if (__builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, *)) {
|
||||||
cpu_type_t type;
|
cpu_type_t type;
|
||||||
cpu_subtype_t subtype;
|
cpu_subtype_t subtype;
|
||||||
if (macho_cpu_type_for_arch_name(arch_name, &type, &subtype)) {
|
if (macho_cpu_type_for_arch_name(arch_name, &type, &subtype)) {
|
||||||
return ArchInfo{type, subtype};
|
return ArchInfo{type, subtype};
|
||||||
}
|
}
|
||||||
} else {
|
return std::nullopt;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
const NXArchInfo* info = NXGetArchInfoFromName(arch_name);
|
const NXArchInfo* info = NXGetArchInfoFromName(arch_name);
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
if (info) {
|
if (info) {
|
||||||
return ArchInfo{info->cputype, info->cpusubtype};
|
return ArchInfo{info->cputype, info->cpusubtype};
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return std::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* GetNameFromCPUType(cpu_type_t cpu_type, cpu_subtype_t cpu_subtype) {
|
const char* GetNameFromCPUType(cpu_type_t cpu_type, cpu_subtype_t cpu_subtype) {
|
||||||
|
#if HAS_MACHO_UTILS
|
||||||
if (__builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, *)) {
|
if (__builtin_available(macOS 13.0, iOS 16.0, tvOS 16.0, *)) {
|
||||||
const char* name = macho_arch_name_for_cpu_type(cpu_type, cpu_subtype);
|
const char* name = macho_arch_name_for_cpu_type(cpu_type, cpu_subtype);
|
||||||
if (name) {
|
if (name) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
} else {
|
return kUnknownArchName;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#pragma clang diagnostic push
|
#pragma clang diagnostic push
|
||||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||||
const NXArchInfo* info = NXGetArchInfoFromCpuType(cpu_type, cpu_subtype);
|
const NXArchInfo* info = NXGetArchInfoFromCpuType(cpu_type, cpu_subtype);
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
if (info) {
|
if (info) {
|
||||||
return info->name;
|
return info->name;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return kUnknownArchName;
|
return kUnknownArchName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue