tunsafe-clang15/tunsafe_cpu.h
2018-08-08 13:53:31 +02:00

29 lines
No EOL
884 B
C

// SPDX-License-Identifier: AGPL-1.0-only
// Copyright (C) 2018 Ludvig Strigeus <info@tunsafe.com>. All Rights Reserved.
#ifndef TUNSAFE_CPU_H_
#define TUNSAFE_CPU_H_
#include "tunsafe_types.h"
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))
void InitCpuFeatures();
void PrintCpuFeatures();
#endif // TUNSAFE_CPU_H_