Compare commits

...

8 Commits

Author SHA1 Message Date
bce48fe121 Fixed "System::OpenURI". Added SHA256. Added URI safe Base64 methods.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 6m9s
Build & Release / Linux-AMD64-Build (push) Successful in 15m26s
Build & Release / Linux-AARCH64-Build (push) Successful in 45m54s
2025-05-11 19:43:50 -07:00
2cb01a7c65 Fixed Windows CI/CD and fixed AVX on AARCH64 again.
All checks were successful
Build & Release / Windows-AMD64-Build (push) Successful in 5m35s
Build & Release / Linux-AMD64-Build (push) Successful in 15m24s
Build & Release / Linux-AARCH64-Build (push) Successful in 45m55s
2025-05-09 19:43:05 -07:00
3025b76bec Fixed AVX undefined symbols on AARCH64 and removed AVX from ehs::Util::Compare.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 31s
Build & Release / Linux-AMD64-Build (push) Successful in 15m25s
Build & Release / Linux-AARCH64-Build (push) Failing after 22m49s
2025-05-09 19:17:09 -07:00
0cec9789b1 Cached CPU features, added AVX2, and AVX512.
Some checks failed
Build & Release / Windows-AMD64-Build (push) Failing after 4m42s
Build & Release / Linux-AMD64-Build (push) Successful in 15m40s
Build & Release / Linux-AARCH64-Build (push) Failing after 45m49s
2025-05-08 22:41:05 -07:00
63eba0d2db Fixed Str constructor not to check for a null-terminator if given a size of zero. 2025-05-02 07:01:40 -07:00
c5b281d73c Added String<T, N>.ParseArgs(). 2025-04-14 13:40:00 -07:00
8d28f3547c Merge remote-tracking branch 'origin/NetChannels' into NetChannels 2025-04-14 00:27:26 -07:00
a7f09382fd Fixed vector. 2025-04-14 00:22:10 -07:00
29 changed files with 1573 additions and 369 deletions

View File

@ -35,6 +35,8 @@ jobs:
mv build/Release/EHS_Dyn.dll bin
mv build/Release/StrToHash.exe bin
mv build/Release/zlib1.dll bin
mv build/Release/libcrypto-3-x64.dll bin
mv build/Release/libssl-3-x64.dll bin
mkdir lib
mv build/Release/EHS_Stc.lib lib
mv build/Release/EHS_Dyn.lib lib

View File

@ -51,6 +51,7 @@ set(EHS_SOURCES
src/Color3.cpp include/ehs/Color3.h
src/Version.cpp include/ehs/Version.h
src/Base64.cpp include/ehs/Base64.h
src/SHA256.cpp include/ehs/SHA256.h
src/Data.cpp include/ehs/Data.h
src/Range.cpp include/ehs/Range.h
src/Util.cpp include/ehs/Util.h
@ -97,6 +98,8 @@ set(EHS_SOURCES
include/ehs/system/OS.h
include/ehs/system/Semaphore.h
include/ehs/system/System.h
include/ehs/system/AVX2.h
include/ehs/system/AVX512.h
src/json/Json.cpp include/ehs/json/Json.h
src/json/JsonBase.cpp include/ehs/json/JsonBase.h
@ -215,6 +218,7 @@ if (IS_OS_WINDOWS)
src/system/CPU_MSVC_AMD64.asm src/HRNG_MSVC.asm src/Math_MSVC_AMD64.asm
src/io/Directory_W32.cpp include/ehs/io/Directory_W32.h
include/ehs/io/socket/ICMP_W32.h src/io/socket/ICMP_W32.cpp
src/system/AVX2_MSVC_AMD64.asm src/system/AVX512_MSVC_AMD64.asm
)
elseif (IS_OS_LINUX)
@ -252,9 +256,9 @@ elseif (IS_OS_LINUX)
endif ()
if (IS_ARCH_AMD64)
list(APPEND EHS_SOURCES src/system/CPU_GCC_AMD64.asm src/HRNG_GCC.asm src/Math_GCC_AMD64.asm)
list(APPEND EHS_SOURCES src/system/CPU_GCC_AMD64.asm src/HRNG_GCC.asm src/Math_GCC_AMD64.asm src/system/AVX2_GCC_AMD64.asm src/system/AVX512_GCC_AMD64.asm)
elseif (IS_ARCH_ARM64)
list(APPEND EHS_SOURCES src/system/CPU_ARM64.cpp src/HRNG_ARM64.cpp src/Math_GCC_ARM64.s)
list(APPEND EHS_SOURCES src/system/CPU_ARM64.cpp src/HRNG_ARM64.cpp src/Math_GCC_ARM64.s src/system/AVX2_AARCH64.cpp src/system/AVX512_AARCH64.cpp)
endif ()
endif()

View File

@ -8,17 +8,26 @@ namespace ehs
class EHS_LIB_IO Base64
{
private:
static const char ascii[];
static constexpr UInt_8 asciiUrl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
static constexpr UInt_8 ascii[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
public:
static Str_8 EncodeURL(const Str_8 &input);
static Str_8 Encode(const Str_8 &input);
static Str_8 DecodeURL(const Str_8 &input);
static Str_8 Decode(const Str_8 &input);
private:
static char Find(char c);
static bool IsBase64(char c);
static UInt_8 FindURL(const UInt_8 &c);
static UInt_8 Find(const UInt_8 &c);
static bool IsBase64URL(const UInt_8 &c);
static bool IsBase64(const UInt_8 &c);
};
}

View File

@ -134,17 +134,17 @@ namespace ehs
#ifndef EHS_LOG_INT
#ifdef EHS_DEBUG
#define EHS_LOG_INT(type, code, msg) ehs::Log::Raise({type, {ehs::GetAcronym_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg})
#define EHS_LOG_INT(type, code, msg) ehs::Log::Raise(ehs::Log(type, {ehs::GetAcronym_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg))
#else
#define EHS_LOG_INT(type, code, msg) ehs::Log::Raise({type, {ehs::GetAcronym_8(), EHS_FUNC}, code, msg})
#define EHS_LOG_INT(type, code, msg) ehs::Log::Raise(ehs::Log(type, {ehs::GetAcronym_8(), EHS_FUNC}, code, msg))
#endif
#endif
#ifndef EHS_LOG
#ifdef EHS_DEBUG
#define EHS_LOG(type, code, msg) ehs::Log::Raise({type, {ehs::GetAppName_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg})
#define EHS_LOG(type, code, msg) ehs::Log::Raise(ehs::Log(type, {ehs::GetAppName_8(), EHS_FILE, EHS_FUNC, ehs::Str_8::FromNum((ehs::UInt_32)EHS_LINE)}, code, msg))
#else
#define EHS_LOG(type, code, msg) ehs::Log::Raise({type, {ehs::GetAppName_8(), EHS_FUNC}, code, msg})
#define EHS_LOG(type, code, msg) ehs::Log::Raise(ehs::Log(type, {ehs::GetAppName_8(), EHS_FUNC}, code, msg))
#endif
#endif

59
include/ehs/SHA256.h Normal file
View File

@ -0,0 +1,59 @@
#pragma once
#include "Types.h"
namespace ehs
{
class SHA256
{
private:
static UInt_32 ROTR(UInt_32 x, UInt_32 n);
static UInt_32 CH(UInt_32 x, UInt_32 y, UInt_32 z);
static UInt_32 MAJ(UInt_32 x, UInt_32 y, UInt_32 z);
static UInt_32 EP0(UInt_32 x);
static UInt_32 EP1(UInt_32 x);
static UInt_32 SIG0(UInt_32 x);
static UInt_32 SIG1(UInt_32 x);
static constexpr UInt_32 k[64] = {
0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
};
UInt_32 state[8];
UInt_64 bitLen;
Byte data[64];
UInt_64 dataLen;
public:
SHA256();
SHA256(SHA256 &&other) noexcept;
SHA256(const SHA256 &other);
SHA256 &operator=(SHA256 &&other) noexcept;
SHA256 &operator=(const SHA256 &other);
void Update(const Byte *data, UInt_64 len);
void Final(Byte hash[32]);
void Hash(const Byte *data, UInt_64 len, Byte hash[32]);
private:
void Transform(const Byte data[64]);
};
}

View File

@ -48,8 +48,11 @@ namespace ehs
/// @param [in] str The C-style string.
/// @param [in] size The size of the given C-style string.
Str(const T* const str, const N size)
: size((size) ? size : Len(str)), data(nullptr)
: size(size), data(nullptr)
{
if (!size)
return;
data = new T[this->size + 1];
Util::Copy(data, str, Size(true));
@ -914,10 +917,10 @@ namespace ehs
}
/// Splits a string into a Vector with the given separator.
/// @param [in] ide The given string as the separator.
/// @param [in] delimeter The given string as the separator.
/// @param [in] max The max amount of times to split the string.
/// @returns The resulting string object.
Vector<Str<T, N>, N> Split(const Str<T, N>& ide, const N max = 0) const
Vector<Str<T, N>, N> Split(const Str<T, N>& delimeter, const N max = 0) const
{
Vector<Str<T, N>, N> result(0, 5);
@ -925,9 +928,9 @@ namespace ehs
for (N i = 0, c = 0; i < size; ++i)
{
if (data[i] == ide[c])
if (data[i] == delimeter[c])
{
if (++c == ide.Size())
if (++c == delimeter.Size())
{
N r = i - (c - 1) - b;
if (!r)
@ -955,17 +958,17 @@ namespace ehs
}
/// Removes all instances of the ide.
/// @param [in] ide The string to look for.
/// @param [in] delimeter The string to look for.
/// @returns The resulting string object.
Str<T, N> RemoveAll(const Str<T, N>& ide) const
Str<T, N> RemoveAll(const Str<T, N>& delimeter) const
{
Str<T, N> result(size);
for (N i = 0, b = 0, c = 0; i < size; ++i)
{
if (data[i] == ide[c])
if (data[i] == delimeter[c])
{
if (++c == ide.Size())
if (++c == delimeter.Size())
c = 0;
}
else
@ -984,18 +987,18 @@ namespace ehs
}
/// Replaces all instances of ide with the replacer.
/// @param [in] ide The string to look for.
/// @param [in] delimeter The string to look for.
/// @param [in] replacer The string placed.
/// @returns The resulting string object.
Str ReplaceAll(const Str& ide, const Str& replacer) const
Str ReplaceAll(const Str& delimeter, const Str& replacer) const
{
Str<T, N> result;
for (N i = 0, b = 0; i < size; ++i)
{
if (data[i] == ide[b])
if (data[i] == delimeter[b])
{
if (++b == ide.Size())
if (++b == delimeter.Size())
{
result.Push(replacer);
b = 0;
@ -1011,20 +1014,20 @@ namespace ehs
}
/// Finds the first instance of the given string object.
/// @param [in] ide The string to look for.
/// @param [in] delimeter The string to look for.
/// @param [out] index The index of the string found. Can be a nullptr.
/// @param [in] pattern The search pattern for optimization.
/// @param [in] result What index to return where the first instance is found.
/// @returns The index where the instance was found with the result varying from the result parameter.
bool Find(const Str<T, N> &ide, N* const index = nullptr, const SearchPattern pattern = SearchPattern::LEFT_RIGHT, const IndexResult result = IndexResult::BEGINNING) const
bool Find(const Str<T, N> &delimeter, N* const index = nullptr, const SearchPattern pattern = SearchPattern::LEFT_RIGHT, const IndexResult result = IndexResult::BEGINNING) const
{
if (pattern == SearchPattern::LEFT_RIGHT)
{
for (N i = 0, c = 0; i < size; ++i)
{
if (data[i] == ide[c])
if (data[i] == delimeter[c])
{
if (++c == ide.Size())
if (++c == delimeter.Size())
{
if (result == IndexResult::BEGINNING)
{
@ -1046,16 +1049,16 @@ namespace ehs
}
else if (pattern == SearchPattern::RIGHT_LEFT)
{
for (N i = size, c = ide.Size(); i > 0; --i)
for (N i = size, c = delimeter.Size(); i > 0; --i)
{
if (data[i - 1] == ide[c - 1])
if (data[i - 1] == delimeter[c - 1])
{
if (--c == 0)
{
if (result == IndexResult::BEGINNING)
{
if (index)
*index = i - (ide.Size() - 1);
*index = i - (delimeter.Size() - 1);
return true;
}
@ -1075,18 +1078,18 @@ namespace ehs
}
/// Checks if the current string contains the given ide.
/// @param [in] ide The given ide to check for.
/// @param [in] delimeter The given ide to check for.
/// @param [in] pattern The search pattern to use.
/// @returns True if the current string does contain the ide.
bool Contains(const Str<T, N>& ide, const SearchPattern pattern = SearchPattern::LEFT_RIGHT) const
bool Contains(const Str<T, N>& delimeter, const SearchPattern pattern = SearchPattern::LEFT_RIGHT) const
{
if (pattern == SearchPattern::LEFT_RIGHT)
{
for (N i = 0, c = 0; i < size; ++i)
{
if (data[i] == ide[c])
if (data[i] == delimeter[c])
{
if (++c == ide.Size())
if (++c == delimeter.Size())
{
return true;
}
@ -1095,9 +1098,9 @@ namespace ehs
}
else if (pattern == SearchPattern::RIGHT_LEFT)
{
for (N i = size, c = ide.Size(); i > 0; --i)
for (N i = size, c = delimeter.Size(); i > 0; --i)
{
if (data[i - 1] == ide[c - 1])
if (data[i - 1] == delimeter[c - 1])
{
if (--c == 0)
{
@ -1110,6 +1113,54 @@ namespace ehs
return false;
}
Vector<Str> ParseArgs() const
{
Vector<Str> args;
T *quoteStart = nullptr;
T *spaceStart = nullptr;
for (T *i = data; i <= data + size; ++i)
{
if (*i == '\"' && !spaceStart)
{
if (quoteStart)
{
args.Push(Str(quoteStart, i - quoteStart));
quoteStart = nullptr;
}
else
{
if (i + 1 < &data[size - 1])
quoteStart = i + 1;
else
args.Push({});
}
}
else if (*i == ' ' && !quoteStart)
{
if (spaceStart)
{
args.Push(Str(spaceStart, i - spaceStart));
spaceStart = i + 1;
}
else
{
if (i + 1 < &data[size - 1])
spaceStart = i + 1;
else
args.Push({});
}
}
}
if (quoteStart)
args.Push(Str(quoteStart, &data[size - 1] - (quoteStart - 1)));
else if (spaceStart)
args.Push(Str(spaceStart, &data[size - 1] - (spaceStart - 1)));
return args;
}
/// Checks if the string represents a number. Must not have any alphabetical characters.
/// @returns The result.
bool IsNum() const

View File

@ -392,7 +392,7 @@ namespace ehs
{
if (stride)
{
rawSize = (this->size + size()) / stride * stride;
rawSize = (this->size + size) / stride * stride;
if ((this->size + size) % stride)
rawSize += stride;
}
@ -403,7 +403,7 @@ namespace ehs
T* result = new T[rawSize];
for (N i = 0; i < size; ++i)
for (N i = 0; i < this->size; ++i)
result[i] = std::move(data[i]);
delete[] data;

36
include/ehs/system/AVX2.h Normal file
View File

@ -0,0 +1,36 @@
#pragma once
#include "ehs/Types.h"
namespace ehs
{
class AVX2
{
public:
/// Compares two unaligned 4 element vectors using 64-bit integers.
/// @param [in] a First vector.
/// @param [in] b Second vector.
/// @returns True if all 4 elements are equal. False otherwise.
static bool CompareUnaligned(const UInt_64 *a, const UInt_64 *b);
/// Compares two unaligned 4 element vectors using 64-bit integers.
/// @param [in] a First vector.
/// @param [in] b Second vector.
/// @returns True if all 4 elements are equal. False otherwise.
static bool CompareUnaligned(const SInt_64 *a, const SInt_64 *b);
/// Compares two aligned 4 element vectors using 64-bit integers.
/// @param [in] a First vector.
/// @param [in] b Second vector.
/// @returns True if all 4 elements are equal. False otherwise.
/// @note The parameters "a", and "b" must have alignas(32).
static bool CompareAligned(const UInt_64 *a, const UInt_64 *b);
/// Compares two aligned 4 element vectors using 64-bit integers.
/// @param [in] a First vector.
/// @param [in] b Second vector.
/// @returns True if all 4 elements are equal. False otherwise.
/// @note The parameters "a", and "b" must have alignas(32).
static bool CompareAligned(const SInt_64 *a, const SInt_64 *b);
};
}

View File

@ -0,0 +1,36 @@
#pragma once
#include "ehs/Types.h"
namespace ehs
{
class AVX512
{
public:
/// Compares two unaligned 8 element vectors using 64-bit integers.
/// @param [in] a First vector.
/// @param [in] b Second vector.
/// @returns True if all 8 elements are equal. False otherwise.
static bool CompareUnaligned(const UInt_64 *a, const UInt_64 *b);
/// Compares two unaligned 8 element vectors using 64-bit integers.
/// @param [in] a First vector.
/// @param [in] b Second vector.
/// @returns True if all 8 elements are equal. False otherwise.
static bool CompareUnaligned(const SInt_64 *a, const SInt_64 *b);
/// Compares two aligned 8 element vectors using 64-bit integers.
/// @param [in] a First vector.
/// @param [in] b Second vector.
/// @returns True if all 8 elements are equal. False otherwise.
/// @note The parameters "a", and "b" must have alignas(32).
static bool CompareAligned(const UInt_64 *a, const UInt_64 *b);
/// Compares two aligned 8 element vectors using 64-bit integers.
/// @param [in] a First vector.
/// @param [in] b Second vector.
/// @returns True if all 8 elements are equal. False otherwise.
/// @note The parameters "a", and "b" must have alignas(32).
static bool CompareAligned(const SInt_64 *a, const SInt_64 *b);
};
}

View File

@ -8,7 +8,7 @@ namespace ehs
class EHS_LIB_IO BaseSystem
{
public:
static void OpenURI(const Str_8& uri);
static void OpenURI(Str_8 uri);
static Str_8 OpenFileDialog(const Str_8 &dir, const Str_8 &filters);

View File

@ -38,6 +38,70 @@ namespace ehs
#endif
public:
static const bool hasFPU;
static const bool hasVME;
static const bool hasDE;
static const bool hasPSE;
static const bool hasTSC;
static const bool hasMSR;
static const bool hasPAE;
static const bool hasMCE;
static const bool hasCX8;
static const bool hasAPIC;
static const bool hasSEP;
static const bool hasMTRR;
static const bool hasPGE;
static const bool hasMCA;
static const bool hasCMOV;
static const bool hasPSE_36;
static const bool hasPSN;
static const bool hasCLFSH;
static const bool hasDS;
static const bool hasACPI;
static const bool hasMMX;
static const bool hasFXSR;
static const bool hasSSE;
static const bool hasSSE2;
static const bool hasSS;
static const bool hasHTT;
static const bool hasTM;
static const bool hasIA64;
static const bool hasPBE;
static const bool hasSSE3;
static const bool hasPCLMULQDQ;
static const bool hasDTES64;
static const bool hasMONITOR;
static const bool hasVMX;
static const bool hasSMX;
static const bool hasEST;
static const bool hasTM2;
static const bool hasSSSE3;
static const bool hasCNXT_ID;
static const bool hasSDBG;
static const bool hasFMA;
static const bool hasCX16;
static const bool hasXTPR;
static const bool hasPDCM;
static const bool hasPCID;
static const bool hasDCA;
static const bool hasSSE4_1;
static const bool hasSSE4_2;
static const bool hasX2APIC;
static const bool hasMOVBE;
static const bool hasPOPCNT;
static const bool hasTSC_DEADLINE;
static const bool hasAES;
static const bool hasXSAVE;
static const bool hasOSXSAVE;
static const bool hasAVX;
static const bool hasF16C;
static const bool hasRDRND;
static const bool hasHYPERVISOR;
static const bool hasAVX2;
static const bool hasAVX512F;
static const bool hasRDSEED;
static const bool hasADX;
static Architecture GetArchitecture();
static UInt_8 PointerSize();
@ -68,153 +132,155 @@ namespace ehs
static UInt_8 GetExtFamilyId();
static UInt_32 GetFeatureBits_1();
static bool HasFPU();
static bool HasVME();
static bool HasDE();
static bool HasPSE();
static bool HasTSC();
static bool HasMSR();
static bool HasPAE();
static bool HasMCE();
static bool HasCX8();
static bool HasAPIC();
static bool HasSEP();
static bool HasMTRR();
static bool HasPGE();
static bool HasMCA();
static bool HasCMOV();
static bool HasPAT();
static bool HasPSE_36();
static bool HasPSN();
static bool HasCLFSH();
static bool HasDS();
static bool HasACPI();
static bool HasMMX();
static bool HasFXSR();
static bool HasSSE();
static bool HasSSE2();
static bool HasSS();
static bool HasHTT();
static bool HasTM();
static bool HasIA64();
static bool HasPBE();
static UInt_32 GetFeatureBits_2();
static bool HasSSE3();
static bool HasPCLMULQDQ();
static bool HasDTES64();
static bool HasMONITOR();
static bool HasDS_CPL();
static bool HasVMX();
static bool HasSMX();
static bool HasEST();
static bool HasTM2();
static bool HasSSSE3();
static bool HasCNXT_ID();
static bool HasSDBG();
static bool HasFMA();
static bool HasCX16();
static bool HasXTPR();
static bool HasPDCM();
static bool HasPCID();
static bool HasDCA();
static bool HasSSE4_1();
static bool HasSSE4_2();
static bool HasX2APIC();
static bool HasMOVBE();
static bool HasPOPCNT();
static bool HasTSC_DEADLINE();
static bool HasAES();
static bool HasXSAVE();
static bool HasOSXSAVE();
static bool HasAVX();
static bool HasF16C();
static bool HasRDRND();
static bool HasHYPERVISOR();
static UInt_32 GetExtFeatureBits_1();
static bool HasAVX2();
static bool HasRDSEED();
static bool HasADX();
static UInt_32 GetExtFeatureBits_2();
static UInt_32 GetExtFeatureBits_3();
/// Retrieves the CPU brand as a null-terminated ASCII string.
/// @param[out] input A 48 byte character array representing the brand.
/// Retrieves the CPU brand as a null-terminated ASCII string.
/// @param[out] input A 48 byte character array representing the brand.
static void GetBrand(Char_8* input);
static UInt_8 GetCacheLineSize();
static UInt_32 GetFeatureBits_1();
static UInt_32 GetFeatureBits_2();
static UInt_32 GetExtFeatureBits_1();
static UInt_32 GetExtFeatureBits_2();
static UInt_32 GetExtFeatureBits_3();
private:
static bool RetrieveFPU();
static bool RetrieveVME();
static bool RetrieveDE();
static bool RetrievePSE();
static bool RetrieveTSC();
static bool RetrieveMSR();
static bool RetrievePAE();
static bool RetrieveMCE();
static bool RetrieveCX8();
static bool RetrieveAPIC();
static bool RetrieveSEP();
static bool RetrieveMTRR();
static bool RetrievePGE();
static bool RetrieveMCA();
static bool RetrieveCMOV();
static bool RetrievePAT();
static bool RetrievePSE_36();
static bool RetrievePSN();
static bool RetrieveCLFSH();
static bool RetrieveDS();
static bool RetrieveACPI();
static bool RetrieveMMX();
static bool RetrieveFXSR();
static bool RetrieveSSE();
static bool RetrieveSSE2();
static bool RetrieveSS();
static bool RetrieveHTT();
static bool RetrieveTM();
static bool RetrieveIA64();
static bool RetrievePBE();
static bool RetrieveSSE3();
static bool RetrievePCLMULQDQ();
static bool RetrieveDTES64();
static bool RetrieveMONITOR();
static bool RetrieveDS_CPL();
static bool RetrieveVMX();
static bool RetrieveSMX();
static bool RetrieveEST();
static bool RetrieveTM2();
static bool RetrieveSSSE3();
static bool RetrieveCNXT_ID();
static bool RetrieveSDBG();
static bool RetrieveFMA();
static bool RetrieveCX16();
static bool RetrieveXTPR();
static bool RetrievePDCM();
static bool RetrievePCID();
static bool RetrieveDCA();
static bool RetrieveSSE4_1();
static bool RetrieveSSE4_2();
static bool RetrieveX2APIC();
static bool RetrieveMOVBE();
static bool RetrievePOPCNT();
static bool RetrieveTSC_DEADLINE();
static bool RetrieveAES();
static bool RetrieveXSAVE();
static bool RetrieveOSXSAVE();
static bool RetrieveAVX();
static bool RetrieveF16C();
static bool RetrieveRDRND();
static bool RetrieveHYPERVISOR();
static bool RetrieveAVX2();
static bool RetrieveAVX512F();
static bool RetrieveRDSEED();
static bool RetrieveADX();
//static Str_8 ToStr();
private:
static UInt_64 RetrieveTSC_Freq();
static UInt_64 CalculateTSC_Freq();

View File

@ -8,7 +8,7 @@ namespace ehs
class EHS_LIB_IO System : public BaseSystem
{
public:
static void OpenURI(const Str_8& uri);
static void OpenURI(Str_8 uri);
static Str_8 OpenFileDialog(const Str_8 &dir, const Str_8 &filters);

View File

@ -7,6 +7,6 @@ namespace ehs
class EHS_LIB_IO System : public BaseSystem
{
public:
static void OpenURI(const Str_8& uri);
static void OpenURI(Str_8 uri);
};
}

View File

@ -2,8 +2,36 @@
namespace ehs
{
const char Base64::ascii[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
Str_8 Base64::EncodeURL(const Str_8 &input)
{
UInt_64 input_length = input.Size();
// Calculate the output length
UInt_64 output_length = (input_length * 4 + 2) / 3;
// Allocate memory for the output
Str_8 result(output_length);
// Loop through the input and fill the output
for (int i = 0, j = 0; i < input_length;) {
// Take first byte and shift right by 2 bits
UInt_32 octet_a = (UInt_8)input[i++];
UInt_32 octet_b = i < input_length ? (UInt_8)input[i++] : 0;
UInt_32 octet_c = i < input_length ? (UInt_8)input[i++] : 0;
UInt_32 triple = (octet_a << 16) + (octet_b << 8) + octet_c;
// Encode the 24-bits into four 6-bits integers
result[j++] = asciiUrl[(triple >> 3 * 6) & 0x3F];
result[j++] = asciiUrl[(triple >> 2 * 6) & 0x3F];
result[j++] = asciiUrl[(triple >> 1 * 6) & 0x3F];
result[j++] = asciiUrl[(triple >> 0 * 6) & 0x3F];
}
return result;
}
Str_8 Base64::Encode(const Str_8 &input)
{
UInt_64 input_length = input.Size();
@ -18,9 +46,9 @@ namespace ehs
for (int i = 0, j = 0; i < input_length;) {
// Take first byte and shift right by 2 bits
UInt_32 octet_a = i < input_length ? input[i++] : 0;
UInt_32 octet_b = i < input_length ? input[i++] : 0;
UInt_32 octet_c = i < input_length ? input[i++] : 0;
UInt_32 octet_a = i < input_length ? (UInt_8)input[i++] : 0;
UInt_32 octet_b = i < input_length ? (UInt_8)input[i++] : 0;
UInt_32 octet_c = i < input_length ? (UInt_8)input[i++] : 0;
UInt_32 triple = (octet_a << 0x10) + (octet_b << 0x08) + octet_c;
@ -41,64 +69,152 @@ namespace ehs
return result;
}
Str_8 Base64::Decode(const Str_8 &input)
Str_8 Base64::DecodeURL(const Str_8 &input)
{
UInt_64 in_len = input.Size();
int i = 0;
int j = 0;
int in_ = 0;
char char_array_4[4], char_array_3[3];
Str_8 ret;
Str_8 result(input.Size() * 3 / 4);
while (in_len-- && ( input[in_] != '=') && IsBase64(input[in_]))
UInt_64 remaining = input.Size();
UInt_64 offsetIn = 0;
UInt_64 offsetOut = 0;
UInt_8 quartet[4];
while (remaining)
{
char_array_4[i++] = input[in_]; in_++;
if (i ==4)
if (remaining >= 4)
{
for (i = 0; i <4; i++)
char_array_4[i] = Find(char_array_4[i]);
for (UInt_8 i = 0; i < 4; ++i)
{
if (!IsBase64URL(input[offsetIn + i]))
return {};
char_array_3[0] = ( char_array_4[0] << 2 ) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3];
quartet[i] = FindURL(input[offsetIn + i]);
if (quartet[i] == EHS_UINT_8_MAX)
return {};
}
for (i = 0; (i < 3); i++)
ret += char_array_3[i];
result[offsetOut++] = (Char_8)((((UInt_8*)&quartet)[0] << 2) | (((UInt_8*)&quartet)[1] >> 4));
result[offsetOut++] = (Char_8)((((UInt_8*)&quartet)[1] << 4) | (((UInt_8*)&quartet)[2] >> 2));
result[offsetOut++] = (Char_8)((((UInt_8*)&quartet)[2] << 6) | ((UInt_8*)&quartet)[3]);
i = 0;
offsetIn += 4;
remaining -= 4;
}
else
{
for (UInt_8 i = 0; i < 4; ++i)
{
if (i < remaining)
{
if (!IsBase64URL(input[offsetIn + i]))
return {};
quartet[i] = FindURL(input[offsetIn + i]);
if (quartet[i] == EHS_UINT_8_MAX)
return {};
}
else
quartet[i] = 0;
}
result[offsetOut++] = (Char_8)((quartet[0] << 2) | (quartet[1] >> 4));
if (remaining == 3)
result[offsetOut++] = (Char_8)((quartet[1] << 4) | (quartet[2] >> 2));
offsetIn += remaining;
remaining = 0;
}
}
if (i)
return result;
}
Str_8 Base64::Decode(const Str_8 &input)
{
Str_8 result(input.Size() * 3 / 4);
UInt_64 remaining = input.Size();
UInt_64 offsetIn = 0;
UInt_64 offsetOut = 0;
UInt_8 quartet[4];
while (remaining)
{
for (j = 0; j < i; j++)
char_array_4[j] = Find(char_array_4[j]);
if (remaining >= 4)
{
for (UInt_8 i = 0; i < 4; ++i)
{
if (!IsBase64(input[offsetIn + i]))
return {};
char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4);
char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2);
quartet[i] = Find(input[offsetIn + i]);
if (quartet[i] == EHS_UINT_8_MAX)
return {};
}
for (j = 0; (j < i - 1); j++)
ret += char_array_3[j];
result[offsetOut++] = (Char_8)((((UInt_8*)&quartet)[0] << 2) | (((UInt_8*)&quartet)[1] >> 4));
result[offsetOut++] = (Char_8)((((UInt_8*)&quartet)[1] << 4) | (((UInt_8*)&quartet)[2] >> 2));
result[offsetOut++] = (Char_8)((((UInt_8*)&quartet)[2] << 6) | ((UInt_8*)&quartet)[3]);
offsetIn += 4;
remaining -= 4;
}
else
{
for (UInt_8 i = 0; i < 4; ++i)
{
if (i < remaining)
{
if (!IsBase64(input[offsetIn + i]))
return {};
quartet[i] = Find(input[offsetIn + i]);
if (quartet[i] == EHS_UINT_8_MAX)
return {};
}
else
quartet[i] = 0;
}
result[offsetOut++] = (Char_8)((quartet[0] << 2) | (quartet[1] >> 4));
if (remaining == 3)
result[offsetOut++] = (Char_8)((quartet[1] << 4) | (quartet[2] >> 2));
offsetIn += remaining;
remaining = 0;
}
}
return ret;
return result;
}
char Base64::Find(const char c)
UInt_8 Base64::FindURL(const UInt_8 &c)
{
for (char i = 0; i < (char)sizeof(ascii); ++i)
{
for (UInt_8 i = 0; i < (UInt_8)sizeof(asciiUrl) - 1; ++i)
if (asciiUrl[i] == c)
return i;
return EHS_UINT_8_MAX;;
}
UInt_8 Base64::Find(const UInt_8 &c)
{
for (UInt_8 i = 0; i < (UInt_8)sizeof(ascii) - 1; ++i)
if (ascii[i] == c)
return i;
}
return EHS_SINT_8_MAX;
}
bool Base64::IsBase64(const char c)
bool Base64::IsBase64URL(const UInt_8 &c)
{
return (c > 47 && c < 58) || (c > 64 && c < 91) || (c > 96 && c < 123) || (c == '+') || (c == '/');
return (c > 47 && c < 58) || (c > 64 && c < 91) || (c > 96 && c < 123) || c == '-' || c == '_';
}
bool Base64::IsBase64(const UInt_8 &c)
{
return (c > 47 && c < 58) || (c > 64 && c < 91) || (c > 96 && c < 123) || c == '+' || c == '/';
}
}

View File

@ -36,9 +36,9 @@ namespace ehs
double Math::Sqrt(const double from)
{
#if defined(EHS_ARCH_X64)
if (CPU::HasAVX())
if (CPU::hasAVX)
return Sqrt_AVX(from);
else if (CPU::HasSSE())
else if (CPU::hasSSE)
return Sqrt_SSE2(from);
double temp = 0.0;
@ -59,9 +59,9 @@ namespace ehs
float Math::Sqrt(const float from)
{
#if defined(EHS_ARCH_X64)
if (CPU::HasAVX())
if (CPU::hasAVX)
return Sqrt_AVX(from);
else if (CPU::HasSSE())
else if (CPU::hasSSE)
return Sqrt_SSE(from);
float temp = 0.0f;

209
src/SHA256.cpp Normal file
View File

@ -0,0 +1,209 @@
#include "ehs/SHA256.h"
#include "ehs/Util.h"
namespace ehs
{
UInt_32 SHA256::ROTR(const UInt_32 x, const UInt_32 n)
{
return (x >> n) | (x << (32 - n));
}
UInt_32 SHA256::CH(const UInt_32 x, const UInt_32 y, const UInt_32 z)
{
return (x & y) ^ (~x & z);
}
UInt_32 SHA256::MAJ(const UInt_32 x, const UInt_32 y, const UInt_32 z)
{
return (x & y) ^ (x & z) ^ (y & z);
}
UInt_32 SHA256::EP0(const UInt_32 x)
{
return ROTR(x, 2) ^ ROTR(x, 13) ^ ROTR(x, 22);
}
UInt_32 SHA256::EP1(const UInt_32 x)
{
return ROTR(x, 6) ^ ROTR(x, 11) ^ ROTR(x, 25);
}
UInt_32 SHA256::SIG0(const UInt_32 x)
{
return ROTR(x, 7) ^ ROTR(x, 18) ^ (x >> 3);
}
UInt_32 SHA256::SIG1(const UInt_32 x)
{
return ROTR(x,17) ^ ROTR(x, 19) ^ (x >> 10);
}
SHA256::SHA256()
: state{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19},
bitLen(0), data{}, dataLen(0)
{
}
SHA256::SHA256(SHA256&& other) noexcept
: state{}, bitLen(0), data{}, dataLen(0)
{
Util::Copy(state, other.state, sizeof(state) / sizeof(UInt_32));
bitLen = other.bitLen;
Util::Copy(data, other.data, sizeof(data));
dataLen = other.dataLen;
Util::Zero(other.state, sizeof(state) / sizeof(UInt_32));
other.bitLen = 0;
Util::Zero(other.data, sizeof(data));
other.dataLen = 0;
}
SHA256::SHA256(const SHA256& other)
: state{}, bitLen(0), data{}, dataLen(0)
{
Util::Copy(state, other.state, sizeof(state) / sizeof(UInt_32));
bitLen = other.bitLen;
Util::Copy(data, other.data, sizeof(data));
dataLen = other.dataLen;
}
SHA256& SHA256::operator=(SHA256&& other) noexcept
{
if (this == &other)
return *this;
Util::Copy(state, other.state, sizeof(state) / sizeof(UInt_32));
bitLen = other.bitLen;
Util::Copy(data, other.data, sizeof(data));
dataLen = other.dataLen;
Util::Zero(other.state, sizeof(state) / sizeof(UInt_32));
other.bitLen = 0;
Util::Zero(other.data, sizeof(data));
other.dataLen = 0;
return *this;
}
SHA256& SHA256::operator=(const SHA256& other)
{
if (this == &other)
return *this;
Util::Copy(state, other.state, sizeof(state) / sizeof(UInt_32));
bitLen = other.bitLen;
Util::Copy(data, other.data, sizeof(data));
dataLen = other.dataLen;
return *this;
}
void SHA256::Update(const Byte* data, const UInt_64 len)
{
for(UInt_64 i = 0; i < len; ++i)
{
this->data[dataLen++] = data[i];
if(dataLen == 64)
{
Transform(this->data);
bitLen += 512;
dataLen = 0;
}
}
}
void SHA256::Final(Byte hash[32])
{
UInt_32 i = dataLen;
/* Pad */
data[i++] = 0x80;
if(i > 56)
{
while(i < 64)
data[i++] = 0x00;
Transform(data);
i = 0;
}
while(i < 56)
data[i++] = 0x00;
/* Length in bits */
bitLen += dataLen * 8ULL;
data[63] = bitLen;
data[62] = bitLen >> 8;
data[61] = bitLen >> 16;
data[60] = bitLen >> 24;
data[59] = bitLen >> 32;
data[58] = bitLen >> 40;
data[57] = bitLen >> 48;
data[56] = bitLen >> 56;
Transform(data);
/* bigendian output */
for(i = 0; i < 4; ++i) {
hash[i] = (state[0] >> (24 - i * 8)) & 0xff;
hash[i + 4] = (state[1] >> (24 - i * 8)) & 0xff;
hash[i + 8] = (state[2] >> (24 - i * 8)) & 0xff;
hash[i + 12] = (state[3] >> (24 - i * 8)) & 0xff;
hash[i + 16] = (state[4] >> (24 - i * 8)) & 0xff;
hash[i + 20] = (state[5] >> (24 - i * 8)) & 0xff;
hash[i + 24] = (state[6] >> (24 - i * 8)) & 0xff;
hash[i + 28] = (state[7] >> (24 - i * 8)) & 0xff;
}
}
void SHA256::Hash(const Byte* data, const UInt_64 len, Byte hash[32])
{
Update(data, len);
Final(hash);
}
void SHA256::Transform(const Byte data[64])
{
UInt_32 m[64];
UInt_32 a = state[0];
UInt_32 b = state[1];
UInt_32 c = state[2];
UInt_32 d = state[3];
UInt_32 e = state[4];
UInt_32 f = state[5];
UInt_32 g = state[6];
UInt_32 h = state[7];
UInt_32 i, t1, t2;
for (i = 0; i < 16; ++i)
m[i] = (UInt_32)data[i * 4] << 24 | (UInt_32)data[i * 4 + 1] << 16 | (UInt_32)data[i * 4 + 2] << 8 | (UInt_32)data[i * 4 + 3];
for (; i < 64; ++i)
m[i] = SIG1(m[i - 2]) + m[i - 7] + SIG0(m[i - 15]) + m[i - 16];
for(i = 0; i < 64; ++i)
{
t1 = h + EP1(e) + CH(e,f,g) + k[i] + m[i];
t2 = EP0(a) + MAJ(a,b,c);
h = g;
g = f;
f = e;
e = d + t1;
d = c;
c = b;
b = a;
a = t1 + t2;
}
state[0] += a;
state[1] += b;
state[2] += c;
state[3] += d;
state[4] += e;
state[5] += f;
state[6] += g;
state[7] += h;
}
}

View File

@ -1,5 +1,9 @@
#include "ehs/Util.h"
#include "ehs/system/CPU.h"
#include "ehs/system/AVX2.h"
#include "ehs/system/AVX512.h"
namespace ehs
{
bool Util::Compare(const void* const a, const void* const b, const UInt_64 size)
@ -118,4 +122,4 @@ namespace ehs
remainder = size - i;
}
}
}
}

View File

@ -693,7 +693,7 @@ namespace ehs
Vector<Str_32> Console::GetArgs_32(const UInt_64 bufferSize)
{
#if defined(EHS_OS_WINDOWS)
return UTF::To_32(GetCommandLineW()).Split(U" ");
return UTF::To_32(GetCommandLineW()).ParseArgs();
#elif defined(EHS_OS_LINUX)
File cmdFile("/proc/self/cmdline", Mode::READ, Disposition::OPEN);
Array<Byte> data = cmdFile.ReadArray(bufferSize);
@ -725,7 +725,7 @@ namespace ehs
Vector<Str_16> Console::GetArgs_16(const UInt_64 bufferSize)
{
#if defined(EHS_OS_WINDOWS)
return Str_16(GetCommandLineW()).Split(L" ");
return Str_16(GetCommandLineW()).ParseArgs();
#elif defined(EHS_OS_LINUX)
File cmdFile("/proc/self/cmdline", Mode::READ, Disposition::OPEN);
Array<Byte> data = cmdFile.ReadArray(bufferSize);
@ -755,7 +755,7 @@ namespace ehs
Vector<Str_8> Console::GetArgs_8(const UInt_64 bufferSize)
{
#if defined(EHS_OS_WINDOWS)
return UTF::To_8(GetCommandLineW()).Split(" ");
return UTF::To_8(GetCommandLineW()).ParseArgs();
#elif defined(EHS_OS_LINUX)
File cmdFile("/proc/self/cmdline", Mode::READ, Disposition::OPEN);
Array<Byte> data = cmdFile.ReadArray(bufferSize);

View File

@ -102,9 +102,21 @@ namespace ehs
if (bound)
return;
OpenSSL_add_all_algorithms();
OpenSSL_add_ssl_algorithms();
SSL_load_error_strings();
ctx = SSL_CTX_new(SSLv23_server_method());
ctx = SSL_CTX_new(TLS_server_method());
SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION);
SSL_CTX_set_cipher_list(ctx, "HIGH:!aNULL:!MD5");
SSL_CTX_set_ciphersuites(ctx,
"TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256:"
"TLS_CHACHA20_POLY1305_SHA256:ECDHE-RSA-AES128-GCM-SHA256"
);
#if OPENSSL_VERSION_NUMBER < 0x10101000L
SSL_CTX_set_ecdh_auto(ctx, 1);
#endif
sslHdl = SSL_new(ctx);
SSL_set_fd(sslHdl, hdl);
@ -143,12 +155,35 @@ namespace ehs
return;
TCP::Connect(address, port);
OpenSSL_add_all_algorithms();
OpenSSL_add_ssl_algorithms();
SSL_load_error_strings();
ctx = SSL_CTX_new(SSLv23_client_method());
ctx = SSL_CTX_new(TLS_client_method());
if (!ctx)
{
EHS_LOG_INT(LogType::ERR, 0, "Failed to creat SSL context.");
return;
}
SSL_CTX_set_default_verify_paths(ctx);
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, nullptr);
SSL_CTX_set_min_proto_version(ctx, TLS1_2_VERSION);
sslHdl = SSL_new(ctx);
SSL_set_fd(sslHdl, hdl);
SSL_connect(sslHdl);
SSL_set_tlsext_host_name(sslHdl, &address[0]);
SInt_32 rc = SSL_connect(sslHdl);
if (rc != 1)
{
EHS_LOG_INT(LogType::ERR, 1, "Failed to connect with error #" + Str_8::FromNum(SSL_get_error(sslHdl, rc)) + ".");
return;
}
EHS_LOG_SUCCESS();
}
UInt_64 SSL::Send(const Byte* const buffer, const UInt_32 size)

View File

@ -0,0 +1,24 @@
#include "ehs/system/AVX2.h"
namespace ehs
{
bool AVX2::CompareUnaligned(const UInt_64* a, const UInt_64* b)
{
return false;
}
bool AVX2::CompareUnaligned(const SInt_64* a, const SInt_64* b)
{
return false;
}
bool AVX2::CompareAligned(const UInt_64* a, const UInt_64* b)
{
return false;
}
bool AVX2::CompareAligned(const SInt_64* a, const SInt_64* b)
{
return false;
}
}

View File

@ -0,0 +1,49 @@
global _ZN3ehs4AVX216CompareUnalignedEPKmS2_
global _ZN3ehs4AVX216CompareUnalignedEPKlS2_
global _ZN3ehs4AVX214CompareAlignedEPKmS2_
global _ZN3ehs4AVX214CompareAlignedEPKlS2_
section .text
_ZN3ehs4AVX216CompareUnalignedEPKmS2_:
VMOVDQU YMM0, [RDI]
VMOVDQU YMM1, [RSI]
VPCMPEQQ YMM2, YMM0, YMM1
VPMOVMSKB EAX, YMM2
CMP EAX, 0xFFFFFFFF
SETE AL
RET
_ZN3ehs4AVX216CompareUnalignedEPKlS2_:
VMOVDQU YMM0, [RDI]
VMOVDQU YMM1, [RSI]
VPCMPEQQ YMM2, YMM0, YMM1
VPMOVMSKB EAX, YMM2
CMP EAX, 0xFFFFFFFF
SETE AL
RET
_ZN3ehs4AVX214CompareAlignedEPKmS2_:
VMOVDQA YMM0, [RDI]
VMOVDQA YMM1, [RSI]
VPCMPEQQ YMM2, YMM0, YMM1
VPMOVMSKB EAX, YMM2
CMP EAX, 0xFFFFFFFF
SETE AL
RET
_ZN3ehs4AVX214CompareAlignedEPKlS2_:
VMOVDQA YMM0, [RDI]
VMOVDQA YMM1, [RSI]
VPCMPEQQ YMM2, YMM0, YMM1
VPMOVMSKB EAX, YMM2
CMP EAX, 0xFFFFFFFF
SETE AL
RET

View File

@ -0,0 +1,49 @@
global ?CompareUnaligned@AVX2@ehs@@SA_NPEBK0@Z
global ?CompareUnaligned@AVX2@ehs@@SA_NPEBJ0@Z
global ?CompareAligned@AVX2@ehs@@SA_NPEBK0@Z
global ?CompareAligned@AVX2@ehs@@SA_NPEBJ0@Z
section .text
?CompareUnaligned@AVX2@ehs@@SA_NPEBK0@Z:
VMOVDQU YMM0, [RCX]
VMOVDQU YMM1, [RDX]
VPCMPEQQ YMM2, YMM0, YMM1
VPMOVMSKB EAX, YMM2
CMP EAX, 0xFFFFFFFF
SETE AL
RET
?CompareUnaligned@AVX2@ehs@@SA_NPEBJ0@Z:
VMOVDQU YMM0, [RCX]
VMOVDQU YMM1, [RDX]
VPCMPEQQ YMM2, YMM0, YMM1
VPMOVMSKB EAX, YMM2
CMP EAX, 0xFFFFFFFF
SETE AL
RET
?CompareAligned@AVX2@ehs@@SA_NPEBK0@Z:
VMOVDQA YMM0, [RCX]
VMOVDQA YMM1, [RDX]
VPCMPEQQ YMM2, YMM0, YMM1
VPMOVMSKB EAX, YMM2
CMP EAX, 0xFFFFFFFF
SETE AL
RET
?CompareAligned@AVX2@ehs@@SA_NPEBJ0@Z:
VMOVDQA YMM0, [RCX]
VMOVDQA YMM1, [RDX]
VPCMPEQQ YMM2, YMM0, YMM1
VPMOVMSKB EAX, YMM2
CMP EAX, 0xFFFFFFFF
SETE AL
RET

View File

@ -0,0 +1,24 @@
#include "ehs/system/AVX512.h"
namespace ehs
{
bool AVX512::CompareUnaligned(const UInt_64* a, const UInt_64* b)
{
return false;
}
bool AVX512::CompareUnaligned(const SInt_64* a, const SInt_64* b)
{
return false;
}
bool AVX512::CompareAligned(const UInt_64* a, const UInt_64* b)
{
return false;
}
bool AVX512::CompareAligned(const SInt_64* a, const SInt_64* b)
{
return false;
}
}

View File

@ -0,0 +1,49 @@
global _ZN3ehs6AVX51216CompareUnalignedEPKmS2_
global _ZN3ehs6AVX51216CompareUnalignedEPKlS2_
global _ZN3ehs6AVX51214CompareAlignedEPKmS2_
global _ZN3ehs6AVX51214CompareAlignedEPKlS2_
section .text
_ZN3ehs6AVX51216CompareUnalignedEPKmS2_:
VMOVDQU64 ZMM0, [RDI]
VMOVDQU64 ZMM1, [RSI]
VPCMPEQQ K1, ZMM0, ZMM1
KORTESTQ K1, K1
SETC AL
RET
_ZN3ehs6AVX51216CompareUnalignedEPKlS2_:
VMOVDQU64 ZMM0, [RDI]
VMOVDQU64 ZMM1, [RSI]
VPCMPEQQ K1, ZMM0, ZMM1
KORTESTQ K1, K1
SETC AL
RET
_ZN3ehs6AVX51214CompareAlignedEPKmS2_:
VMOVDQA64 ZMM0, [RDI]
VMOVDQA64 ZMM1, [RSI]
VPCMPEQQ K1, ZMM0, ZMM1
KORTESTQ K1, K1
SETC AL
RET
_ZN3ehs6AVX51214CompareAlignedEPKlS2_:
VMOVDQA64 ZMM0, [RDI]
VMOVDQA64 ZMM1, [RSI]
VPCMPEQQ K1, ZMM0, ZMM1
KORTESTQ K1, K1
SETC AL
RET

View File

@ -0,0 +1,49 @@
global ?CompareUnaligned@AVX512@ehs@@SA_NPEBK0@Z
global ?CompareUnaligned@AVX512@ehs@@SA_NPEBJ0@Z
global ?CompareAligned@AVX512@ehs@@SA_NPEBK0@Z
global ?CompareAligned@AVX512@ehs@@SA_NPEBJ0@Z
section .text
?CompareUnaligned@AVX512@ehs@@SA_NPEBK0@Z:
VMOVDQU64 ZMM0, [RCX]
VMOVDQU64 ZMM1, [RDX]
VPCMPEQQ K1, ZMM0, ZMM1
KORTESTQ K1, K1
SETC AL
RET
?CompareUnaligned@AVX512@ehs@@SA_NPEBJ0@Z:
VMOVDQU64 ZMM0, [RCX]
VMOVDQU64 ZMM1, [RDX]
VPCMPEQQ K1, ZMM0, ZMM1
KORTESTQ K1, K1
SETC AL
RET
?CompareAligned@AVX512@ehs@@SA_NPEBK0@Z:
VMOVDQA64 ZMM0, [RCX]
VMOVDQA64 ZMM1, [RDX]
VPCMPEQQ K1, ZMM0, ZMM1
KORTESTQ K1, K1
SETC AL
RET
?CompareAligned@AVX512@ehs@@SA_NPEBJ0@Z:
VMOVDQA64 ZMM0, [RCX]
VMOVDQA64 ZMM1, [RDX]
VPCMPEQQ K1, ZMM0, ZMM1
KORTESTQ K1, K1
SETC AL
RET

View File

@ -2,7 +2,7 @@
namespace ehs
{
void BaseSystem::OpenURI(const Str_8& uri)
void BaseSystem::OpenURI(Str_8 uri)
{
}

View File

@ -10,6 +10,70 @@ namespace ehs
UInt_64 CPU::TSC_Freq = 0;
#endif
const bool CPU::hasFPU = RetrieveFPU();
const bool CPU::hasVME = RetrieveVME();
const bool CPU::hasDE = RetrieveDE();
const bool CPU::hasPSE = RetrievePSE();
const bool CPU::hasTSC = RetrieveTSC();
const bool CPU::hasMSR = RetrieveMSR();
const bool CPU::hasPAE = RetrievePAE();
const bool CPU::hasMCE = RetrieveMCE();
const bool CPU::hasCX8 = RetrieveCX8();
const bool CPU::hasAPIC = RetrieveAPIC();
const bool CPU::hasSEP = RetrieveSEP();
const bool CPU::hasMTRR = RetrieveMTRR();
const bool CPU::hasPGE = RetrievePGE();
const bool CPU::hasMCA = RetrieveMCA();
const bool CPU::hasCMOV = RetrieveCMOV();
const bool CPU::hasPSE_36 = RetrievePSE_36();
const bool CPU::hasPSN = RetrievePSN();
const bool CPU::hasCLFSH = RetrieveCLFSH();
const bool CPU::hasDS = RetrieveDS();
const bool CPU::hasACPI = RetrieveACPI();
const bool CPU::hasMMX = RetrieveMMX();
const bool CPU::hasFXSR = RetrieveFXSR();
const bool CPU::hasSSE = RetrieveSSE();
const bool CPU::hasSSE2 = RetrieveSSE2();
const bool CPU::hasSS = RetrieveSS();
const bool CPU::hasHTT = RetrieveHTT();
const bool CPU::hasTM = RetrieveTM();
const bool CPU::hasIA64 = RetrieveIA64();
const bool CPU::hasPBE = RetrievePBE();
const bool CPU::hasSSE3 = RetrieveSSE3();
const bool CPU::hasPCLMULQDQ = RetrievePCLMULQDQ();
const bool CPU::hasDTES64 = RetrieveDTES64();
const bool CPU::hasMONITOR = RetrieveMONITOR();
const bool CPU::hasVMX = RetrieveVMX();
const bool CPU::hasSMX = RetrieveSMX();
const bool CPU::hasEST = RetrieveEST();
const bool CPU::hasTM2 = RetrieveTM2();
const bool CPU::hasSSSE3 = RetrieveSSSE3();
const bool CPU::hasCNXT_ID = RetrieveCNXT_ID();
const bool CPU::hasSDBG = RetrieveSDBG();
const bool CPU::hasFMA = RetrieveFMA();
const bool CPU::hasCX16 = RetrieveCX16();
const bool CPU::hasXTPR = RetrieveXTPR();
const bool CPU::hasPDCM = RetrievePDCM();
const bool CPU::hasPCID = RetrievePCID();
const bool CPU::hasDCA = RetrieveDCA();
const bool CPU::hasSSE4_1 = RetrieveSSE4_1();
const bool CPU::hasSSE4_2 = RetrieveSSE4_2();
const bool CPU::hasX2APIC = RetrieveX2APIC();
const bool CPU::hasMOVBE = RetrieveMOVBE();
const bool CPU::hasPOPCNT = RetrievePOPCNT();
const bool CPU::hasTSC_DEADLINE = RetrieveTSC_DEADLINE();
const bool CPU::hasAES = RetrieveAES();
const bool CPU::hasXSAVE = RetrieveXSAVE();
const bool CPU::hasOSXSAVE = RetrieveOSXSAVE();
const bool CPU::hasAVX = RetrieveAVX();
const bool CPU::hasF16C = RetrieveF16C();
const bool CPU::hasRDRND = RetrieveRDRND();
const bool CPU::hasHYPERVISOR = RetrieveHYPERVISOR();
const bool CPU::hasAVX2 = RetrieveAVX2();
const bool CPU::hasAVX512F = RetrieveAVX512F();
const bool CPU::hasRDSEED = RetrieveRDSEED();
const bool CPU::hasADX = RetrieveADX();
Architecture CPU::GetArchitecture()
{
#if defined(EHS_ARCH_X64)
@ -119,324 +183,589 @@ namespace ehs
return (UInt_8)(GetInfoBits() >> 20);
}
bool CPU::HasFPU()
bool CPU::RetrieveFPU()
{
return GetFeatureBits_1() & 0b00000000000000000000000000000001;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000000000000001;
#else
return false;
#endif
}
bool CPU::HasVME()
bool CPU::RetrieveVME()
{
return GetFeatureBits_1() & 0b00000000000000000000000000000010;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000000000000010;
#else
return false;
#endif
}
bool CPU::HasDE()
bool CPU::RetrieveDE()
{
return GetFeatureBits_1() & 0b00000000000000000000000000000100;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000000000000100;
#else
return false;
#endif
}
bool CPU::HasPSE()
bool CPU::RetrievePSE()
{
return GetFeatureBits_1() & 0b00000000000000000000000000001000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000000000001000;
#else
return false;
#endif
}
bool CPU::HasTSC()
bool CPU::RetrieveTSC()
{
return GetFeatureBits_1() & 0b00000000000000000000000000010000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000000000010000;
#else
return false;
#endif
}
bool CPU::HasMSR()
bool CPU::RetrieveMSR()
{
return GetFeatureBits_1() & 0b00000000000000000000000000100000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000000000100000;
#else
return false;
#endif
}
bool CPU::HasPAE()
bool CPU::RetrievePAE()
{
return GetFeatureBits_1() & 0b00000000000000000000000001000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000000001000000;
#else
return false;
#endif
}
bool CPU::HasMCE()
bool CPU::RetrieveMCE()
{
return GetFeatureBits_1() & 0b00000000000000000000000010000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000000010000000;
#else
return false;
#endif
}
bool CPU::HasCX8()
bool CPU::RetrieveCX8()
{
return GetFeatureBits_1() & 0b00000000000000000000000100000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000000100000000;
#else
return false;
#endif
}
bool CPU::HasAPIC()
bool CPU::RetrieveAPIC()
{
return GetFeatureBits_1() & 0b00000000000000000000001000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000001000000000;
#else
return false;
#endif
}
bool CPU::HasSEP()
bool CPU::RetrieveSEP()
{
return GetFeatureBits_1() & 0b00000000000000000000100000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000000100000000000;
#else
return false;
#endif
}
bool CPU::HasMTRR()
bool CPU::RetrieveMTRR()
{
return GetFeatureBits_1() & 0b00000000000000000001000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000001000000000000;
#else
return false;
#endif
}
bool CPU::HasPGE()
bool CPU::RetrievePGE()
{
return GetFeatureBits_1() & 0b00000000000000000010000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000010000000000000;
#else
return false;
#endif
}
bool CPU::HasMCA()
bool CPU::RetrieveMCA()
{
return GetFeatureBits_1() & 0b00000000000000000100000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000000100000000000000;
#else
return false;
#endif
}
bool CPU::HasCMOV()
bool CPU::RetrieveCMOV()
{
return GetFeatureBits_1() & 0b00000000000000001000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000001000000000000000;
#else
return false;
#endif
}
bool CPU::HasPAT()
bool CPU::RetrievePAT()
{
return GetFeatureBits_1() & 0b00000000000000010000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000010000000000000000;
#else
return false;
#endif
}
bool CPU::HasPSE_36()
bool CPU::RetrievePSE_36()
{
return GetFeatureBits_1() & 0b00000000000000100000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000000100000000000000000;
#else
return false;
#endif
}
bool CPU::HasPSN()
bool CPU::RetrievePSN()
{
return GetFeatureBits_1() & 0b00000000000001000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000001000000000000000000;
#else
return false;
#endif
}
bool CPU::HasCLFSH()
bool CPU::RetrieveCLFSH()
{
return GetFeatureBits_1() & 0b00000000000010000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000000010000000000000000000;
#else
return false;
#endif
}
bool CPU::HasDS()
bool CPU::RetrieveDS()
{
return GetFeatureBits_1() & 0b00000000001000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000001000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasACPI()
bool CPU::RetrieveACPI()
{
return GetFeatureBits_1() & 0b00000000010000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000010000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasMMX()
bool CPU::RetrieveMMX()
{
return GetFeatureBits_1() & 0b00000000100000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000000100000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasFXSR()
bool CPU::RetrieveFXSR()
{
return GetFeatureBits_1() & 0b00000001000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000001000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasSSE()
bool CPU::RetrieveSSE()
{
return GetFeatureBits_1() & 0b00000010000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000010000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasSSE2()
bool CPU::RetrieveSSE2()
{
return GetFeatureBits_1() & 0b00000100000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00000100000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasSS()
bool CPU::RetrieveSS()
{
return GetFeatureBits_1() & 0b00001000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00001000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasHTT()
bool CPU::RetrieveHTT()
{
return GetFeatureBits_1() & 0b00010000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00010000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasTM()
bool CPU::RetrieveTM()
{
return GetFeatureBits_1() & 0b00100000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b00100000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasIA64()
bool CPU::RetrieveIA64()
{
return GetFeatureBits_1() & 0b01000000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b01000000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasPBE()
bool CPU::RetrievePBE()
{
return GetFeatureBits_1() & 0b10000000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_1() & 0b10000000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasSSE3()
bool CPU::RetrieveSSE3()
{
return GetFeatureBits_2() & 0b00000000000000000000000000000001;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000000000000001;
#else
return false;
#endif
}
bool CPU::HasPCLMULQDQ()
bool CPU::RetrievePCLMULQDQ()
{
return GetFeatureBits_2() & 0b00000000000000000000000000000010;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000000000000010;
#else
return false;
#endif
}
bool CPU::HasDTES64()
bool CPU::RetrieveDTES64()
{
return GetFeatureBits_2() & 0b00000000000000000000000000000100;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000000000000100;
#else
return false;
#endif
}
bool CPU::HasMONITOR()
bool CPU::RetrieveMONITOR()
{
return GetFeatureBits_2() & 0b00000000000000000000000000001000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000000000001000;
#else
return false;
#endif
}
bool CPU::HasDS_CPL()
bool CPU::RetrieveDS_CPL()
{
return GetFeatureBits_2() & 0b00000000000000000000000000010000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000000000010000;
#else
return false;
#endif
}
bool CPU::HasVMX()
bool CPU::RetrieveVMX()
{
return GetFeatureBits_2() & 0b00000000000000000000000000100000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000000000100000;
#else
return false;
#endif
}
bool CPU::HasSMX()
bool CPU::RetrieveSMX()
{
return GetFeatureBits_2() & 0b00000000000000000000000001000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000000001000000;
#else
return false;
#endif
}
bool CPU::HasEST()
bool CPU::RetrieveEST()
{
return GetFeatureBits_2() & 0b00000000000000000000000010000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000000010000000;
#else
return false;
#endif
}
bool CPU::HasTM2()
bool CPU::RetrieveTM2()
{
return GetFeatureBits_2() & 0b00000000000000000000000100000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000000100000000;
#else
return false;
#endif
}
bool CPU::HasSSSE3()
bool CPU::RetrieveSSSE3()
{
return GetFeatureBits_2() & 0b00000000000000000000001000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000001000000000;
#else
return false;
#endif
}
bool CPU::HasCNXT_ID()
bool CPU::RetrieveCNXT_ID()
{
return GetFeatureBits_2() & 0b00000000000000000000010000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000010000000000;
#else
return false;
#endif
}
bool CPU::HasSDBG()
bool CPU::RetrieveSDBG()
{
return GetFeatureBits_2() & 0b00000000000000000000100000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000000100000000000;
#else
return false;
#endif
}
bool CPU::HasFMA()
bool CPU::RetrieveFMA()
{
return GetFeatureBits_2() & 0b00000000000000000001000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000001000000000000;
#else
return false;
#endif
}
bool CPU::HasCX16()
bool CPU::RetrieveCX16()
{
return GetFeatureBits_2() & 0b00000000000000000010000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000010000000000000;
#else
return false;
#endif
}
bool CPU::HasXTPR()
bool CPU::RetrieveXTPR()
{
return GetFeatureBits_2() & 0b00000000000000000100000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000000100000000000000;
#else
return false;
#endif
}
bool CPU::HasPDCM()
bool CPU::RetrievePDCM()
{
return GetFeatureBits_2() & 0b00000000000000001000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000001000000000000000;
#else
return false;
#endif
}
bool CPU::HasPCID()
bool CPU::RetrievePCID()
{
return GetFeatureBits_2() & 0b00000000000000100000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000000100000000000000000;
#else
return false;
#endif
}
bool CPU::HasDCA()
bool CPU::RetrieveDCA()
{
return GetFeatureBits_2() & 0b00000000000001000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000001000000000000000000;
#else
return false;
#endif
}
bool CPU::HasSSE4_1()
bool CPU::RetrieveSSE4_1()
{
return GetFeatureBits_2() & 0b00000000000010000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000010000000000000000000;
#else
return false;
#endif
}
bool CPU::HasSSE4_2()
bool CPU::RetrieveSSE4_2()
{
return GetFeatureBits_2() & 0b00000000000100000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000000100000000000000000000;
#else
return false;
#endif
}
bool CPU::HasX2APIC()
bool CPU::RetrieveX2APIC()
{
return GetFeatureBits_2() & 0b00000000001000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000001000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasMOVBE()
bool CPU::RetrieveMOVBE()
{
return GetFeatureBits_2() & 0b00000000010000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000010000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasPOPCNT()
bool CPU::RetrievePOPCNT()
{
return GetFeatureBits_2() & 0b00000000100000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000000100000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasTSC_DEADLINE()
bool CPU::RetrieveTSC_DEADLINE()
{
return GetFeatureBits_2() & 0b00000001000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000001000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasAES()
bool CPU::RetrieveAES()
{
return GetFeatureBits_2() & 0b00000010000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000010000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasXSAVE()
bool CPU::RetrieveXSAVE()
{
return GetFeatureBits_2() & 0b00000100000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00000100000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasOSXSAVE()
bool CPU::RetrieveOSXSAVE()
{
return GetFeatureBits_2() & 0b00001000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00001000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasAVX()
bool CPU::RetrieveAVX()
{
return GetFeatureBits_2() & 0b00010000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00010000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasF16C()
bool CPU::RetrieveF16C()
{
return GetFeatureBits_2() & 0b00100000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b00100000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasRDRND()
bool CPU::RetrieveRDRND()
{
return GetFeatureBits_2() & 0b01000000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b01000000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasHYPERVISOR()
bool CPU::RetrieveHYPERVISOR()
{
return GetFeatureBits_2() & 0b10000000000000000000000000000000;
#ifdef EHS_ARCH_X64
return GetFeatureBits_2() & 0b10000000000000000000000000000000;
#else
return false;
#endif
}
bool CPU::HasAVX2()
bool CPU::RetrieveAVX2()
{
return GetExtFeatureBits_1() & 0b00000000000000000000000000100000;
#ifdef EHS_ARCH_X64
return GetExtFeatureBits_1() & 0b00000000000000000000000000100000;
#else
return false;
#endif
}
bool CPU::HasRDSEED()
bool CPU::RetrieveAVX512F()
{
return GetExtFeatureBits_1() & 0b00000000000001000000000000000000;
#ifdef EHS_ARCH_X64
return GetExtFeatureBits_1() & 0b00000000000000010000000000000000;
#else
return false;
#endif
}
bool CPU::HasADX()
bool CPU::RetrieveRDSEED()
{
return GetExtFeatureBits_1() & 0b00000000000010000000000000000000;
#ifdef EHS_ARCH_X64
return GetExtFeatureBits_1() & 0b00000000000001000000000000000000;
#else
return false;
#endif
}
bool CPU::RetrieveADX()
{
#ifdef EHS_ARCH_X64
return GetExtFeatureBits_1() & 0b00000000000010000000000000000000;
#else
return false;
#endif
}
/*

View File

@ -13,13 +13,17 @@ namespace ehs
system("xdg-open \"" + *uri + "\"");
delete uri;
return 0;
}
void System::OpenURI(const Str_8& uri)
void System::OpenURI(Str_8 uri)
{
Str_8 *arg = new Str_8((Str_8&&)uri);
Thread xdg;
xdg.Start(XDG_Thread, (void*)&uri);
xdg.Start(XDG_Thread, arg);
xdg.Detach();
}

View File

@ -4,7 +4,7 @@
namespace ehs
{
void System::OpenURI(const Str_8& uri)
void System::OpenURI(Str_8 uri)
{
ShellExecuteA(nullptr, "open", uri, nullptr, nullptr, SW_SHOW);
}