[*] Amend %x -> {:X} formatting

[+] Added source files ready for an LTC ECC implementation
[+] Added linux specific HWInfo get threads backend
[+] AU_TEMPLATE_ENABLE_WHEN
[*] Amend IO::FS::WriteString compilation issue
This commit is contained in:
Reece Wilson 2021-09-17 20:26:05 +01:00
parent 412d798994
commit c4567f4c8c
19 changed files with 172 additions and 16 deletions

View File

@ -37,6 +37,7 @@ namespace Aurora::Crypto::ECC
{ {
eCurve256, eCurve256,
eCurve384, eCurve384,
eCurve521,
eCurveX25519, eCurveX25519,
eCurveEd25519 eCurveEd25519
}; };

View File

@ -31,12 +31,12 @@ namespace Aurora::Memory
this->ptr = nullptr; this->ptr = nullptr;
this->length = 0; this->length = 0;
} }
template<typename T, typename std::enable_if<AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, T>::value>::type* = nullptr> template<typename T, AU_TEMPLATE_ENABLE_WHEN(AuIsBaseOfTemplate<AURORA_RUNTIME_AU_LIST, T>::value)>
MemoryView(T &list) MemoryView(T &list)
{ {
this->ptr = list.data(); this->ptr = list.data();
this->length = list.size() * sizeof(T); this->length = list.size() * sizeof(T::value_type);
} }
MemoryView(const AuString &str) MemoryView(const AuString &str)

View File

@ -14,6 +14,10 @@
#define AU_SHARED_FROM_THIS (std::static_pointer_cast<std::remove_pointer_t<decltype(this)>>(this->shared_from_this())) #define AU_SHARED_FROM_THIS (std::static_pointer_cast<std::remove_pointer_t<decltype(this)>>(this->shared_from_this()))
#define AU_WEAK_FROM_THIS (AuWPtr<std::remove_pointer_t<decltype(this)>>(std::static_pointer_cast<std::remove_pointer_t<decltype(this)>>(this->shared_from_this()))) #define AU_WEAK_FROM_THIS (AuWPtr<std::remove_pointer_t<decltype(this)>>(std::static_pointer_cast<std::remove_pointer_t<decltype(this)>>(this->shared_from_this())))
#define AU_BRACKET_SCOPE(...) __VA_ARGS__
#define AU_TEMPLATE_ENABLE_WHEN(...) typename std::enable_if<__VA_ARGS__>::type* = nullptr
/// @hideinitializer /// @hideinitializer
#define AU_STRINGIFY_(in) #in #define AU_STRINGIFY_(in) #in
#define AU_STRINGIFY(in) AU_STRINGIFY_(in) #define AU_STRINGIFY(in) AU_STRINGIFY_(in)

View File

@ -34,7 +34,7 @@ static inline auto AuMakePair(Args... args)
return AURORA_RUNTIME_MAKE_PAIR(args...); return AURORA_RUNTIME_MAKE_PAIR(args...);
} }
#if defined(AURORA_IS_MODERNNT_DERIVED) && defined(_WINDOWS_) #if defined(AURORA_IS_MODERNNT_DERIVED) && (defined(_WINDOWS_) || defined(_OTHER_MS_MAIN_HEADER_GUARDS_HERE))
static inline void AuWin32CloseHandle(HANDLE &handle) static inline void AuWin32CloseHandle(HANDLE &handle)
{ {
HANDLE local; HANDLE local;
@ -164,13 +164,13 @@ static inline AuOptional<AuSPtr<T>> AuOptionalSharedStaticCast(AuOptional<AuSPtr
return std::static_pointer_cast<T>(in.value()); return std::static_pointer_cast<T>(in.value());
} }
static inline bool AuEndsWith(std::string const &value, std::string const &ending) static inline bool AuEndsWith(AuString const &value, AuString const &ending)
{ {
if (ending.size() > value.size()) return false; if (ending.size() > value.size()) return false;
return std::equal(ending.rbegin(), ending.rend(), value.rbegin()); return std::equal(ending.rbegin(), ending.rend(), value.rbegin());
} }
static inline bool AuStartsWith(std::string const &value, std::string const &starting) static inline bool AuStartsWith(AuString const &value, AuString const &starting)
{ {
return value.rfind(starting, 0) == 0; return value.rfind(starting, 0) == 0;
} }
@ -448,7 +448,7 @@ static inline bool AuTryResize(T &list, AuUInt length)
} }
} }
static inline std::string AuReplaceAll(std::string &str, const std::string &from, const std::string &to) static inline AuString AuReplaceAll(AuString &str, const AuString &from, const AuString &to)
{ {
size_t start_pos = 0; size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos) while ((start_pos = str.find(from, start_pos)) != std::string::npos)
@ -456,7 +456,7 @@ static inline std::string AuReplaceAll(std::string &str, const std::string &from
str.replace(start_pos, from.length(), to); str.replace(start_pos, from.length(), to);
start_pos += to.length(); // Handles case where 'to' is a substring of 'from' start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
} }
return str; return str; // :(
} }
// i told myself not to copy this, required a split function twice, now here we are :D // i told myself not to copy this, required a split function twice, now here we are :D

14
Source/Crypto/ECC/ECC.cpp Normal file
View File

@ -0,0 +1,14 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECC.cpp
Date: 2021-9-17
Author: Reece
***/
#include <RuntimeInternal.hpp>
#include "ECC.hpp"
namespace Aurora::Crypto::ECC
{
}

13
Source/Crypto/ECC/ECC.hpp Normal file
View File

@ -0,0 +1,13 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECC.hpp
Date: 2021-9-17
Author: Reece
***/
#pragma once
namespace Aurora::Crypto::ECC
{
}

View File

@ -0,0 +1,15 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECCCurves.cpp
Date: 2021-9-17
Author: Reece
***/
#include <RuntimeInternal.hpp>
#include "ECC.hpp"
#include "ECCCurves.hpp"
namespace Aurora::Crypto::ECC
{
}

View File

@ -0,0 +1,13 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECCCurves.hpp
Date: 2021-9-17
Author: Reece
***/
#pragma once
namespace Aurora::Crypto::ECC
{
}

View File

@ -0,0 +1,16 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECCGeneric.cpp
Date: 2021-9-17
Author: Reece
***/
#include <RuntimeInternal.hpp>
#include "ECC.hpp"
#include "ECCGeneric.hpp"
#include "ECCCurves.hpp"
namespace Aurora::Crypto::ECC
{
}

View File

@ -0,0 +1,13 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECCGeneric.hpp
Date: 2021-9-17
Author: Reece
***/
#pragma once
namespace Aurora::Crypto::ECC
{
}

View File

@ -0,0 +1,15 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECCX25519.cpp
Date: 2021-9-17
Author: Reece
***/
#include <RuntimeInternal.hpp>
#include "ECC.hpp"
#include "ECCx25519.hpp"
namespace Aurora::Crypto::ECC
{
}

View File

@ -0,0 +1,13 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECCX25519.hpp
Date: 2021-9-17
Author: Reece
***/
#pragma once
namespace Aurora::Crypto::ECC
{
}

View File

@ -0,0 +1,15 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECCx25519Utils.cpp
Date: 2021-9-17
Author: Reece
***/
#include <RuntimeInternal.hpp>
#include "ECC.hpp"
#include "ECCx25519Utils.hpp"
namespace Aurora::Crypto::ECC
{
}

View File

@ -0,0 +1,13 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ECCx25519Utils.hpp
Date: 2021-9-17
Author: Reece
***/
#pragma once
namespace Aurora::Crypto::ECC
{
}

View File

@ -190,7 +190,7 @@ namespace Aurora::Debug
#endif #endif
AddVectoredExceptionHandler(1, AddVectoredExceptionHandler(1,
[](_EXCEPTION_POINTERS *ExceptionInfo) -> LONG [](_EXCEPTION_POINTERS *ExceptionInfo) -> LONG
{ {
Telemetry::NewBlockboxEntry entry; Telemetry::NewBlockboxEntry entry;
entry.type = Telemetry::ENewBlackBoxEntry::eWinCxxException; entry.type = Telemetry::ENewBlackBoxEntry::eWinCxxException;

View File

@ -15,9 +15,9 @@ namespace Aurora::Debug
{ {
AUKN_SYM void DebugBreak() AUKN_SYM void DebugBreak()
{ {
#if defined(DEBUG) || defined(INTERNAL) #if defined(DEBUG) || defined(STAGING)
#if defined(AURORA_PLATFORM_WIN32) #if defined(AURORA_PLATFORM_WIN32)
#if defined(INTERNAL) #if defined(STAGING)
if (IsDebuggerPresent()) if (IsDebuggerPresent())
#endif #endif
{ {

View File

@ -14,6 +14,11 @@
#include <sys/sysctl.h> #include <sys/sysctl.h>
#endif #endif
#if defined(AURORA_IS_POSIX_DERIVED)
#include <stdlib.h>
#include <sys/sysinfo.h>
#endif
namespace Aurora::HWInfo namespace Aurora::HWInfo
{ {
static CpuInfo gCpuInfo; static CpuInfo gCpuInfo;
@ -448,7 +453,13 @@ namespace Aurora::HWInfo
gCpuInfo.socket = 1; gCpuInfo.socket = 1;
gCpuInfo.cores = 1; gCpuInfo.cores = 1;
gCpuInfo.threads = opt.value_or(1) gCpuInfo.threads = opt.value_or(1);
#elif defined(AURORA_IS_LINUX_DERIVED)
gCpuInfo.socket = 1;
gCpuInfo.cores = 1;
gCpuInfo.threads = get_nprocs(void);
#elif defined(AURORA_IS_POSIX_DERIVED) #elif defined(AURORA_IS_POSIX_DERIVED)

View File

@ -230,8 +230,8 @@ namespace Aurora::IO::FS
} }
bool ok {}; bool ok {};
ok = stream->Write(const Memory::MemoryViewStreamRead &{bom}); ok = stream->Write(Memory::MemoryViewStreamRead{bom});
ok &= stream->Write(const Memory::MemoryViewStreamRead &{str}); ok &= stream->Write(Memory::MemoryViewStreamRead{str});
stream->Flush(); stream->Flush();
return ok; return ok;

View File

@ -107,7 +107,7 @@ namespace Aurora::IO::FS
if (!::ReadFile(handle_, &reinterpret_cast<char *>(parameters.ptr)[offset], blockSize, &read, NULL)) if (!::ReadFile(handle_, &reinterpret_cast<char *>(parameters.ptr)[offset], blockSize, &read, NULL))
{ {
LogWarn("ReadFile IO Error: 0x%x, {}", GetLastError(), path_); LogWarn("ReadFile IO Error: 0x{:x}, {}", GetLastError(), path_);
SysPushErrorIO(); SysPushErrorIO();
return false; return false;
} }
@ -148,7 +148,7 @@ namespace Aurora::IO::FS
if (!::WriteFile(handle_, &reinterpret_cast<const char *>(parameters.ptr)[offset], blockSize, &written, NULL)) if (!::WriteFile(handle_, &reinterpret_cast<const char *>(parameters.ptr)[offset], blockSize, &written, NULL))
{ {
LogWarn("WriteFileEx IO Error: 0x%x, {}", GetLastError(), path_); LogWarn("WriteFileEx IO Error: 0x{:x}, {}", GetLastError(), path_);
SysPushErrorIO(); SysPushErrorIO();
return false; return false;
} }