From 7e60069968d538b2f8d51649fa46b3ca574a9218 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Fri, 16 Feb 2018 11:01:04 -0500 Subject: [PATCH] add uncommitted files --- libi2pd/CPU.cpp | 34 ++++++++++++++++++++++++++++++++++ libi2pd/CPU.h | 15 +++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 libi2pd/CPU.cpp create mode 100644 libi2pd/CPU.h diff --git a/libi2pd/CPU.cpp b/libi2pd/CPU.cpp new file mode 100644 index 00000000..96beaf78 --- /dev/null +++ b/libi2pd/CPU.cpp @@ -0,0 +1,34 @@ +#include "CPU.h" +#if defined(__x86_64__) || defined(__i386__) +#include +#endif +#include "Log.h" +namespace i2p +{ +namespace cpu +{ + bool aesni = false; + bool avx = false; + + void Detect() + { +#if defined(__x86_64__) || defined(__i386__) + int info[4]; + __cpuid(0, info[0], info[1], info[2], info[3]); + if (info[0] >= 0x00000001) { + __cpuid(0x00000001, info[0], info[1], info[2], info[3]); + aesni = info[2] & bit_AES; // AESNI + avx = info[2] & bit_AVX; // AVX + } +#endif + if(aesni) + { + LogPrint(eLogInfo, "AESNI enabled"); + } + if(avx) + { + LogPrint(eLogInfo, "AVX enabled"); + } + } +} +} diff --git a/libi2pd/CPU.h b/libi2pd/CPU.h new file mode 100644 index 00000000..b4c19607 --- /dev/null +++ b/libi2pd/CPU.h @@ -0,0 +1,15 @@ +#ifndef LIBI2PD_CPU_H +#define LIBI2PD_CPU_H + +namespace i2p +{ +namespace cpu +{ + extern bool aesni; + extern bool avx; + + void Detect(); +} +} + +#endif