Skip to content

Commit 23b54dd

Browse files
committed
Add support for Apple M1 AArch64 SoCs
Completely based on google#150. Thanks to @sbehnke! + Refactoring to accomodate the new source tree + Adding more feature flags
1 parent fc52c64 commit 23b54dd

File tree

7 files changed

+325
-85
lines changed

7 files changed

+325
-85
lines changed

CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.0)
1+
cmake_minimum_required(VERSION 3.19.2)
22

33
# option() honors normal variables.
44
# see: https://cmake.org/cmake/help/git-stage/policy/CMP0077.html
@@ -52,10 +52,10 @@ set(PROCESSOR_IS_POWER FALSE)
5252

5353
if(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
5454
set(PROCESSOR_IS_MIPS TRUE)
55+
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(^aarch64)|(^arm64)")
56+
set(PROCESSOR_IS_AARCH64 TRUE)
5557
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
5658
set(PROCESSOR_IS_ARM TRUE)
57-
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
58-
set(PROCESSOR_IS_AARCH64 TRUE)
5959
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86_64)|(AMD64|amd64)|(^i.86$)")
6060
set(PROCESSOR_IS_X86 TRUE)
6161
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
@@ -135,7 +135,7 @@ target_link_libraries(cpu_features PUBLIC ${CMAKE_DL_LIBS})
135135
target_include_directories(cpu_features
136136
PUBLIC $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/cpu_features>
137137
)
138-
if(PROCESSOR_IS_X86)
138+
if(PROCESSOR_IS_X86 OR PROCESSOR_IS_AARCH64)
139139
if(APPLE)
140140
target_compile_definitions(cpu_features PRIVATE HAVE_SYSCTLBYNAME)
141141
endif()

README.md

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,14 @@ flags : aes,avx,cx16,smx,sse4_1,sse4_2,ssse3
152152
<a name="support"></a>
153153
## What's supported
154154

155-
| | x86³ | ARM | AArch64 | MIPS⁴ | POWER |
156-
|---------|:----:|:-------:|:-------:|:-------:|:-------:|
157-
| Android | yes² | yes¹ | yes¹ | yes¹ | N/A |
158-
| iOS | N/A | not yet | not yet | N/A | N/A |
159-
| Linux | yes² | yes¹ | yes¹ | yes¹ | yes¹ |
160-
| MacOs | yes² | N/A | not yet | N/A | no |
161-
| Windows | yes² | not yet | not yet | N/A | N/A |
162-
| FreeBSD | yes² | not yet | not yet | not yet | not yet |
155+
| | x86<sup>3</sup> | ARM | AArch64 | MIPS<sup>4</sup>| POWER |
156+
|---------|:---------------:|:---------------:|:-----------------:|:---------------:|:---------------:|
157+
| Android | yes<sup>2</sup> | yes<sup>1</sup> | yes<sup>1</sup> | yes<sup>1</sup> | N/A |
158+
| iOS | N/A | not yet | not yet | N/A | N/A |
159+
| Linux | yes<sup>2</sup> | yes<sup>1</sup> | yes<sup>1</sup> | yes<sup>1</sup> | yes<sup>1</sup> |
160+
| MacOs | yes<sup>2</sup> | N/A | yes<sup>5</sup> | N/A | no |
161+
| Windows | yes<sup>2</sup> | not yet | not yet | N/A | N/A |
162+
| FreeBSD | yes<sup>2</sup> | not yet | not yet | not yet | not yet |
163163

164164
1. **Features revealed from Linux.** We gather data from several sources
165165
depending on availability:
@@ -174,6 +174,8 @@ flags : aes,avx,cx16,smx,sse4_1,sse4_2,ssse3
174174
microarchitecture allows the client to reject particular microarchitectures.
175175
4. All flavors of Mips are supported, little and big endian as well as 32/64
176176
bits.
177+
5. **Features revealed from sysctl.** features are retrieved by the `sysctl`
178+
instruction.
177179

178180
<a name="ndk"></a>
179181
## Android NDK's drop in replacement
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Copyright 2017 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "cpu_features_macros.h"
16+
17+
#ifdef CPU_FEATURES_ARCH_AARCH64
18+
#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) || \
19+
defined(CPU_FEATURES_OS_MACOS)
20+
21+
#include "cpuinfo_aarch64.h"
22+
23+
////////////////////////////////////////////////////////////////////////////////
24+
// Definitions for introspection.
25+
////////////////////////////////////////////////////////////////////////////////
26+
#define INTROSPECTION_TABLE \
27+
LINE(AARCH64_FP, fp, "fp", AARCH64_HWCAP_FP, 0) \
28+
LINE(AARCH64_ASIMD, asimd, "asimd", AARCH64_HWCAP_ASIMD, 0) \
29+
LINE(AARCH64_EVTSTRM, evtstrm, "evtstrm", AARCH64_HWCAP_EVTSTRM, 0) \
30+
LINE(AARCH64_AES, aes, "aes", AARCH64_HWCAP_AES, 0) \
31+
LINE(AARCH64_PMULL, pmull, "pmull", AARCH64_HWCAP_PMULL, 0) \
32+
LINE(AARCH64_SHA1, sha1, "sha1", AARCH64_HWCAP_SHA1, 0) \
33+
LINE(AARCH64_SHA2, sha2, "sha2", AARCH64_HWCAP_SHA2, 0) \
34+
LINE(AARCH64_CRC32, crc32, "crc32", AARCH64_HWCAP_CRC32, 0) \
35+
LINE(AARCH64_ATOMICS, atomics, "atomics", AARCH64_HWCAP_ATOMICS, 0) \
36+
LINE(AARCH64_FPHP, fphp, "fphp", AARCH64_HWCAP_FPHP, 0) \
37+
LINE(AARCH64_ASIMDHP, asimdhp, "asimdhp", AARCH64_HWCAP_ASIMDHP, 0) \
38+
LINE(AARCH64_CPUID, cpuid, "cpuid", AARCH64_HWCAP_CPUID, 0) \
39+
LINE(AARCH64_ASIMDRDM, asimdrdm, "asimdrdm", AARCH64_HWCAP_ASIMDRDM, 0) \
40+
LINE(AARCH64_JSCVT, jscvt, "jscvt", AARCH64_HWCAP_JSCVT, 0) \
41+
LINE(AARCH64_FCMA, fcma, "fcma", AARCH64_HWCAP_FCMA, 0) \
42+
LINE(AARCH64_LRCPC, lrcpc, "lrcpc", AARCH64_HWCAP_LRCPC, 0) \
43+
LINE(AARCH64_DCPOP, dcpop, "dcpop", AARCH64_HWCAP_DCPOP, 0) \
44+
LINE(AARCH64_SHA3, sha3, "sha3", AARCH64_HWCAP_SHA3, 0) \
45+
LINE(AARCH64_SM3, sm3, "sm3", AARCH64_HWCAP_SM3, 0) \
46+
LINE(AARCH64_SM4, sm4, "sm4", AARCH64_HWCAP_SM4, 0) \
47+
LINE(AARCH64_ASIMDDP, asimddp, "asimddp", AARCH64_HWCAP_ASIMDDP, 0) \
48+
LINE(AARCH64_SHA512, sha512, "sha512", AARCH64_HWCAP_SHA512, 0) \
49+
LINE(AARCH64_SVE, sve, "sve", AARCH64_HWCAP_SVE, 0) \
50+
LINE(AARCH64_ASIMDFHM, asimdfhm, "asimdfhm", AARCH64_HWCAP_ASIMDFHM, 0) \
51+
LINE(AARCH64_DIT, dit, "dit", AARCH64_HWCAP_DIT, 0) \
52+
LINE(AARCH64_USCAT, uscat, "uscat", AARCH64_HWCAP_USCAT, 0) \
53+
LINE(AARCH64_ILRCPC, ilrcpc, "ilrcpc", AARCH64_HWCAP_ILRCPC, 0) \
54+
LINE(AARCH64_FLAGM, flagm, "flagm", AARCH64_HWCAP_FLAGM, 0) \
55+
LINE(AARCH64_SSBS, ssbs, "ssbs", AARCH64_HWCAP_SSBS, 0) \
56+
LINE(AARCH64_SB, sb, "sb", AARCH64_HWCAP_SB, 0) \
57+
LINE(AARCH64_PACA, paca, "paca", AARCH64_HWCAP_PACA, 0) \
58+
LINE(AARCH64_PACG, pacg, "pacg", AARCH64_HWCAP_PACG, 0) \
59+
LINE(AARCH64_DCPODP, dcpodp, "dcpodp", 0, AARCH64_HWCAP2_DCPODP) \
60+
LINE(AARCH64_SVE2, sve2, "sve2", 0, AARCH64_HWCAP2_SVE2) \
61+
LINE(AARCH64_SVEAES, sveaes, "sveaes", 0, AARCH64_HWCAP2_SVEAES) \
62+
LINE(AARCH64_SVEPMULL, svepmull, "svepmull", 0, AARCH64_HWCAP2_SVEPMULL) \
63+
LINE(AARCH64_SVEBITPERM, svebitperm, "svebitperm", 0, \
64+
AARCH64_HWCAP2_SVEBITPERM) \
65+
LINE(AARCH64_SVESHA3, svesha3, "svesha3", 0, AARCH64_HWCAP2_SVESHA3) \
66+
LINE(AARCH64_SVESM4, svesm4, "svesm4", 0, AARCH64_HWCAP2_SVESM4) \
67+
LINE(AARCH64_FLAGM2, flagm2, "flagm2", 0, AARCH64_HWCAP2_FLAGM2) \
68+
LINE(AARCH64_FRINT, frint, "frint", 0, AARCH64_HWCAP2_FRINT) \
69+
LINE(AARCH64_SVEI8MM, svei8mm, "svei8mm", 0, AARCH64_HWCAP2_SVEI8MM) \
70+
LINE(AARCH64_SVEF32MM, svef32mm, "svef32mm", 0, AARCH64_HWCAP2_SVEF32MM) \
71+
LINE(AARCH64_SVEF64MM, svef64mm, "svef64mm", 0, AARCH64_HWCAP2_SVEF64MM) \
72+
LINE(AARCH64_SVEBF16, svebf16, "svebf16", 0, AARCH64_HWCAP2_SVEBF16) \
73+
LINE(AARCH64_I8MM, i8mm, "i8mm", 0, AARCH64_HWCAP2_I8MM) \
74+
LINE(AARCH64_BF16, bf16, "bf16", 0, AARCH64_HWCAP2_BF16) \
75+
LINE(AARCH64_DGH, dgh, "dgh", 0, AARCH64_HWCAP2_DGH) \
76+
LINE(AARCH64_RNG, rng, "rng", 0, AARCH64_HWCAP2_RNG) \
77+
LINE(AARCH64_BTI, bti, "bti", 0, AARCH64_HWCAP2_BTI) \
78+
LINE(AARCH64_MTE, mte, "mte", 0, AARCH64_HWCAP2_MTE)
79+
#define INTROSPECTION_PREFIX Aarch64
80+
#define INTROSPECTION_ENUM_PREFIX AARCH64
81+
#include "define_introspection_and_hwcaps.inl"
82+
83+
////////////////////////////////////////////////////////////////////////////////
84+
// Implementation.
85+
////////////////////////////////////////////////////////////////////////////////
86+
87+
#include <stdbool.h>
88+
89+
#include "internal/bit_utils.h"
90+
#include "internal/filesystem.h"
91+
#include "internal/stack_line_reader.h"
92+
#include "internal/string_view.h"
93+
94+
static bool HandleAarch64Line(const LineResult result, Aarch64Info* const info);
95+
96+
static void FillProcCpuInfoData(Aarch64Info* const info);
97+
98+
#endif // defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID) ||
99+
// defined(CPU_FEATURES_OS_MACOS)
100+
#endif // CPU_FEATURES_ARCH_AARCH64

src/impl_aarch64_linux_or_android.c

Lines changed: 1 addition & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -17,78 +17,7 @@
1717
#ifdef CPU_FEATURES_ARCH_AARCH64
1818
#if defined(CPU_FEATURES_OS_LINUX) || defined(CPU_FEATURES_OS_ANDROID)
1919

20-
#include "cpuinfo_aarch64.h"
21-
22-
////////////////////////////////////////////////////////////////////////////////
23-
// Definitions for introspection.
24-
////////////////////////////////////////////////////////////////////////////////
25-
#define INTROSPECTION_TABLE \
26-
LINE(AARCH64_FP, fp, "fp", AARCH64_HWCAP_FP, 0) \
27-
LINE(AARCH64_ASIMD, asimd, "asimd", AARCH64_HWCAP_ASIMD, 0) \
28-
LINE(AARCH64_EVTSTRM, evtstrm, "evtstrm", AARCH64_HWCAP_EVTSTRM, 0) \
29-
LINE(AARCH64_AES, aes, "aes", AARCH64_HWCAP_AES, 0) \
30-
LINE(AARCH64_PMULL, pmull, "pmull", AARCH64_HWCAP_PMULL, 0) \
31-
LINE(AARCH64_SHA1, sha1, "sha1", AARCH64_HWCAP_SHA1, 0) \
32-
LINE(AARCH64_SHA2, sha2, "sha2", AARCH64_HWCAP_SHA2, 0) \
33-
LINE(AARCH64_CRC32, crc32, "crc32", AARCH64_HWCAP_CRC32, 0) \
34-
LINE(AARCH64_ATOMICS, atomics, "atomics", AARCH64_HWCAP_ATOMICS, 0) \
35-
LINE(AARCH64_FPHP, fphp, "fphp", AARCH64_HWCAP_FPHP, 0) \
36-
LINE(AARCH64_ASIMDHP, asimdhp, "asimdhp", AARCH64_HWCAP_ASIMDHP, 0) \
37-
LINE(AARCH64_CPUID, cpuid, "cpuid", AARCH64_HWCAP_CPUID, 0) \
38-
LINE(AARCH64_ASIMDRDM, asimdrdm, "asimdrdm", AARCH64_HWCAP_ASIMDRDM, 0) \
39-
LINE(AARCH64_JSCVT, jscvt, "jscvt", AARCH64_HWCAP_JSCVT, 0) \
40-
LINE(AARCH64_FCMA, fcma, "fcma", AARCH64_HWCAP_FCMA, 0) \
41-
LINE(AARCH64_LRCPC, lrcpc, "lrcpc", AARCH64_HWCAP_LRCPC, 0) \
42-
LINE(AARCH64_DCPOP, dcpop, "dcpop", AARCH64_HWCAP_DCPOP, 0) \
43-
LINE(AARCH64_SHA3, sha3, "sha3", AARCH64_HWCAP_SHA3, 0) \
44-
LINE(AARCH64_SM3, sm3, "sm3", AARCH64_HWCAP_SM3, 0) \
45-
LINE(AARCH64_SM4, sm4, "sm4", AARCH64_HWCAP_SM4, 0) \
46-
LINE(AARCH64_ASIMDDP, asimddp, "asimddp", AARCH64_HWCAP_ASIMDDP, 0) \
47-
LINE(AARCH64_SHA512, sha512, "sha512", AARCH64_HWCAP_SHA512, 0) \
48-
LINE(AARCH64_SVE, sve, "sve", AARCH64_HWCAP_SVE, 0) \
49-
LINE(AARCH64_ASIMDFHM, asimdfhm, "asimdfhm", AARCH64_HWCAP_ASIMDFHM, 0) \
50-
LINE(AARCH64_DIT, dit, "dit", AARCH64_HWCAP_DIT, 0) \
51-
LINE(AARCH64_USCAT, uscat, "uscat", AARCH64_HWCAP_USCAT, 0) \
52-
LINE(AARCH64_ILRCPC, ilrcpc, "ilrcpc", AARCH64_HWCAP_ILRCPC, 0) \
53-
LINE(AARCH64_FLAGM, flagm, "flagm", AARCH64_HWCAP_FLAGM, 0) \
54-
LINE(AARCH64_SSBS, ssbs, "ssbs", AARCH64_HWCAP_SSBS, 0) \
55-
LINE(AARCH64_SB, sb, "sb", AARCH64_HWCAP_SB, 0) \
56-
LINE(AARCH64_PACA, paca, "paca", AARCH64_HWCAP_PACA, 0) \
57-
LINE(AARCH64_PACG, pacg, "pacg", AARCH64_HWCAP_PACG, 0) \
58-
LINE(AARCH64_DCPODP, dcpodp, "dcpodp", 0, AARCH64_HWCAP2_DCPODP) \
59-
LINE(AARCH64_SVE2, sve2, "sve2", 0, AARCH64_HWCAP2_SVE2) \
60-
LINE(AARCH64_SVEAES, sveaes, "sveaes", 0, AARCH64_HWCAP2_SVEAES) \
61-
LINE(AARCH64_SVEPMULL, svepmull, "svepmull", 0, AARCH64_HWCAP2_SVEPMULL) \
62-
LINE(AARCH64_SVEBITPERM, svebitperm, "svebitperm", 0, \
63-
AARCH64_HWCAP2_SVEBITPERM) \
64-
LINE(AARCH64_SVESHA3, svesha3, "svesha3", 0, AARCH64_HWCAP2_SVESHA3) \
65-
LINE(AARCH64_SVESM4, svesm4, "svesm4", 0, AARCH64_HWCAP2_SVESM4) \
66-
LINE(AARCH64_FLAGM2, flagm2, "flagm2", 0, AARCH64_HWCAP2_FLAGM2) \
67-
LINE(AARCH64_FRINT, frint, "frint", 0, AARCH64_HWCAP2_FRINT) \
68-
LINE(AARCH64_SVEI8MM, svei8mm, "svei8mm", 0, AARCH64_HWCAP2_SVEI8MM) \
69-
LINE(AARCH64_SVEF32MM, svef32mm, "svef32mm", 0, AARCH64_HWCAP2_SVEF32MM) \
70-
LINE(AARCH64_SVEF64MM, svef64mm, "svef64mm", 0, AARCH64_HWCAP2_SVEF64MM) \
71-
LINE(AARCH64_SVEBF16, svebf16, "svebf16", 0, AARCH64_HWCAP2_SVEBF16) \
72-
LINE(AARCH64_I8MM, i8mm, "i8mm", 0, AARCH64_HWCAP2_I8MM) \
73-
LINE(AARCH64_BF16, bf16, "bf16", 0, AARCH64_HWCAP2_BF16) \
74-
LINE(AARCH64_DGH, dgh, "dgh", 0, AARCH64_HWCAP2_DGH) \
75-
LINE(AARCH64_RNG, rng, "rng", 0, AARCH64_HWCAP2_RNG) \
76-
LINE(AARCH64_BTI, bti, "bti", 0, AARCH64_HWCAP2_BTI) \
77-
LINE(AARCH64_MTE, mte, "mte", 0, AARCH64_HWCAP2_MTE)
78-
#define INTROSPECTION_PREFIX Aarch64
79-
#define INTROSPECTION_ENUM_PREFIX AARCH64
80-
#include "define_introspection_and_hwcaps.inl"
81-
82-
////////////////////////////////////////////////////////////////////////////////
83-
// Implementation.
84-
////////////////////////////////////////////////////////////////////////////////
85-
86-
#include <stdbool.h>
87-
88-
#include "internal/bit_utils.h"
89-
#include "internal/filesystem.h"
90-
#include "internal/stack_line_reader.h"
91-
#include "internal/string_view.h"
20+
#include "impl_aarch64__base_implementation.inl"
9221

9322
static bool HandleAarch64Line(const LineResult result,
9423
Aarch64Info* const info) {

src/impl_aarch64_macos.c

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// Copyright 2021 Google LLC
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
#include "cpu_features_macros.h"
16+
17+
#ifdef CPU_FEATURES_ARCH_AARCH64
18+
#ifdef CPU_FEATURES_OS_MACOS
19+
20+
#include "impl_aarch64__base_implementation.inl"
21+
22+
#if !defined(HAVE_SYSCTLBYNAME)
23+
#error "Darwin needs support for sysctlbyname"
24+
#endif
25+
#include <sys/sysctl.h>
26+
27+
#if defined(CPU_FEATURES_MOCK_SYSCTL_AARCH64)
28+
extern bool GetDarwinSysCtlByName(const char*);
29+
extern int GetDarwinSysCtlByNameValue(const char* name);
30+
#else
31+
static int GetDarwinSysCtlByNameValue(const char* name) {
32+
int enabled;
33+
size_t enabled_len = sizeof(enabled);
34+
const int failure = sysctlbyname(name, &enabled, &enabled_len, NULL, 0);
35+
return failure ? 0 : enabled;
36+
}
37+
38+
static bool GetDarwinSysCtlByName(const char* name) {
39+
return !!GetDarwinSysCtlByNameValue(name);
40+
}
41+
#endif
42+
43+
static const Aarch64Info kEmptyAarch64Info;
44+
45+
Aarch64Info GetAarch64Info(void) {
46+
Aarch64Info info = kEmptyAarch64Info;
47+
48+
// Handling Darwin platform through sysctlbyname.
49+
info.implementer = GetDarwinSysCtlByNameValue("hw.cputype");
50+
info.variant = GetDarwinSysCtlByNameValue("hw.cpusubtype");
51+
info.part = GetDarwinSysCtlByNameValue("hw.cpufamily");
52+
info.revision = GetDarwinSysCtlByNameValue("hw.cpusubfamily");
53+
54+
info.features.fp = GetDarwinSysCtlByName("hw.optional.floatingpoint");
55+
info.features.asimd = GetDarwinSysCtlByName("hw.optional.AdvSIMD");
56+
info.features.aes = GetDarwinSysCtlByName("hw.optional.arm.FEAT_AES");
57+
info.features.pmull = GetDarwinSysCtlByName("hw.optional.arm.FEAT_PMULL");
58+
info.features.sha1 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA1");
59+
info.features.sha2 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SHA2");
60+
info.features.crc32 = GetDarwinSysCtlByName("hw.optional.armv8_crc32");
61+
info.features.atomics = GetDarwinSysCtlByName("hw.optional.armv8_1_atomics");
62+
info.features.fphp = GetDarwinSysCtlByName("hw.optional.neon_hpfp");
63+
info.features.jscvt = GetDarwinSysCtlByName("hw.optional.arm.FEAT_JSCVT");
64+
info.features.fcma = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FCMA");
65+
info.features.lrcpc = GetDarwinSysCtlByName("hw.optional.arm.FEAT_LRCPC");
66+
info.features.sha3 = GetDarwinSysCtlByName("hw.optional.armv8_2_sha3");
67+
info.features.sha512 = GetDarwinSysCtlByName("hw.optional.armv8_2_sha512");
68+
info.features.asimdfhm = GetDarwinSysCtlByName("hw.optional.armv8_2_fhm");
69+
info.features.flagm = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FLAGM");
70+
info.features.flagm2 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_FLAGM2");
71+
info.features.ssbs = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SSBS");
72+
info.features.sb = GetDarwinSysCtlByName("hw.optional.arm.FEAT_SB");
73+
info.features.i8mm = GetDarwinSysCtlByName("hw.optional.arm.FEAT_I8MM");
74+
info.features.bf16 = GetDarwinSysCtlByName("hw.optional.arm.FEAT_BF16");
75+
info.features.bti = GetDarwinSysCtlByName("hw.optional.arm.FEAT_BTI");
76+
77+
return info;
78+
}
79+
80+
#endif // CPU_FEATURES_OS_MACOS
81+
#endif // CPU_FEATURES_ARCH_X86

test/CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ endif()
7171
##------------------------------------------------------------------------------
7272
## cpuinfo_aarch64_test
7373
if(PROCESSOR_IS_AARCH64)
74-
add_executable(cpuinfo_aarch64_test cpuinfo_aarch64_test.cc ../src/impl_aarch64_linux_or_android.c)
74+
add_executable(cpuinfo_aarch64_test
75+
cpuinfo_aarch64_test.cc
76+
../src/impl_aarch64_linux_or_android.c
77+
../src/impl_aarch64_macos.c
78+
)
79+
if(APPLE)
80+
target_compile_definitions(cpuinfo_aarch64_test PUBLIC CPU_FEATURES_MOCK_SYSCTL_AARCH64)
81+
target_compile_definitions(cpuinfo_aarch64_test PRIVATE HAVE_SYSCTLBYNAME)
82+
endif()
7583
target_link_libraries(cpuinfo_aarch64_test all_libraries)
7684
add_test(NAME cpuinfo_aarch64_test COMMAND cpuinfo_aarch64_test)
7785
endif()

0 commit comments

Comments
 (0)