Initial re-upload of spice2x-24-08-24
This commit is contained in:
40
external/cpu_features/include/internal/bit_utils.h
vendored
Normal file
40
external/cpu_features/include/internal/bit_utils.h
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// Copyright 2017 Google LLC
|
||||
//
|
||||
// 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 CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_
|
||||
#define CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
inline static bool IsBitSet(uint32_t reg, uint32_t bit) {
|
||||
return (reg >> bit) & 0x1;
|
||||
}
|
||||
|
||||
inline static uint32_t ExtractBitRange(uint32_t reg, uint32_t msb,
|
||||
uint32_t lsb) {
|
||||
const uint64_t bits = msb - lsb + 1ULL;
|
||||
const uint64_t mask = (1ULL << bits) - 1ULL;
|
||||
assert(msb >= lsb);
|
||||
return (reg >> lsb) & mask;
|
||||
}
|
||||
|
||||
CPU_FEATURES_END_CPP_NAMESPACE
|
||||
|
||||
#endif // CPU_FEATURES_INCLUDE_INTERNAL_BIT_UTILS_H_
|
||||
37
external/cpu_features/include/internal/cpuid_x86.h
vendored
Normal file
37
external/cpu_features/include/internal/cpuid_x86.h
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright 2017 Google LLC
|
||||
//
|
||||
// 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 CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_
|
||||
#define CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
// A struct to hold the result of a call to cpuid.
|
||||
typedef struct {
|
||||
uint32_t eax, ebx, ecx, edx;
|
||||
} Leaf;
|
||||
|
||||
// Returns the result of a call to the cpuid instruction.
|
||||
Leaf GetCpuidLeaf(uint32_t leaf_id, int ecx);
|
||||
|
||||
// Returns the eax value of the XCR0 register.
|
||||
uint32_t GetXCR0Eax(void);
|
||||
|
||||
CPU_FEATURES_END_CPP_NAMESPACE
|
||||
|
||||
#endif // CPU_FEATURES_INCLUDE_INTERNAL_CPUID_X86_H_
|
||||
39
external/cpu_features/include/internal/filesystem.h
vendored
Normal file
39
external/cpu_features/include/internal/filesystem.h
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright 2017 Google LLC
|
||||
//
|
||||
// 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.
|
||||
|
||||
// An interface for the filesystem that allows mocking the filesystem in
|
||||
// unittests.
|
||||
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_
|
||||
#define CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
// Same as linux "open(filename, O_RDONLY)", retries automatically on EINTR.
|
||||
int CpuFeatures_OpenFile(const char* filename);
|
||||
|
||||
// Same as linux "read(file_descriptor, buffer, buffer_size)", retries
|
||||
// automatically on EINTR.
|
||||
int CpuFeatures_ReadFile(int file_descriptor, void* buffer, size_t buffer_size);
|
||||
|
||||
// Same as linux "close(file_descriptor)".
|
||||
void CpuFeatures_CloseFile(int file_descriptor);
|
||||
|
||||
CPU_FEATURES_END_CPP_NAMESPACE
|
||||
|
||||
#endif // CPU_FEATURES_INCLUDE_INTERNAL_FILESYSTEM_H_
|
||||
277
external/cpu_features/include/internal/hwcaps.h
vendored
Normal file
277
external/cpu_features/include/internal/hwcaps.h
vendored
Normal file
@@ -0,0 +1,277 @@
|
||||
// Copyright 2017 Google LLC
|
||||
//
|
||||
// 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.
|
||||
|
||||
// Interface to retrieve hardware capabilities. It relies on Linux's getauxval
|
||||
// or `/proc/self/auxval` under the hood.
|
||||
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_
|
||||
#define CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
// To avoid depending on the linux kernel we reproduce the architecture specific
|
||||
// constants here.
|
||||
|
||||
// http://elixir.free-electrons.com/linux/latest/source/arch/arm64/include/uapi/asm/hwcap.h
|
||||
#define AARCH64_HWCAP_FP (1UL << 0)
|
||||
#define AARCH64_HWCAP_ASIMD (1UL << 1)
|
||||
#define AARCH64_HWCAP_EVTSTRM (1UL << 2)
|
||||
#define AARCH64_HWCAP_AES (1UL << 3)
|
||||
#define AARCH64_HWCAP_PMULL (1UL << 4)
|
||||
#define AARCH64_HWCAP_SHA1 (1UL << 5)
|
||||
#define AARCH64_HWCAP_SHA2 (1UL << 6)
|
||||
#define AARCH64_HWCAP_CRC32 (1UL << 7)
|
||||
#define AARCH64_HWCAP_ATOMICS (1UL << 8)
|
||||
#define AARCH64_HWCAP_FPHP (1UL << 9)
|
||||
#define AARCH64_HWCAP_ASIMDHP (1UL << 10)
|
||||
#define AARCH64_HWCAP_CPUID (1UL << 11)
|
||||
#define AARCH64_HWCAP_ASIMDRDM (1UL << 12)
|
||||
#define AARCH64_HWCAP_JSCVT (1UL << 13)
|
||||
#define AARCH64_HWCAP_FCMA (1UL << 14)
|
||||
#define AARCH64_HWCAP_LRCPC (1UL << 15)
|
||||
#define AARCH64_HWCAP_DCPOP (1UL << 16)
|
||||
#define AARCH64_HWCAP_SHA3 (1UL << 17)
|
||||
#define AARCH64_HWCAP_SM3 (1UL << 18)
|
||||
#define AARCH64_HWCAP_SM4 (1UL << 19)
|
||||
#define AARCH64_HWCAP_ASIMDDP (1UL << 20)
|
||||
#define AARCH64_HWCAP_SHA512 (1UL << 21)
|
||||
#define AARCH64_HWCAP_SVE (1UL << 22)
|
||||
#define AARCH64_HWCAP_ASIMDFHM (1UL << 23)
|
||||
#define AARCH64_HWCAP_DIT (1UL << 24)
|
||||
#define AARCH64_HWCAP_USCAT (1UL << 25)
|
||||
#define AARCH64_HWCAP_ILRCPC (1UL << 26)
|
||||
#define AARCH64_HWCAP_FLAGM (1UL << 27)
|
||||
#define AARCH64_HWCAP_SSBS (1UL << 28)
|
||||
#define AARCH64_HWCAP_SB (1UL << 29)
|
||||
#define AARCH64_HWCAP_PACA (1UL << 30)
|
||||
#define AARCH64_HWCAP_PACG (1UL << 31)
|
||||
|
||||
#define AARCH64_HWCAP2_DCPODP (1UL << 0)
|
||||
#define AARCH64_HWCAP2_SVE2 (1UL << 1)
|
||||
#define AARCH64_HWCAP2_SVEAES (1UL << 2)
|
||||
#define AARCH64_HWCAP2_SVEPMULL (1UL << 3)
|
||||
#define AARCH64_HWCAP2_SVEBITPERM (1UL << 4)
|
||||
#define AARCH64_HWCAP2_SVESHA3 (1UL << 5)
|
||||
#define AARCH64_HWCAP2_SVESM4 (1UL << 6)
|
||||
#define AARCH64_HWCAP2_FLAGM2 (1UL << 7)
|
||||
#define AARCH64_HWCAP2_FRINT (1UL << 8)
|
||||
#define AARCH64_HWCAP2_SVEI8MM (1UL << 9)
|
||||
#define AARCH64_HWCAP2_SVEF32MM (1UL << 10)
|
||||
#define AARCH64_HWCAP2_SVEF64MM (1UL << 11)
|
||||
#define AARCH64_HWCAP2_SVEBF16 (1UL << 12)
|
||||
#define AARCH64_HWCAP2_I8MM (1UL << 13)
|
||||
#define AARCH64_HWCAP2_BF16 (1UL << 14)
|
||||
#define AARCH64_HWCAP2_DGH (1UL << 15)
|
||||
#define AARCH64_HWCAP2_RNG (1UL << 16)
|
||||
#define AARCH64_HWCAP2_BTI (1UL << 17)
|
||||
#define AARCH64_HWCAP2_MTE (1UL << 18)
|
||||
#define AARCH64_HWCAP2_ECV (1UL << 19)
|
||||
#define AARCH64_HWCAP2_AFP (1UL << 20)
|
||||
#define AARCH64_HWCAP2_RPRES (1UL << 21)
|
||||
#define AARCH64_HWCAP2_MTE3 (1UL << 22)
|
||||
#define AARCH64_HWCAP2_SME (1UL << 23)
|
||||
#define AARCH64_HWCAP2_SME_I16I64 (1UL << 24)
|
||||
#define AARCH64_HWCAP2_SME_F64F64 (1UL << 25)
|
||||
#define AARCH64_HWCAP2_SME_I8I32 (1UL << 26)
|
||||
#define AARCH64_HWCAP2_SME_F16F32 (1UL << 27)
|
||||
#define AARCH64_HWCAP2_SME_B16F32 (1UL << 28)
|
||||
#define AARCH64_HWCAP2_SME_F32F32 (1UL << 29)
|
||||
#define AARCH64_HWCAP2_SME_FA64 (1UL << 30)
|
||||
#define AARCH64_HWCAP2_WFXT (1UL << 31)
|
||||
#define AARCH64_HWCAP2_EBF16 (1UL << 32)
|
||||
#define AARCH64_HWCAP2_SVE_EBF16 (1UL << 33)
|
||||
#define AARCH64_HWCAP2_CSSC (1UL << 34)
|
||||
#define AARCH64_HWCAP2_RPRFM (1UL << 35)
|
||||
#define AARCH64_HWCAP2_SVE2P1 (1UL << 36)
|
||||
#define AARCH64_HWCAP2_SME2 (1UL << 37)
|
||||
#define AARCH64_HWCAP2_SME2P1 (1UL << 38)
|
||||
#define AARCH64_HWCAP2_SME_I16I32 (1UL << 39)
|
||||
#define AARCH64_HWCAP2_SME_BI32I32 (1UL << 40)
|
||||
#define AARCH64_HWCAP2_SME_B16B16 (1UL << 41)
|
||||
#define AARCH64_HWCAP2_SME_F16F16 (1UL << 42)
|
||||
|
||||
// http://elixir.free-electrons.com/linux/latest/source/arch/arm/include/uapi/asm/hwcap.h
|
||||
#define ARM_HWCAP_SWP (1UL << 0)
|
||||
#define ARM_HWCAP_HALF (1UL << 1)
|
||||
#define ARM_HWCAP_THUMB (1UL << 2)
|
||||
#define ARM_HWCAP_26BIT (1UL << 3)
|
||||
#define ARM_HWCAP_FAST_MULT (1UL << 4)
|
||||
#define ARM_HWCAP_FPA (1UL << 5)
|
||||
#define ARM_HWCAP_VFP (1UL << 6)
|
||||
#define ARM_HWCAP_EDSP (1UL << 7)
|
||||
#define ARM_HWCAP_JAVA (1UL << 8)
|
||||
#define ARM_HWCAP_IWMMXT (1UL << 9)
|
||||
#define ARM_HWCAP_CRUNCH (1UL << 10)
|
||||
#define ARM_HWCAP_THUMBEE (1UL << 11)
|
||||
#define ARM_HWCAP_NEON (1UL << 12)
|
||||
#define ARM_HWCAP_VFPV3 (1UL << 13)
|
||||
#define ARM_HWCAP_VFPV3D16 (1UL << 14)
|
||||
#define ARM_HWCAP_TLS (1UL << 15)
|
||||
#define ARM_HWCAP_VFPV4 (1UL << 16)
|
||||
#define ARM_HWCAP_IDIVA (1UL << 17)
|
||||
#define ARM_HWCAP_IDIVT (1UL << 18)
|
||||
#define ARM_HWCAP_VFPD32 (1UL << 19)
|
||||
#define ARM_HWCAP_LPAE (1UL << 20)
|
||||
#define ARM_HWCAP_EVTSTRM (1UL << 21)
|
||||
#define ARM_HWCAP2_AES (1UL << 0)
|
||||
#define ARM_HWCAP2_PMULL (1UL << 1)
|
||||
#define ARM_HWCAP2_SHA1 (1UL << 2)
|
||||
#define ARM_HWCAP2_SHA2 (1UL << 3)
|
||||
#define ARM_HWCAP2_CRC32 (1UL << 4)
|
||||
|
||||
// http://elixir.free-electrons.com/linux/latest/source/arch/mips/include/uapi/asm/hwcap.h
|
||||
#define MIPS_HWCAP_R6 (1UL << 0)
|
||||
#define MIPS_HWCAP_MSA (1UL << 1)
|
||||
#define MIPS_HWCAP_CRC32 (1UL << 2)
|
||||
#define MIPS_HWCAP_MIPS16 (1UL << 3)
|
||||
#define MIPS_HWCAP_MDMX (1UL << 4)
|
||||
#define MIPS_HWCAP_MIPS3D (1UL << 5)
|
||||
#define MIPS_HWCAP_SMARTMIPS (1UL << 6)
|
||||
#define MIPS_HWCAP_DSP (1UL << 7)
|
||||
#define MIPS_HWCAP_DSP2 (1UL << 8)
|
||||
#define MIPS_HWCAP_DSP3 (1UL << 9)
|
||||
|
||||
// http://elixir.free-electrons.com/linux/latest/source/arch/powerpc/include/uapi/asm/cputable.h
|
||||
#ifndef _UAPI__ASM_POWERPC_CPUTABLE_H
|
||||
/* in AT_HWCAP */
|
||||
#define PPC_FEATURE_32 0x80000000
|
||||
#define PPC_FEATURE_64 0x40000000
|
||||
#define PPC_FEATURE_601_INSTR 0x20000000
|
||||
#define PPC_FEATURE_HAS_ALTIVEC 0x10000000
|
||||
#define PPC_FEATURE_HAS_FPU 0x08000000
|
||||
#define PPC_FEATURE_HAS_MMU 0x04000000
|
||||
#define PPC_FEATURE_HAS_4xxMAC 0x02000000
|
||||
#define PPC_FEATURE_UNIFIED_CACHE 0x01000000
|
||||
#define PPC_FEATURE_HAS_SPE 0x00800000
|
||||
#define PPC_FEATURE_HAS_EFP_SINGLE 0x00400000
|
||||
#define PPC_FEATURE_HAS_EFP_DOUBLE 0x00200000
|
||||
#define PPC_FEATURE_NO_TB 0x00100000
|
||||
#define PPC_FEATURE_POWER4 0x00080000
|
||||
#define PPC_FEATURE_POWER5 0x00040000
|
||||
#define PPC_FEATURE_POWER5_PLUS 0x00020000
|
||||
#define PPC_FEATURE_CELL 0x00010000
|
||||
#define PPC_FEATURE_BOOKE 0x00008000
|
||||
#define PPC_FEATURE_SMT 0x00004000
|
||||
#define PPC_FEATURE_ICACHE_SNOOP 0x00002000
|
||||
#define PPC_FEATURE_ARCH_2_05 0x00001000
|
||||
#define PPC_FEATURE_PA6T 0x00000800
|
||||
#define PPC_FEATURE_HAS_DFP 0x00000400
|
||||
#define PPC_FEATURE_POWER6_EXT 0x00000200
|
||||
#define PPC_FEATURE_ARCH_2_06 0x00000100
|
||||
#define PPC_FEATURE_HAS_VSX 0x00000080
|
||||
|
||||
#define PPC_FEATURE_PSERIES_PERFMON_COMPAT 0x00000040
|
||||
|
||||
/* Reserved - do not use 0x00000004 */
|
||||
#define PPC_FEATURE_TRUE_LE 0x00000002
|
||||
#define PPC_FEATURE_PPC_LE 0x00000001
|
||||
|
||||
/* in AT_HWCAP2 */
|
||||
#define PPC_FEATURE2_ARCH_2_07 0x80000000
|
||||
#define PPC_FEATURE2_HTM 0x40000000
|
||||
#define PPC_FEATURE2_DSCR 0x20000000
|
||||
#define PPC_FEATURE2_EBB 0x10000000
|
||||
#define PPC_FEATURE2_ISEL 0x08000000
|
||||
#define PPC_FEATURE2_TAR 0x04000000
|
||||
#define PPC_FEATURE2_VEC_CRYPTO 0x02000000
|
||||
#define PPC_FEATURE2_HTM_NOSC 0x01000000
|
||||
#define PPC_FEATURE2_ARCH_3_00 0x00800000
|
||||
#define PPC_FEATURE2_HAS_IEEE128 0x00400000
|
||||
#define PPC_FEATURE2_DARN 0x00200000
|
||||
#define PPC_FEATURE2_SCV 0x00100000
|
||||
#define PPC_FEATURE2_HTM_NO_SUSPEND 0x00080000
|
||||
#endif
|
||||
|
||||
// https://elixir.bootlin.com/linux/v6.0-rc6/source/arch/s390/include/asm/elf.h
|
||||
#define HWCAP_S390_ESAN3 1
|
||||
#define HWCAP_S390_ZARCH 2
|
||||
#define HWCAP_S390_STFLE 4
|
||||
#define HWCAP_S390_MSA 8
|
||||
#define HWCAP_S390_LDISP 16
|
||||
#define HWCAP_S390_EIMM 32
|
||||
#define HWCAP_S390_DFP 64
|
||||
#define HWCAP_S390_HPAGE 128
|
||||
#define HWCAP_S390_ETF3EH 256
|
||||
#define HWCAP_S390_HIGH_GPRS 512
|
||||
#define HWCAP_S390_TE 1024
|
||||
#define HWCAP_S390_VX 2048
|
||||
#define HWCAP_S390_VXRS HWCAP_S390_VX
|
||||
#define HWCAP_S390_VXD 4096
|
||||
#define HWCAP_S390_VXRS_BCD HWCAP_S390_VXD
|
||||
#define HWCAP_S390_VXE 8192
|
||||
#define HWCAP_S390_VXRS_EXT HWCAP_S390_VXE
|
||||
#define HWCAP_S390_GS 16384
|
||||
#define HWCAP_S390_VXRS_EXT2 32768
|
||||
#define HWCAP_S390_VXRS_PDE 65536
|
||||
#define HWCAP_S390_SORT 131072
|
||||
#define HWCAP_S390_DFLT 262144
|
||||
#define HWCAP_S390_VXRS_PDE2 524288
|
||||
#define HWCAP_S390_NNPA 1048576
|
||||
#define HWCAP_S390_PCI_MIO 2097152
|
||||
#define HWCAP_S390_SIE 4194304
|
||||
|
||||
// https://elixir.bootlin.com/linux/latest/source/arch/riscv/include/uapi/asm/hwcap.h
|
||||
#define RISCV_HWCAP_32 0x32
|
||||
#define RISCV_HWCAP_64 0x64
|
||||
#define RISCV_HWCAP_128 0x128
|
||||
#define RISCV_HWCAP_M (1UL << ('M' - 'A'))
|
||||
#define RISCV_HWCAP_A (1UL << ('A' - 'A'))
|
||||
#define RISCV_HWCAP_F (1UL << ('F' - 'A'))
|
||||
#define RISCV_HWCAP_D (1UL << ('D' - 'A'))
|
||||
#define RISCV_HWCAP_Q (1UL << ('Q' - 'A'))
|
||||
#define RISCV_HWCAP_C (1UL << ('C' - 'A'))
|
||||
#define RISCV_HWCAP_V (1UL << ('V' - 'A'))
|
||||
|
||||
// https://github.com/torvalds/linux/blob/master/arch/loongarch/include/uapi/asm/hwcap.h
|
||||
#define HWCAP_LOONGARCH_CPUCFG (1 << 0)
|
||||
#define HWCAP_LOONGARCH_LAM (1 << 1)
|
||||
#define HWCAP_LOONGARCH_UAL (1 << 2)
|
||||
#define HWCAP_LOONGARCH_FPU (1 << 3)
|
||||
#define HWCAP_LOONGARCH_LSX (1 << 4)
|
||||
#define HWCAP_LOONGARCH_LASX (1 << 5)
|
||||
#define HWCAP_LOONGARCH_CRC32 (1 << 6)
|
||||
#define HWCAP_LOONGARCH_COMPLEX (1 << 7)
|
||||
#define HWCAP_LOONGARCH_CRYPTO (1 << 8)
|
||||
#define HWCAP_LOONGARCH_LVZ (1 << 9)
|
||||
#define HWCAP_LOONGARCH_LBT_X86 (1 << 10)
|
||||
#define HWCAP_LOONGARCH_LBT_ARM (1 << 11)
|
||||
#define HWCAP_LOONGARCH_LBT_MIPS (1 << 12)
|
||||
#define HWCAP_LOONGARCH_PTW (1 << 13)
|
||||
|
||||
typedef struct {
|
||||
unsigned long hwcaps;
|
||||
unsigned long hwcaps2;
|
||||
} HardwareCapabilities;
|
||||
|
||||
// Retrieves values from auxiliary vector for types AT_HWCAP and AT_HWCAP2.
|
||||
// First tries to call getauxval(), if not available falls back to reading
|
||||
// "/proc/self/auxv".
|
||||
HardwareCapabilities CpuFeatures_GetHardwareCapabilities(void);
|
||||
|
||||
// Checks whether value for AT_HWCAP (or AT_HWCAP2) match hwcaps_mask.
|
||||
bool CpuFeatures_IsHwCapsSet(const HardwareCapabilities hwcaps_mask,
|
||||
const HardwareCapabilities hwcaps);
|
||||
|
||||
// Get pointer for the AT_PLATFORM type.
|
||||
const char* CpuFeatures_GetPlatformPointer(void);
|
||||
// Get pointer for the AT_BASE_PLATFORM type.
|
||||
const char* CpuFeatures_GetBasePlatformPointer(void);
|
||||
|
||||
CPU_FEATURES_END_CPP_NAMESPACE
|
||||
|
||||
#endif // CPU_FEATURES_INCLUDE_INTERNAL_HWCAPS_H_
|
||||
49
external/cpu_features/include/internal/stack_line_reader.h
vendored
Normal file
49
external/cpu_features/include/internal/stack_line_reader.h
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2017 Google LLC
|
||||
//
|
||||
// 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.
|
||||
|
||||
// Reads a file line by line and stores the data on the stack. This allows
|
||||
// parsing files in one go without allocating.
|
||||
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_
|
||||
#define CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
#include "internal/string_view.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
typedef struct {
|
||||
char buffer[STACK_LINE_READER_BUFFER_SIZE];
|
||||
StringView view;
|
||||
int fd;
|
||||
bool skip_mode;
|
||||
} StackLineReader;
|
||||
|
||||
// Initializes a StackLineReader.
|
||||
void StackLineReader_Initialize(StackLineReader* reader, int fd);
|
||||
|
||||
typedef struct {
|
||||
StringView line; // A view of the line.
|
||||
bool eof; // Nothing more to read, we reached EOF.
|
||||
bool full_line; // If false the line was truncated to
|
||||
// STACK_LINE_READER_BUFFER_SIZE.
|
||||
} LineResult;
|
||||
|
||||
// Reads the file pointed to by fd and tries to read a full line.
|
||||
LineResult StackLineReader_NextLine(StackLineReader* reader);
|
||||
|
||||
CPU_FEATURES_END_CPP_NAMESPACE
|
||||
|
||||
#endif // CPU_FEATURES_INCLUDE_INTERNAL_STACK_LINE_READER_H_
|
||||
110
external/cpu_features/include/internal/string_view.h
vendored
Normal file
110
external/cpu_features/include/internal/string_view.h
vendored
Normal file
@@ -0,0 +1,110 @@
|
||||
// Copyright 2017 Google LLC
|
||||
//
|
||||
// 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.
|
||||
|
||||
// A view over a piece of string. The view is not 0 terminated.
|
||||
#ifndef CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_
|
||||
#define CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
CPU_FEATURES_START_CPP_NAMESPACE
|
||||
|
||||
typedef struct {
|
||||
const char* ptr;
|
||||
size_t size;
|
||||
} StringView;
|
||||
|
||||
#ifdef __cplusplus
|
||||
static const StringView kEmptyStringView = {NULL, 0};
|
||||
#else
|
||||
static const StringView kEmptyStringView;
|
||||
#endif
|
||||
|
||||
// Returns a StringView from the provided string.
|
||||
// Passing NULL is valid only if size is 0.
|
||||
static inline StringView view(const char* str, const size_t size) {
|
||||
StringView view;
|
||||
view.ptr = str;
|
||||
view.size = size;
|
||||
return view;
|
||||
}
|
||||
|
||||
static inline StringView str(const char* str) { return view(str, strlen(str)); }
|
||||
|
||||
// Returns the index of the first occurrence of c in view or -1 if not found.
|
||||
int CpuFeatures_StringView_IndexOfChar(const StringView view, char c);
|
||||
|
||||
// Returns the index of the first occurrence of sub_view in view or -1 if not
|
||||
// found.
|
||||
int CpuFeatures_StringView_IndexOf(const StringView view,
|
||||
const StringView sub_view);
|
||||
|
||||
// Returns whether a is equal to b (same content).
|
||||
bool CpuFeatures_StringView_IsEquals(const StringView a, const StringView b);
|
||||
|
||||
// Returns whether a starts with b.
|
||||
bool CpuFeatures_StringView_StartsWith(const StringView a, const StringView b);
|
||||
|
||||
// Removes count characters from the beginning of view or kEmptyStringView if
|
||||
// count if greater than view.size.
|
||||
StringView CpuFeatures_StringView_PopFront(const StringView str_view,
|
||||
size_t count);
|
||||
|
||||
// Removes count characters from the end of view or kEmptyStringView if count if
|
||||
// greater than view.size.
|
||||
StringView CpuFeatures_StringView_PopBack(const StringView str_view,
|
||||
size_t count);
|
||||
|
||||
// Keeps the count first characters of view or view if count if greater than
|
||||
// view.size.
|
||||
StringView CpuFeatures_StringView_KeepFront(const StringView str_view,
|
||||
size_t count);
|
||||
|
||||
// Retrieves the first character of view. If view is empty the behavior is
|
||||
// undefined.
|
||||
char CpuFeatures_StringView_Front(const StringView view);
|
||||
|
||||
// Retrieves the last character of view. If view is empty the behavior is
|
||||
// undefined.
|
||||
char CpuFeatures_StringView_Back(const StringView view);
|
||||
|
||||
// Removes leading and tailing space characters.
|
||||
StringView CpuFeatures_StringView_TrimWhitespace(StringView view);
|
||||
|
||||
// Convert StringView to positive integer. e.g. "42", "0x2a".
|
||||
// Returns -1 on error.
|
||||
int CpuFeatures_StringView_ParsePositiveNumber(const StringView view);
|
||||
|
||||
// Copies src StringView to dst buffer.
|
||||
void CpuFeatures_StringView_CopyString(const StringView src, char* dst,
|
||||
size_t dst_size);
|
||||
|
||||
// Checks if line contains the specified whitespace separated word.
|
||||
bool CpuFeatures_StringView_HasWord(const StringView line,
|
||||
const char* const word,
|
||||
const char separator);
|
||||
|
||||
// Get key/value from line. key and value are separated by ": ".
|
||||
// key and value are cleaned up from leading and trailing whitespaces.
|
||||
bool CpuFeatures_StringView_GetAttributeKeyValue(const StringView line,
|
||||
StringView* key,
|
||||
StringView* value);
|
||||
|
||||
CPU_FEATURES_END_CPP_NAMESPACE
|
||||
|
||||
#endif // CPU_FEATURES_INCLUDE_INTERNAL_STRING_VIEW_H_
|
||||
70
external/cpu_features/include/internal/windows_utils.h
vendored
Normal file
70
external/cpu_features/include/internal/windows_utils.h
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright 2022 Google LLC
|
||||
//
|
||||
// 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 CPU_FEATURES_INCLUDE_INTERNAL_WINDOWS_UTILS_H_
|
||||
#define CPU_FEATURES_INCLUDE_INTERNAL_WINDOWS_UTILS_H_
|
||||
|
||||
#include "cpu_features_macros.h"
|
||||
|
||||
#ifdef CPU_FEATURES_OS_WINDOWS
|
||||
|
||||
#include <windows.h> // IsProcessorFeaturePresent
|
||||
|
||||
// modern WinSDK winnt.h contains newer features detection definitions
|
||||
#if !defined(PF_SSSE3_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_SSSE3_INSTRUCTIONS_AVAILABLE 36
|
||||
#endif
|
||||
|
||||
#if !defined(PF_SSE4_1_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_SSE4_1_INSTRUCTIONS_AVAILABLE 37
|
||||
#endif
|
||||
|
||||
#if !defined(PF_SSE4_2_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_SSE4_2_INSTRUCTIONS_AVAILABLE 38
|
||||
#endif
|
||||
|
||||
#if !defined(PF_ARM_VFP_32_REGISTERS_AVAILABLE)
|
||||
#define PF_ARM_VFP_32_REGISTERS_AVAILABLE 18
|
||||
#endif
|
||||
|
||||
#if !defined(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_ARM_NEON_INSTRUCTIONS_AVAILABLE 19
|
||||
#endif
|
||||
|
||||
#if !defined(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE 30
|
||||
#endif
|
||||
|
||||
#if !defined(PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE 31
|
||||
#endif
|
||||
|
||||
#if !defined(PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_ARM_V81_ATOMIC_INSTRUCTIONS_AVAILABLE 34
|
||||
#endif
|
||||
|
||||
#if !defined(PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_ARM_V82_DP_INSTRUCTIONS_AVAILABLE 43
|
||||
#endif
|
||||
|
||||
#if !defined(PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_ARM_V83_JSCVT_INSTRUCTIONS_AVAILABLE 44
|
||||
#endif
|
||||
|
||||
#if !defined(PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE)
|
||||
#define PF_ARM_V83_LRCPC_INSTRUCTIONS_AVAILABLE 45
|
||||
#endif
|
||||
|
||||
#endif // CPU_FEATURES_OS_WINDOWS
|
||||
#endif // CPU_FEATURES_INCLUDE_INTERNAL_WINDOWS_UTILS_H_
|
||||
Reference in New Issue
Block a user