[*/+/-] MEGA COMMIT. ~2 weeks compressed.

The intention is to quickly improve and add util apis, enhance functionality given current demands, go back to the build pipeline, finish that, publish runtime tests, and then use what we have to go back to to linux support with a more stable api.

[+] AuMakeSharedArray
[+] Technet ArgvQuote
[+] Grug subsystem (UNIX signal thread async safe ipc + telemetry flusher + log flusher.)
[+] auEndianness -> Endian swap utils
[+] AuGet<N>(...)
[*] AUE_DEFINE conversion for
        ECompresionType, EAnsiColor, EHashType, EStreamError, EHexDump
[+] ConsoleMessage ByteBuffer serialization
[+] CmdLine subsystem for parsing command line arguments and simple switch/flag checks
[*] Split logger from console subsystem
[+] StartupParameters -> A part of a clean up effort under Process
[*] Refactor SysErrors header + get caller hack
[+] Atomic APIs
[+] popcnt
[+] Ring Buffer sink
[+] Added more standard errors
        Catch,
        Submission,
        LockError,
        NoAccess,
        ResourceMissing,
        ResourceLocked,
        MalformedData,
        InSandboxContext,
        ParseError

[+] Added ErrorCategorySet, ErrorCategoryClear, GetStackTrace
[+] IExitSubscriber, ETriggerLevel
[*] Write bias the high performance RWLockImpl read-lock operation operation
[+] ExitHandlerAdd/ExitHandlerRemove (exit subsystem)
[*] Updated API style
        Digests
[+] CpuId::CpuBitCount
[+] GetUserProgramsFolder
[+] GetPackagePath
[*] Split IStreamReader with an inl file
[*] BlobWriter/BlobReader/BlobArbitraryReader can now take shared pointers to bytebuffers. default constructor allocates a new scalable bytebuffer
[+] ICharacterProvider
[+] ICharacterProviderEx
[+] IBufferedCharacterConsumer
[+] ProviderFromSharedString
[+] ProviderFromString
[+] BufferConsumerFromProvider
[*] Parse Subsystem uses character io bufferer
[*] Rewritten NT's high perf semaphore to use userland SRW/ConVars [like mutex, based on generic semaphore]
[+] ByteBuffer::ResetReadPointer
[*] Bug fix bytebuffer base not reset on free and some scaling issues
[+] ProcessMap -> Added kSectionNameStack, kSectionNameFile, kSectionNameHeap for Section
[*] ProcessMap -> Refactor Segment to Section. I was stupid for keeping a type conflict hack API facing
[+] Added 64 *byte* fast RNG seeds
[+] File Advisorys/File Lock Awareness
[+] Added extended IAuroraThread from OS identifier caches for debug purposes
[*] Tweaked how memory is reported on Windows. Better consistency of what values mean across functions.
[*] Broke AuroraUtils/Typedefs out into a separate library
[*] Update build script
[+] Put some more effort into adding detail to the readme before rewriting it, plus, added some media
[*] Improved public API documentation
[*] Bug fix `SetConsoleCtrlHandler`
[+] Locale TimeDateToFileNameISO8601
[+] Console config stdOutShortTime
[*] Begin using internal UTF8/16 decoders when platform support isnt available (instead of stl)
[*] Bug fixes in decoders
[*] Major bug fix, AuMax
[+] RateLimiter
[+] Binary file sink
[+] Log directory sink
[*] Data header usability (more operators)
[+] AuRemoveRange
[+] AuRemove
[+] AuTryRemove
[+] AuTryRemoveRange
[+] auCastUtils
[+] Finish NewLSWin32Source
[+] AuTryFindByTupleN, AuTryRemoveByTupleN
[+] Separated AuRead/Write types, now in auTypeUtils
[+] Added GetPosition/SetPosition to FileWriter
[*] Fix stupid AuMin in place of AuMax in SpawnThread.Unix.Cpp
[*] Refactored Arbitrary readers to SeekingReaders (as in, they could be atomic and/or parallelized, and accept an arbitrary position as a work parameter -> not Seekable, as in, you can simply set the position)
[*] Hack back in the sched deinit
[+] File AIO loop source interop
[+] Begin to prototype a LoopQueue object I had in mind for NT, untested btw
[+] Stub code for networking
[+] Compression BaseStream/IngestableStreamBase
[*] Major: read/write locks now support write-entrant read routines.
[*] Compression subsystem now uses the MemoryView concept
[*] Rewrite the base stream compressions, made them less broken
[*] Update hashing api
[*] WriterTryGoForward and ReaderTryGoForward now revert to the previous relative index instead of panicing
[+] Added new AuByteBuffer apis
    Trim, Pad, WriteFrom, WriteString, [TODO: ReadString]
[+] Added ByteBufferPushReadState
[+] Added ByteBufferPushWriteState
[*] Move from USC-16 to full UTF-16. Win32 can handle full UTF-16.
[*] ELogLevel is now an Aurora enum
[+] Raised arbitrary limit in header to 255, the max filter buffer
[+] Explicit GZip support
[+] Explicit Zip support
[+] Added [some] compressors

et al
This commit is contained in:
Reece Wilson 2022-02-17 00:11:40 +00:00
parent 19ebdf3761
commit cf70f0d45c
410 changed files with 14066 additions and 5180 deletions

View File

@ -15,7 +15,7 @@
{
"filter": {"platforms": "win32"},
"then": {
"links": ["Bcrypt.lib", "UxTheme.lib", "Aux_ulib.lib", "Dbghelp.lib", "ws2_32.lib", "Ntdll.lib"]
"links": ["Bcrypt.lib", "UxTheme.lib", "Aux_ulib.lib", "Dbghelp.lib", "ws2_32.lib", "Ntdll.lib", "Wer.lib", "wintrust.lib"]
}
}
]

View File

@ -9,7 +9,7 @@
namespace Aurora::Loop
{
class ILoopSource;
struct ILoopSource;
}
namespace Aurora::Async

View File

@ -51,9 +51,10 @@ namespace Aurora::Async
virtual WorkerId_t GetCurrentThread() = 0;
// Synchronization
// Note: syncing to yourself will nullify requireSignal to prevent deadlock
// Note: syncing to yourself will nullify requireSignal to prevent deadlock conditions
virtual bool Sync(WorkerId_t workerId, AuUInt32 timeoutMs = 0, bool requireSignal = false) = 0;
virtual void Signal(WorkerId_t workerId) = 0;
virtual AuSPtr<Loop::ILoopSource> WorkerToLoopSource(WorkerId_t id) = 0;
virtual void SyncAllSafe() = 0;
// Features

View File

@ -32,6 +32,7 @@ namespace Aurora::Async
// ns = time relative to the time at which the work item would otherwise dispatch
virtual AuSPtr<IWorkItem> AddDelayTimeNs(AuUInt64 ns) = 0;
// inverted WaitFor
virtual AuSPtr<IWorkItem> Then(const AuSPtr<IWorkItem> &next) = 0;
virtual AuSPtr<IWorkItem> Dispatch() = 0;

View File

@ -37,7 +37,7 @@ namespace Aurora::Async
FJob<AuTuple<Args...>, Out_t> ret;
ret.onSuccess = [=](const AuTuple<Args...> &in, const Out_t &a)
{
std::apply(onSuccess, std::tuple_cat(in, AuMakeTuple<const Out_t &>(a)));
AuTupleApply(onSuccess, AuTupleCat(in, AuMakeTuple<const Out_t &>(a)));
};
return ret;
}
@ -48,12 +48,12 @@ namespace Aurora::Async
FJob<AuTuple<Args...>, Out_t> ret;
ret.onSuccess = [=](const AuTuple<Args...> &in, const Out_t &a)
{
std::apply(onSuccess, std::tuple_cat(in, AuMakeTuple<const Out_t &>(a)));
AuTupleApply(onSuccess, AuTupleCat(in, AuMakeTuple<const Out_t &>(a)));
};
ret.onFailure = [=](const AuTuple<Args...> &in)
{
std::apply(onFailure, in);
AuTupleApply(onFailure, in);
};
return ret;
}
@ -115,7 +115,7 @@ namespace Aurora::Async
FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<Arg0_t, Args...> &in, const ReturnValue_t &out)
{
onSuccess(std::get<0>(in), out);
onSuccess(AuGet<0>(in), out);
};
return ret;
}
@ -126,12 +126,12 @@ namespace Aurora::Async
FJob<AuTuple<Arg0_t, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<Arg0_t, Args...> &in, const ReturnValue_t &out)
{
onSuccess(std::get<0>(in), out);
onSuccess(AuGet<0>(in), out);
};
ret.onFailure = [=](const AuTuple<Arg0_t, Args...> &in)
{
onFailure(std::get<0>(in));
onFailure(AuGet<0>(in));
};
return ret;
}
@ -154,7 +154,7 @@ namespace Aurora::Async
FJob<AuTuple<AuSPtr<Clazz_t>, Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<AuSPtr<Clazz_t>, Args...> &in, const ReturnValue_t &out)
{
std::apply(onSuccess, std::tuple_cat(AuTuplePopFront(in), AuMakeTuple<const ReturnValue_t &>(out)));
AuTupleApply(onSuccess, AuTupleCat(AuTuplePopFront(in), AuMakeTuple<const ReturnValue_t &>(out)));
};
return ret;
}
@ -177,7 +177,7 @@ namespace Aurora::Async
FJob<AuTuple<Args...>, ReturnValue_t> ret;
ret.onSuccess = [=](const AuTuple<Args...> &in, const ReturnValue_t &out)
{
std::apply(onSuccess, std::tuple_cat(in, AuMakeTuple<const ReturnValue_t &>(out)));
AuTupleApply(onSuccess, AuTupleCat(in, AuMakeTuple<const ReturnValue_t &>(out)));
};
return ret;
}

View File

@ -34,7 +34,7 @@ namespace Aurora::Async
FTask<AuTuple<Args...>, Out_t> ret;
ret.onFrame = [callable = func](const AuTuple<Args...> &in) -> Out_t
{
return std::apply(callable, in);
return AuTupleApply(callable, in);
};
return ret;
}
@ -45,7 +45,7 @@ namespace Aurora::Async
FTask<AuTuple<Owner_t, Args...>, Out_t> ret;
ret.onFrame = [callable = func](const AuTuple<Args...> &in) -> Out_t
{
return std::apply(callable, AuTuple_cat(AuMakeTuple<Owner_t>(ownerToPin), in));
return AuTupleApply(callable, AuTupleCat(AuMakeTuple<Owner_t>(ownerToPin), in));
};
return ret;
}
@ -56,7 +56,7 @@ namespace Aurora::Async
Task_t ret;
ret.onFrame = [callable = func](const auto &in) -> ReturnValue_t
{
return std::apply(callable, AuTuplePopFront(in));
return AuTupleApply(callable, AuTuplePopFront(in));
};
return ret;
}
@ -67,7 +67,7 @@ namespace Aurora::Async
Task_t ret;
ret.onFrame = [callable = func](const auto &in) -> ReturnValue_t
{
return std::apply(callable, AuTuplePopFront(in));
return AuTupleApply(callable, AuTuplePopFront(in));
};
return ret;
}

View File

@ -0,0 +1,59 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: CmdLine.hpp
Date: 2022-1-31
Author: Reece
Note: Even kernels have a commandline so why not?
***/
#pragma once
namespace Aurora::CmdLine
{
/**
* @brief Returns a UTF-8 string array of argv[1, ...]
* @return
*/
AUKN_SYM const AuList<AuString> &GetCommandLineArguments();
/**
* @brief Performs a check on whether the exact key matches an argument
* @param key
* @return
*/
AUKN_SYM bool HasFlag(const AuString &key);
/**
* @brief Performs a check on whether such string came before an equals sign
* @param key
* @return
*/
AUKN_SYM bool HasValue(const AuString &key);
/**
* @brief Returns part after key= or defaultDefault
* @param key
* @param defaultValue
* @return
*/
AUKN_SYM const AuString &GetValue(const AuString &key, const AuString &defaultValue);
/**
* @brief Returns part after key= or an empty string
* @param key
* @return
*/
AUKN_SYM const AuString &GetValue(const AuString &key);
/**
* @brief Returns a constant array of flag keys
* @return
*/
AUKN_SYM const AuList<AuString> &GetFlags();
/**
* @brief Returns a constant array of value keys
* @return
*/
AUKN_SYM const AuList<AuString> &GetValues();
}

View File

@ -12,20 +12,10 @@ namespace Aurora::Compression
/**
Compresses an in memory blob with zstandard
*/
AUKN_SYM bool Compress(const void *buffer, AuUInt32 length, Memory::ByteBuffer &out, int compressionLevel = 3);
/**
Compresses an in memory blob with zstandard
*/
AUKN_SYM bool Compress(const Memory::ByteBuffer &in, Memory::ByteBuffer &out, int compressionLevel = 3);
AUKN_SYM bool Compress(const Memory::MemoryViewRead &source, Memory::ByteBuffer &out, int compressionLevel = 3);
/**
Decompresses an in memory blob with zstandard
*/
AUKN_SYM bool Decompress(const void *buffer, AuUInt32 length, Memory::ByteBuffer &out);
/**
Decompresses an in memory blob with zstandard
*/
AUKN_SYM bool Decompress(const Memory::ByteBuffer &in, Memory::ByteBuffer &out);
AUKN_SYM bool Decompress(const Memory::MemoryViewRead &source, Memory::ByteBuffer &out);
}

View File

@ -7,6 +7,44 @@
***/
#pragma once
// Types
#include "ECompresionType.hpp"
#include "CompressionInfo.hpp"
// Legacy API
#include "StreamPipeProcessor.hpp"
// Recommended API
#include "ICompressionStream.hpp"
#include "StreamProcessor.hpp"
// Utility
#include "BasicCompression.hpp"
// TODO: neat comment + real world data
/*
Ballpark figures of real world performance:
https://www.gaia-gis.it/fossil/librasterlite2/wiki?name=benchmarks+(2019+update)
@ -23,14 +61,4 @@
LZ4 -> Network compression and other large data streams (~4.5GB/s, 2.884 compression ratio)
ZSTD -> Standard use (~1.5GB/s to 2.5GB/s, respective compression ratios 2.4 and 2.1. Can be pushed to ~10 at around 750MB/s. Great general use. )
ZIP -> Zlib has a disgusting decompression upper limit of around 450MB/s for 2.7
*/
#include "BasicCompression.hpp"
#include "ECompresionType.hpp"
#include "CompressionInfo.hpp"
#include "StreamPipeProcessor.hpp"
#include "ICompressionStream.hpp"
#include "StreamProcessor.hpp"
*/

View File

@ -12,39 +12,94 @@ namespace Aurora::Compression
struct CompressionInfo
{
ECompresionType type;
/**
* @brief
*
* ZSTD: -5 <= level <= 22
* recommended: ZSTD_CLEVEL_DEFAULT
* LZMA: 0 <= level <= 9
* LZ4 : N/A
* Deflate: 0 <= x >= 9,
* recommended: 6
* Zip: 0 <= x >= 9,
* recommended: 6
* GZip: 0 <= x >= 9,
* recommended: 6
* BZIP: 0 <= x >= 9
*
*/
AuInt8 compressionLevel {6};
/// ZSTD: -5 <= level <= 22
/// recommended: ZSTD_CLEVEL_DEFAULT
/// LZMA: 0 <= level <= 9
/// LZ4 : N/A
/// ZLIB: 0 <= x >= 9
/// recommended: 6
/// BZIP: 0 <= x >= 9
AuInt8 compressionLevel{};
/**
* @brief LZMA: 5 <= fb <= 273, default = 32
*/
AuUInt32 fbWordSize {32};
/// LZMA: 5 <= fb <= 273, default = 32
AuUInt32 fbWordSize{};
/// LZMA only
/// (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
/// (1 << 12) <= dictSize <= (3 << 29) for 64-bit version
/// default = (1 << 24)
/**
* LZMA only
* (1 << 12) <= dictSize <= (1 << 27) for 32-bit version
* (1 << 12) <= dictSize <= (3 << 29) for 64-bit version
* default = (1 << 24)
*/
AuUInt32 dictSize{};
// 64KiB is a recommended "small" block size
/**
* @brief 64KiB is a recommended "small" block size
*/
AuUInt16 lz4BlockSize {};
};
/**
* @brief DEFLATE related variabl
*
* Deflate: 0 <= x >= 15,
* recommended: 15
* Zip: 0 <= x >= 15,
* recommended: 15
* GZip: 0 <= x >= 15,
* recommended: 15
*/
AuUInt8 windowBits {15};
/**
* @brief Internal output buffer size.
* Internal swap page is undefined.
*/
AuUInt32 internalStreamSize {4096};
AuUInt8 threads {1};
; };
struct DecompressInfo
{
/**
* @brief algorithm
*/
ECompresionType alg {ECompresionType::eDeflate};
/**
* @brief Internal output buffer size. Internal swap page is undefined.
*/
AuUInt32 internalStreamSize {4096};
/**
* @brief Flag for headerless decompression streams
*/
bool hasWindowbits {true};
/**
* @brief Flag for headerless decompression streams
*/
AuInt8 windowBits {15};
DecompressInfo(ECompresionType alg) : alg(alg)
{
}
AuUInt32 internalStreamSize {};
bool permitResize {};
DecompressInfo(ECompresionType alg, AuUInt32 bufferSize) : alg(alg), internalStreamSize(bufferSize)
{
}
};
}

View File

@ -9,12 +9,14 @@
namespace Aurora::Compression
{
enum class ECompresionType
{
AUE_DEFINE(ECompresionType,
(
eLZMA,
eZSTD,
eDeflate,
eZip,
eGZip,
eLZ4,
eBZIP2
};
));
}

View File

@ -9,25 +9,66 @@
namespace Aurora::Compression
{
class ICompressionStream
struct ICompressionStream
{
public:
/// Ingest n bytes from the input stream assigned to the compression object
/**
* @brief Ingest n bytes from the input stream assigned to the compression object.
* On error, returns {0, 0} or {bytesRead, 0}
* If the stream buffer runs out of memory, {bytesRead, 0} is expected, and although
* `GetAvailableProcessedBytes()` will still return some data, the decompressed data
* or uncompressed stream will be dropped in part, and you should destroy from the stream object
* @param bytesFromUnprocessedInputSource
* @return
*/
virtual AuStreamReadWrittenPair_t Ingest(AuUInt32 bytesFromUnprocessedInputSource) = 0;
/// Limited stream API
virtual bool ReadByProcessedN (void * /*opt*/, AuUInt32 minimumProcessed, AuStreamReadWrittenPair_t &pair, bool ingestUntilEOS = true) = 0;
/**
* @brief Returns the available bytes for immediate release
* @return
*/
virtual AuUInt32 GetAvailableProcessedBytes() = 0;
/**
* @brief Returns the internal overhead to store the seekable stream buffer
* @return
*/
virtual AuUInt32 GetInternalBufferSize() = 0;
/**
* @brief Reads 'minimumProcessed', optionally into the first buffer, until EOS or destination length.
* If the destination is null and the length is a nonzero value, the stream seeks ahead
* If the destination is null and the length is a zero, {0, GetAvailableProcessedBytes} is returned
* @param destination
* @param ingestUntilEOS should continue to poll Ingest with an arbitrary page size to fulfill destination.length
* @return Bytes read / written
*/
virtual AuStreamReadWrittenPair_t ReadEx(const Memory::MemoryViewWrite & /*opt*/ destination, bool ingestUntilEOS = true) = 0;
/// Limited stream API
virtual bool ReadByProcessedN (void * /*opt*/, AuUInt32 minimumProcessed) = 0;
/**
* @brief Reads 'minimumProcessed', optionally into the first buffer, from the internal stream buffer
* @param destination
* @return Bytes written
*/
virtual AuUInt32 Read(const Memory::MemoryViewWrite & /*opt*/ destination) = 0;
/// Limited stream API
/**
* @brief Seek processed read functions backwards
* @param offset
* @return
*/
virtual bool GoBackByProcessedN (AuUInt32 offset) = 0;
/// Limited stream API
/**
* @brief Seek read processed forward
* @param offset
* @return
*/
virtual bool GoForwardByProcessedN(AuUInt32 offset) = 0;
/// Compression only
virtual void Flush() = 0;
virtual bool Flush() = 0;
/// Compression only
virtual bool Finish() = 0;
};
}

View File

@ -14,7 +14,7 @@ namespace Aurora::Compression
/// algorithm
/// LZMA decompression + compression, and ZSTD compression only
AuUInt32 threads;
AuUInt32 threads {1};
/// consume from stream callback
AuFunction<AuUInt(void *, AuUInt)> inPipe;

View File

@ -11,6 +11,13 @@
namespace Aurora::Compression
{
/**
* @brief
*/
AUKN_SHARED_API(Decompressor, ICompressionStream, const AuSPtr<IO::IStreamReader> &reader, const DecompressInfo &info);
/**
* @brief
*/
AUKN_SHARED_API(Compressor, ICompressionStream, const AuSPtr<IO::IStreamReader> &reader, const CompressionInfo &info);
}

View File

@ -8,6 +8,7 @@
#pragma once
#include <Aurora/Parse/Parse.hpp>
#include "ICommandSubscriber.hpp"
namespace Aurora::Async
{
@ -15,8 +16,6 @@ namespace Aurora::Async
struct WorkerPId_t;
}
#include "ICommandSubscriber.hpp"
namespace Aurora::Console::Commands
{
AUKN_SYM void AddCommand(const AuString &tag, const Parse::ParseObject &commandStructure, const AuSPtr<ICommandSubscriber> &subscriber);

View File

@ -10,23 +10,13 @@
#include "EAnsiColor.hpp"
#include "ConsoleMessage.hpp"
namespace Aurora::Logging
{
struct ILogger;
}
namespace Aurora::Console
{
namespace Logging
{
struct ILogger;
}
/// Writes a log message to the console subscribers and telemetry outputs
AUKN_SYM void WriteLine(AuUInt8 level, const ConsoleMessage &msg);
/**
* @brief Overloads the ILogger backend of the AuLogXX functions
* @param defaultGlobalLogger
* @return
*/
AUKN_SYM void SetGlobalLogger(const AuSPtr<Logging::ILogger> &defaultGlobalLogger);
/**
* @brief Returns the untouched ILogger interface of the AuLogXX functions as configured by the Aurora::RuntimeStartInfo structure
* @return
@ -63,4 +53,3 @@ namespace Aurora::Console
#include "Commands/Commands.hpp"
#include "Hooks/Hooks.hpp"
#include "Logging/Logging.hpp"

View File

@ -47,6 +47,9 @@ namespace Aurora::Console
tid = Threading::Threads::GetThreadId();
}
AUKN_SYM void Read(Memory::ByteBuffer &deserialize);
AUKN_SYM void Write(Memory::ByteBuffer &serialize) const;
AUKN_SYM AuString StringifyTime(bool simple = false) const;
AUKN_SYM AuString StringifyTimeUTC() const;
AUKN_SYM AuString GetWrappedTag() const;

View File

@ -9,8 +9,8 @@
namespace Aurora::Console
{
enum class EAnsiColor
{
AUE_DEFINE(EAnsiColor,
(
eRed,
eBoldRed,
eGreen,
@ -23,7 +23,6 @@ namespace Aurora::Console
eBoldMagenta,
eCyan,
eBoldCyan,
eReset,
eCount
};
eReset
));
}

View File

@ -1,17 +0,0 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IBasicSink.hpp
Date: 2021-11-1
Author: Reece
***/
#pragma once
namespace Aurora::Console::Logging
{
AUKN_INTERFACE(IBasicSink,
AUI_METHOD(void, OnMessageBlocking, (AuUInt8, level, const ConsoleMessage &, msg)),
AUI_METHOD(void, OnMessageNonblocking, (AuUInt8, level, const ConsoleMessage &, msg)),
AUI_METHOD(void, OnFlush, ())
)
}

View File

@ -1,17 +0,0 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IBasicSinkRB.hpp
Date: 2021-11-2
Author: Reece
***/
#pragma once
namespace Aurora::Console::Logging
{
struct IBasicSinkRB : IBasicSink
{
virtual void SaveToPath(const AuString &path, bool plainText = false) = 0;
virtual AuList<ConsoleMessage> Export() = 0;
};
}

View File

@ -1,23 +0,0 @@
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Sinks.hpp
Date: 2021-11-2
Author: Reece
***/
#pragma once
namespace Aurora
{
struct SocketConsole;
}
namespace Aurora::Console::Logging
{
AUKN_SHARED_API(NewStdSink, IBasicSink);
AUKN_SHARED_API(NewOSEventDirectorySink, IBasicSink);
AUKN_SHARED_API(NewFileSink, IBasicSink, const AuString &path, bool binary = false);
AUKN_SHARED_API(NewIPCSink, IBasicSink, const SocketConsole &console);
AUKN_SHARED_API(NewRingLogger, IBasicSinkRB, AuUInt32 approxMaxBytes);
AUKN_SHARED_API(NewLogger, ILogger, const AuList<AuSPtr<IBasicSink>> &sinks);
}

View File

@ -9,12 +9,12 @@
namespace Aurora::Crypto::ECC
{
enum EECCCurve
{
AUE_DEFINE(EECCCurve,
(
eCurve256,
eCurve384,
eCurve521,
eCurveX25519,
eCurveEd25519
};
));
}

View File

@ -13,5 +13,98 @@ namespace Aurora::Data
{
EDataType type;
Value value;
TypedValue()
{
type = EDataType::kTypeEND;
}
#define TYPEDVALUE_CONSTRUCTOR(typen, typeval, datatype) inline TypedValue(typen typeval) : value(typeval), type(datatype) {}
TYPEDVALUE_CONSTRUCTOR(const AuVec3 &, vec3, EDataType::kTypeVec3);
TYPEDVALUE_CONSTRUCTOR(const AuVec4 &, vec4, EDataType::kTypeVec4);
TYPEDVALUE_CONSTRUCTOR(bool, boolean, EDataType::kTypeBoolean);
TYPEDVALUE_CONSTRUCTOR(double, number, EDataType::kTypeNumber);
TYPEDVALUE_CONSTRUCTOR(AuInt64, sint, EDataType::kTypeSInt);
TYPEDVALUE_CONSTRUCTOR(AuUInt64, uint, EDataType::kTypeUInt);
TYPEDVALUE_CONSTRUCTOR(uuids::uuid, uuid, EDataType::kTypeUUID);
TYPEDVALUE_CONSTRUCTOR(const AuString &, str, EDataType::kTypeString);
#undef TYPEDVALUE_CONSTRUCTOR
inline AuString ToString() const
{
if (!IsValid()) return "INVALID DATATYPE";
switch (type)
{
case EDataType::kTypeUInt:
return AuToString(value.primitive.uint);
case EDataType::kTypeSInt:
return AuToString(value.primitive.sint);
case EDataType::kTypeNumber:
return AuToString(value.primitive.number);
case EDataType::kTypeString:
return value.string;
case EDataType::kTypeBoolean:
return value.primitive.boolean ? "true" : "false";
case EDataType::kTypeUUID:
return uuids::to_string(value.UUID);
case EDataType::kTypeVec3:
return AuToString(value.primitive.vec3[0]) + "." +
AuToString(value.primitive.vec3[1]) + "." +
AuToString(value.primitive.vec3[2]);
case EDataType::kTypeVec4:
return AuToString(value.primitive.vec4[0]) + "." +
AuToString(value.primitive.vec4[1]) + "." +
AuToString(value.primitive.vec4[2]) + "." +
AuToString(value.primitive.vec4[3]);
default:
return {};
}
return {};
}
inline bool operator==(const TypedValue &cmp) const
{
if (cmp.type != type)
{
return false;
}
switch (type)
{
case EDataType::kTypeUInt:
return cmp.value.primitive.uint == value.primitive.uint;
case EDataType::kTypeSInt:
return cmp.value.primitive.sint == value.primitive.sint;
case EDataType::kTypeNumber:
return cmp.value.primitive.number == value.primitive.number;
case EDataType::kTypeString:
return cmp.value.string == value.string;
case EDataType::kTypeBoolean:
return cmp.value.primitive.boolean == value.primitive.boolean;
case EDataType::kTypeUUID:
return cmp.value.UUID == value.UUID;
case EDataType::kTypeVec3:
return cmp.value.primitive.vec3 == value.primitive.vec3;
case EDataType::kTypeVec4:
return cmp.value.primitive.vec4 == value.primitive.vec4;
default:
return false;
}
return false;
}
inline bool IsValid() const
{
return static_cast<int>(type) < static_cast<int>(EDataType::kTypeGenericMax);
}
inline operator bool() const
{
return IsValid();
}
};
}

View File

@ -48,7 +48,25 @@ namespace Aurora::Debug
AUKN_SYM void CheckErrors();
/**
* @brief Specifies an EFailureCategory value for the current thread
* @param category
* @return
*/
AUKN_SYM void ErrorCategorySet(EFailureCategory category);
/**
* @brief Guarantees a refresh of ErrorCategoryGet's current value
* @return
*/
AUKN_SYM void ErrorCategoryClear();
/**
* @brief Returns the last EFailureCategory as specified by ErrorCategorySet or SysPushErrors
* @return
*/
AUKN_SYM EFailureCategory ErrorCategoryGet();
AUKN_SYM StackTrace GetStackTrace();
/**

View File

@ -34,7 +34,17 @@ namespace Aurora::Debug
kFailureDisconnected,
kFailureUninitialized,
kFailureUnimplemented,
kFailureCatch,
kFailureSubmission,
kFailureLockError,
kFailureNoAccess,
kFailureResourceMissing,
kFailureResourceLocked,
kFailureMalformedData,
kFailureInSandboxContext,
kFailureParseError,
kFailureNone = 255,
kFailureUserBegin = 256
};
}

View File

@ -21,8 +21,8 @@
return;
}
Aurora::Console::Logging::WriteLinef(
static_cast<AuUInt8>(Aurora::Console::Logging::ELogLevel::eError),
Aurora::Logging::WriteLinef(
static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError),
Aurora::Console::EAnsiColor::eBoldRed,
"Fatal",
"Expression address: {} {}:{}", func, file, fileno);
@ -107,14 +107,14 @@
return;
}
Aurora::Console::Logging::WriteLinef(
static_cast<AuUInt8>(Aurora::Console::Logging::ELogLevel::eError),
Aurora::Logging::WriteLinef(
static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError),
Aurora::Console::EAnsiColor::eBoldRed,
"Fatal",
"Expression address: {} {}:{}", func, file, fileno);
Aurora::Console::Logging::WriteLinef(
static_cast<AuUInt8>(Aurora::Console::Logging::ELogLevel::eError),
Aurora::Logging::WriteLinef(
static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError),
Aurora::Console::EAnsiColor::eBoldRed,
"Fatal",
"Expression failed: {}", exp);
@ -158,8 +158,8 @@
return;
}
Aurora::Console::Logging::WriteLinef(
static_cast<AuUInt8>(Aurora::Console::Logging::ELogLevel::eError),
Aurora::Logging::WriteLinef(
static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError),
Aurora::Console::EAnsiColor::eBoldRed,
"Fatal",
"Expression failed: {}", exp);

View File

@ -28,23 +28,55 @@ namespace Aurora::Debug
#define _FREECOMPILER_OPTIMIZE_OFF __attribute__((optimize("0")))
#endif
static AU_NOINLINE void ErrorMakeNested() _FREECOMPILER_OPTIMIZE_OFF
// TODO: bring the xenus thing into here
static AU_NOINLINE AuUInt GetIPNoBackend() _FREECOMPILER_OPTIMIZE_OFF
{
return _DBG_RET_ADDR;
}
#if defined(AURORA_COMPILER_MSVC)
#pragma optimize("", on)
#endif
#undef _FREECOMPILER_OPTIMIZE_OFF
static auline void ErrorMakeNested()
{
_PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, nullptr);
}
template<typename ... T>
static AU_NOINLINE void ErrorMakeNested(const AuString &msg, T&& ... args) _FREECOMPILER_OPTIMIZE_OFF
auline void ErrorMakeNested(const AuString &msg, T&& ... args)
{
#if defined(_AUHAS_FMT)
_PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, fmt::format(msg, AuForward<T>(args)...).c_str());
#else
_PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, nullptr);
#endif
if constexpr (sizeof...(T) == 0)
{
_PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, msg.c_str());
}
else
{
#if defined(_AUHAS_FMT)
try
{
auto tempString = fmt::format(msg, AuForward<T>(args)...);
_PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, tempString.c_str());
}
catch (...)
{
_PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, msg.c_str());
}
#else
_PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, msg.c_str());
#endif
}
}
static auline void ErrorMakeNested(const char *msg)
{
_PushError(_DBG_RET_ADDR, EFailureCategory::kFailureNested, msg);
}
template<typename ... T>
static AU_NOINLINE void SysPushError(EFailureCategory category, const AuString &msg, T&& ... args) _FREECOMPILER_OPTIMIZE_OFF
auline void SysPushError(EFailureCategory category, const AuString &msg, T&& ... args)
{
if constexpr (sizeof...(T) == 0)
{
@ -53,22 +85,30 @@ namespace Aurora::Debug
else
{
#if defined(_AUHAS_FMT)
_PushError(_DBG_RET_ADDR, category, fmt::format(msg, AuForward<T>(args)...).c_str());
try
{
auto tempString = fmt::format(msg, AuForward<T>(args)...);
_PushError(_DBG_RET_ADDR, category, tempString.c_str());
}
catch (...)
{
_PushError(_DBG_RET_ADDR, category, msg.c_str());
}
#else
_PushError(_DBG_RET_ADDR, category, "Missing dependency");
_PushError(_DBG_RET_ADDR, category, msg.c_str());
#endif
}
}
static AU_NOINLINE void SysPushError(EFailureCategory category) _FREECOMPILER_OPTIMIZE_OFF
static auline void SysPushError(EFailureCategory category, const char *msg)
{
_PushError(_DBG_RET_ADDR, category, msg);
}
static auline void SysPushError(EFailureCategory category)
{
_PushError(_DBG_RET_ADDR, category, nullptr);
}
#if defined(AURORA_COMPILER_MSVC)
#pragma optimize("", on)
#endif
#undef _FREECOMPILER_OPTIMIZE_OFF
}
#define SysCheckReturn(x, ...) if (!(static_cast<bool>(x))) { Aurora::Debug::ErrorMakeNested(); return __VA_ARGS__; }
@ -88,6 +128,7 @@ namespace Aurora::Debug
// enums
#define SysPushErrorGeneric(...) SysPushErrorError(kFailureGeneric, ## __VA_ARGS__)
#define SysPushErrorCatch(...) SysPushErrorError(kFailureCatch, ## __VA_ARGS__)
#define SysPushErrorMemory(...) SysPushErrorError(kFailureMemory, ## __VA_ARGS__)
#define SysPushErrorIO(...) SysPushErrorError(kFailureIO, ## __VA_ARGS__)
#define SysPushErrorFIO(...) SysPushErrorError(kFailureFIO, ## __VA_ARGS__)
@ -109,6 +150,15 @@ namespace Aurora::Debug
#define SysPushErrorDisconnected(...) SysPushErrorError(kFailureDisconnected, ## __VA_ARGS__)
#define SysPushErrorUninitialized(...) SysPushErrorError(kFailureUninitialized, ## __VA_ARGS__)
#define SysPushErrorUnimplemented(...) SysPushErrorError(kFailureUnimplemented, ## __VA_ARGS__)
#define SysPushErrorSubmission(...) SysPushErrorError(kFailureSubmission, ## __VA_ARGS__)
#define SysPushErrorLockError(...) SysPushErrorError(kFailureLockError, ## __VA_ARGS__)
#define SysPushErrorSyntax(...) SysPushErrorError(kFailureSyntax, ## __VA_ARGS__)
#define SysPushErrorNoAccess(...) SysPushErrorError(kFailureNoAccess, ## __VA_ARGS__)
#define SysPushErrorResourceMissing(...) SysPushErrorError(kFailureResourceMissing, ## __VA_ARGS__)
#define SysPushErrorResourceLocked(...) SysPushErrorError(kFailureResourceLocked, ## __VA_ARGS__)
#define SysPushErrorMalformedData(...) SysPushErrorError(kFailureMalformedData, ## __VA_ARGS__)
#define SysPushErrorInSandboxContext(...) SysPushErrorError(kFailureInSandboxContext, ## __VA_ARGS__)
#define SysPushErrorParseError(...) SysPushErrorError(kFailureParseError, ## __VA_ARGS__)
#if defined(DEBUG) || defined(STAGING)
@ -144,6 +194,16 @@ namespace Aurora::Debug
#define SysPushErrorDisconnectedDbg SysPushErrorDisconnected
#define SysPushErrorUninitializedDbg SysPushErrorUninitialized
#define SysPushErrorUnimplementedDbg SysPushErrorUnimplemented
#define SysPushErrorCatchDbg SysPushErrorCatch
#define SysPushErrorSubmissionDbg SysPushErrorSubmission
#define SysPushErrorLockErrorDbg SysPushErrorLockError
#define SysPushErrorSyntaxDbg SysPushErrorSyntax
#define SysPushErrorNoAccessDbg SysPushErrorNoAccess
#define SysPushErrorResourceMissingDbg SysPushErrorResourceMissing
#define SysPushErrorResourceLockedDbg SysPushErrorResourceLocked
#define SysPushErrorMalformedDataDbg SysPushErrorMalformedData
#define SysPushErrorInSandboxContextDbg SysPushErrorInSandboxContext
#define SysPushErrorParseErrorDbg SysPushErrorParseError
#else
@ -177,5 +237,16 @@ namespace Aurora::Debug
#define SysPushErrorDisconnectedDbg(...)
#define SysPushErrorUninitializedDbg(...)
#define SysPushErrorUnimplementedDbg(...)
#define SysPushErrorCatchDbg(...)
#define SysPushErrorSubmissionDbg(...)
#define SysPushErrorLockErrorDbg(...)
#define SysPushErrorSyntaxDbg(...)
#define SysPushErrorNoAccessDbg(...)
#define SysPushErrorResourceMissingDbg(...)
#define SysPushErrorResourceLockedDbg(...)
#define SysPushErrorMalformedDataDbg(...)
#define SysPushErrorInSandboxContextDbg(...)
#define SysPushErrorParseErrorDbg(...)
#endif

View File

@ -9,9 +9,9 @@
#if defined(_AUHAS_FMT)
template<typename ... T>
static inline void __declspec(noreturn) SysPanic(T... args)
static inline void AU_NORETURN SysPanic(T... args)
{
Aurora::Console::Logging::WriteLinef(static_cast<AuUInt8>(Aurora::Console::Logging::ELogLevel::eError), Aurora::Console::EAnsiColor::eBoldRed, "Fatal", AuForward<T>(args)...);
Aurora::Logging::WriteLinef(static_cast<AuUInt8>(Aurora::Logging::ELogLevel::eError), Aurora::Console::EAnsiColor::eBoldRed, "Fatal", AuForward<T>(args)...);
Aurora::Debug::Panic();
}
#endif

View File

@ -0,0 +1,26 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: ETriggerLevel.hpp
Date: 2022-1-30
Author: Reece
***/
#pragma once
namespace Aurora::Exit
{
AUE_DEFINE(ETriggerLevel, (
// Runtime deinitialize
eSafeTermination,
// A fatal exception was caught by the watchdog. The process is on its way out
eFatalException,
// Control+C was sent, termination must follow
eSigTerminate,
// Something went wrong in the process. These could be frequent depending on the process
eProblematicEvent
));
}

View File

@ -0,0 +1,36 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Exit.hpp
Date: 2022-1-30
Author: Reece
***/
#pragma once
#include "ETriggerLevel.hpp"
#include "IExitSubscriber.hpp"
namespace Aurora::Exit
{
/**
* @brief Registers @param callback to the registry to subscribe to @param level events
* @param level
* @param callback
* @return
*/
AUKN_SYM bool ExitHandlerAdd(ETriggerLevel level, const AuSPtr<IExitSubscriber> &callback);
/**
* @brief Removes all exit handlers by pointer
* @param callback
* @return
*/
AUKN_SYM void ExitHandlerRemove(const AuSPtr<IExitSubscriber> &callback);
/**
* @brief Used from within callbacks to determine if the application is shutting down.
* @return
*/
AUKN_SYM bool IsAppRunning();
}

View File

@ -0,0 +1,23 @@
/***
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: IExitSubscriber.hpp
Date: 2022-1-30
Author: Reece
***/
#pragma once
namespace Aurora::Exit
{
struct ExitInvoker
{
Threading::Threads::IAuroraThread *pCaller;
};
/**
* @brief User definedable callback
*/
AUKN_INTERFACE(IExitSubscriber,
AUI_METHOD(void, OnTrigger, (ETriggerLevel, level, const ExitInvoker *, pInvoker))
);
}

View File

@ -32,7 +32,8 @@ namespace Aurora::HWInfo
inline CpuBitId Or(const CpuBitId &id) const;
inline bool CpuBitScanForward(AuUInt8 &index, AuUInt8 offset) const;
inline AuUInt8 CpuBitCount() const;
inline bool TestCpuIdx(AuUInt8 idx) const;
inline void Clear();
inline void SetBit(AuUInt8 idx);

View File

@ -33,6 +33,17 @@ namespace Aurora::HWInfo
#endif
}
inline AuUInt8 CpuBitId::CpuBitCount() const
{
return AuPopCnt(lower) +
AuPopCnt(upper)
#if defined(_AU_MASSIVE_CPUID)
+ AuPopCnt(upper2)
+ AuPopCnt(upper3)
#endif
;
}
bool CpuBitId::CpuBitScanForward(AuUInt8 &index, AuUInt8 offset) const
{
#if defined(_AU_MASSIVE_CPUID)

View File

@ -9,53 +9,9 @@
namespace Aurora::Hashing
{
AUKN_SYM void MD5(const void *buffer, AuMach length, AuArray<AuUInt8, 16> &md5);
static void MD5(const Memory::ByteBuffer &bytebuffer, AuArray<AuUInt8, 16> &md5)
{
return MD5(bytebuffer.data(), bytebuffer.size(), md5);
}
static void MD5(const AuString &bytebuffer, AuArray<AuUInt8, 16> &md5)
{
return MD5(bytebuffer.data(), bytebuffer.size(), md5);
}
AUKN_SYM void SHA1(const void *buffer, AuMach length, AuArray<AuUInt8, 20> &sha1);
static void SHA1(const Memory::ByteBuffer &bytebuffer, AuArray<AuUInt8, 20> &sha1)
{
return SHA1(bytebuffer.data(), bytebuffer.size(), sha1);
}
static void SHA1(const AuString &bytebuffer, AuArray<AuUInt8, 20> &sha1)
{
return SHA1(bytebuffer.data(), bytebuffer.size(), sha1);
}
AUKN_SYM void Tiger(const void *buffer, AuMach length, AuArray<AuUInt8, 24> &tiger);
static void Tiger(const Memory::ByteBuffer &bytebuffer, AuArray<AuUInt8, 24> &tiger)
{
return Tiger(bytebuffer.data(), bytebuffer.size(), tiger);
}
static void Tiger(const AuString &bytebuffer, AuArray<AuUInt8, 24> &tiger)
{
return Tiger(bytebuffer.data(), bytebuffer.size(), tiger);
}
AUKN_SYM void SHA2(const void *buffer, AuMach length, AuArray<AuUInt8, 32> &sha2);
static void SHA2(const Memory::ByteBuffer &bytebuffer, AuArray<AuUInt8, 32> &sha2)
{
return SHA2(bytebuffer.data(), bytebuffer.size(), sha2);
}
static void SHA2(const AuString &bytebuffer, AuArray<AuUInt8, 32> &sha2)
{
return SHA2(bytebuffer.data(), bytebuffer.size(), sha2);
}
AUKN_SYM void SHA2_64(const void *buffer, AuMach length, AuArray<AuUInt8, 64> &sha2);
static void SHA2_64(const Memory::ByteBuffer &bytebuffer, AuArray<AuUInt8, 64> &sha2)
{
return SHA2_64(bytebuffer.data(), bytebuffer.size(), sha2);
}
static void SHA2_64(const AuString &bytebuffer, AuArray<AuUInt8, 64> &sha2)
{
return SHA2_64(bytebuffer.data(), bytebuffer.size(), sha2);
}
AUKN_SYM void MD5(const Memory::MemoryViewRead &span, AuArray<AuUInt8, 16> &md5);
AUKN_SYM void SHA1(const Memory::MemoryViewRead &span, AuArray<AuUInt8, 20> &sha1);
AUKN_SYM void Tiger(const Memory::MemoryViewRead &span, AuArray<AuUInt8, 24> &tiger);
AUKN_SYM void SHA2(const Memory::MemoryViewRead &span, AuArray<AuUInt8, 32> &sha2);
AUKN_SYM void SHA2_64(const Memory::MemoryViewRead &span, AuArray<AuUInt8, 64> &sha2);
}