#include "partition_alloc/partition_alloc_base/cpu.h"
#include <algorithm>
#include <cinttypes>
#include <climits>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <sstream>
#include <utility>
#include "partition_alloc/build_config.h"
#if PA_BUILDFLAG(PA_ARCH_CPU_ARM_FAMILY) && \
(PA_BUILDFLAG(IS_ANDROID) || PA_BUILDFLAG(IS_LINUX) || \
PA_BUILDFLAG(IS_CHROMEOS))
#include <asm/hwcap.h>
#include <sys/auxv.h>
#if PA_BUILDFLAG(PA_ARCH_CPU_ARM64)
#ifndef HWCAP2_MTE
#define HWCAP2_MTE …
#endif
#ifndef HWCAP2_BTI
#define HWCAP2_BTI …
#endif
#endif
#endif
#if PA_BUILDFLAG(PA_ARCH_CPU_X86_FAMILY)
#if PA_BUILDFLAG(PA_COMPILER_MSVC)
#include <immintrin.h>
#include <intrin.h>
#endif
#endif
namespace partition_alloc::internal::base {
CPU::CPU() { … }
CPU::CPU(CPU&&) = default;
namespace {
#if PA_BUILDFLAG(PA_ARCH_CPU_X86_FAMILY)
#if !PA_BUILDFLAG(PA_COMPILER_MSVC)
#if defined(__pic__) && defined(__i386__)
void __cpuid(int cpu_info[4], int info_type) {
__asm__ volatile(
"mov %%ebx, %%edi\n"
"cpuid\n"
"xchg %%edi, %%ebx\n"
: "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]),
"=d"(cpu_info[3])
: "a"(info_type), "c"(0));
}
#else
void __cpuid(int cpu_info[4], int info_type) { … }
#endif
#endif
uint64_t xgetbv(uint32_t xcr) { … }
#endif
}
void CPU::Initialize() { … }
const CPU& CPU::GetInstanceNoAllocation() { … }
}