-
Notifications
You must be signed in to change notification settings - Fork 425
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[cpu] remove avx detect and code blocks, try to switch to __builtin
Signed-off-by: r4sas <[email protected]>
- Loading branch information
Showing
9 changed files
with
20 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,32 @@ | ||
/* | ||
* Copyright (c) 2013-2020, The PurpleI2P Project | ||
* Copyright (c) 2013-2023, The PurpleI2P Project | ||
* | ||
* This file is part of Purple i2pd project and licensed under BSD3 | ||
* | ||
* See full license text in LICENSE file at top of project tree | ||
*/ | ||
|
||
#include "CPU.h" | ||
#if defined(__x86_64__) || defined(__i386__) | ||
#include <cpuid.h> | ||
#endif | ||
#include "Log.h" | ||
|
||
#ifndef bit_AES | ||
#define bit_AES (1 << 25) | ||
#endif | ||
#ifndef bit_AVX | ||
#define bit_AVX (1 << 28) | ||
#endif | ||
|
||
|
||
namespace i2p | ||
{ | ||
namespace cpu | ||
{ | ||
bool aesni = false; | ||
bool avx = false; | ||
|
||
void Detect(bool AesSwitch, bool AvxSwitch, bool force) | ||
void Detect(bool AesSwitch, bool force) | ||
{ | ||
#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]); | ||
#if defined (_WIN32) && (WINVER == 0x0501) // WinXP | ||
if (AesSwitch && force) { // only if forced | ||
#else | ||
if ((info[2] & bit_AES && AesSwitch) || (AesSwitch && force)) { | ||
#endif | ||
aesni = true; | ||
} | ||
__builtin_cpu_init (); | ||
#if defined (_WIN32) && (WINVER == 0x0501) // WinXP | ||
if (AvxSwitch && force) { // only if forced | ||
if (AesSwitch && force) { // only if forced | ||
#else | ||
if ((info[2] & bit_AVX && AvxSwitch) || (AvxSwitch && force)) { | ||
if ((__builtin_cpu_supports ("aes") && AesSwitch) || (AesSwitch && force)) { | ||
#endif | ||
avx = true; | ||
} | ||
aesni = true; | ||
} | ||
#endif // defined(__x86_64__) || defined(__i386__) | ||
|
||
LogPrint(eLogInfo, "AESNI ", (aesni ? "enabled" : "disabled")); | ||
LogPrint(eLogInfo, "AVX ", (avx ? "enabled" : "disabled")); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters