forked from TunSafe/TunSafe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tunsafe_cpu.h
43 lines (29 loc) · 1.09 KB
/
tunsafe_cpu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: AGPL-1.0-only
// Copyright (C) 2018 Ludvig Strigeus <[email protected]>. All Rights Reserved.
#ifndef TUNSAFE_CPU_H_
#define TUNSAFE_CPU_H_
#include "tunsafe_types.h"
#if defined(ARCH_CPU_X86_FAMILY)
extern uint32 x86_pcap[3];
// cpuid 1, edx
#define X86_PCAP_SSE (x86_pcap[0] & (1 << 25))
#define X86_PCAP_SSE2 (x86_pcap[0] & (1 << 26))
// cpuid 1, ecx
#define X86_PCAP_SSE3 (x86_pcap[1] & (1 << 0))
#define X86_PCAP_PCLMULQDQ (x86_pcap[1] & (1 << 0))
#define X86_PCAP_SSSE3 (x86_pcap[1] & (1 << 9))
#define X86_PCAP_MOVBE (x86_pcap[1] & (1 << 22))
#define X86_PCAP_AES (x86_pcap[1] & (1 << 25))
#define X86_PCAP_AVX (x86_pcap[1] & (1 << 28))
// cpuid 7, ebx
#define X86_PCAP_AVX2 (x86_pcap[2] & (1 << 5))
#define X86_PCAP_AVX512F (x86_pcap[2] & (1 << 16))
#define X86_PCAP_AVX512VL (x86_pcap[2] & (1 << 31))
#endif // defined(ARCH_CPU_X86_FAMILY)
#if defined(ARCH_CPU_ARM_FAMILY)
extern uint32 arm_pcap[1];
#define ARM_PCAP_NEON (arm_pcap[0] & (1 << 0))
#endif // defined(ARCH_CPU_ARM_FAMILY)
void InitCpuFeatures();
void PrintCpuFeatures();
#endif // TUNSAFE_CPU_H_