[*] Refactoring in progress...
This commit is contained in:
parent
673872f632
commit
898c0ced37
@ -11,19 +11,19 @@ namespace Aurora::RNG
|
||||
{
|
||||
struct IRandomDevice
|
||||
{
|
||||
virtual void Read(void *in, AuUInt32 length) = 0;
|
||||
virtual void Read(void *pIn, AuUInt32 uLength) = 0;
|
||||
|
||||
virtual AuString NextString(AuUInt32 length, ERngStringCharacters type = ERngStringCharacters::eAlphaCharacters) = 0;
|
||||
virtual void NextString(char *string, AuUInt32 length, ERngStringCharacters type = ERngStringCharacters::eAlphaCharacters) = 0;
|
||||
virtual AuString NextString(AuUInt32 uLength, ERngStringCharacters type = ERngStringCharacters::eAlphaCharacters) = 0;
|
||||
virtual void NextString(char *pString, AuUInt32 uLength, ERngStringCharacters type = ERngStringCharacters::eAlphaCharacters) = 0;
|
||||
virtual AuUInt8 NextByte() = 0;
|
||||
virtual bool NextBoolean() = 0;
|
||||
virtual AuUInt32 NextU32() = 0;
|
||||
virtual AuUInt32 NextU32(AuUInt32 min, AuUInt32 max) = 0;
|
||||
virtual AuUInt32 NextU32(AuUInt32 uMin, AuUInt32 uMax) = 0;
|
||||
virtual AuUInt64 NextU64() = 0;
|
||||
virtual AuInt32 NextInt(AuInt32 min, AuInt32 max) = 0;
|
||||
virtual AuInt32 NextInt(AuInt32 uMin, AuInt32 uMax) = 0;
|
||||
virtual double NextDecimal() = 0;
|
||||
virtual float NextNumber(float min, float max) = 0;
|
||||
virtual AuUInt32 NextIndex(AuUInt32 count /* = max + 1*/) = 0;
|
||||
virtual AuUInt32 NextIndex(AuUInt32 uCount /* = max + 1*/) = 0;
|
||||
|
||||
template<typename T, int N>
|
||||
inline void NextFillArray(T(&array)[N])
|
||||
|
@ -10,28 +10,28 @@
|
||||
#include <AuroraRuntime.hpp>
|
||||
#include "RuntimeInternal.hpp"
|
||||
#include "AuCrypto.hpp"
|
||||
#include "Processes/Processes.hpp"
|
||||
#include "RNG/RNG.hpp"
|
||||
#include "Processes/AuProcesses.hpp"
|
||||
#include "RNG/AuRNG.hpp"
|
||||
#include "Locale/Locale.hpp"
|
||||
#include "Console/Console.hpp"
|
||||
#include "IO/FS/FS.hpp"
|
||||
#include "IO/IO.hpp"
|
||||
#include "IO/Net/Net.hpp"
|
||||
#include "Hashing/Hashing.hpp"
|
||||
#include "Hashing/AuHashing.hpp"
|
||||
#include "Debug/Debug.hpp"
|
||||
#include "Async/Async.hpp"
|
||||
#include "HWInfo/HWInfo.hpp"
|
||||
#include "HWInfo/AuHWInfo.hpp"
|
||||
#include "Telemetry/Telemetry.hpp"
|
||||
#include "Threading/Threads/OSThread.hpp"
|
||||
#include "SWInfo/SWInfo.hpp"
|
||||
#include "Threading/Threads/AuOSThread.hpp"
|
||||
#include "SWInfo/AuSWInfo.hpp"
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
#include "Extensions/Win32/DarkTheme.hpp"
|
||||
#endif
|
||||
#include "Process/Process.hpp"
|
||||
#include "Exit/Exit.hpp"
|
||||
#include "Exit/AuExit.hpp"
|
||||
#include "CmdLine/CmdLine.hpp"
|
||||
#include "Grug/Grug.hpp"
|
||||
#include "Threading/Sleep.hpp"
|
||||
#include "Grug/AuGrug.hpp"
|
||||
#include "Threading/AuSleep.hpp"
|
||||
|
||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||
void LinuxSuperSecretIOTick();
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
#include "Debug.hpp"
|
||||
#include <Source/Telemetry/Telemetry.hpp>
|
||||
#include <Source/Grug/Grug.hpp>
|
||||
#include <Source/Exit/Exit.hpp>
|
||||
#include <Source/Grug/AuGrug.hpp>
|
||||
#include <Source/Exit/AuExit.hpp>
|
||||
|
||||
namespace Aurora::Debug
|
||||
{
|
||||
|
@ -24,8 +24,8 @@
|
||||
#include <Source/Process/ProcessMap.hpp>
|
||||
#include <Source/IO/FS/FS.hpp>
|
||||
|
||||
#include <Source/Grug/Grug.hpp>
|
||||
#include <Source/Exit/Exit.hpp>
|
||||
#include <Source/Grug/AuGrug.hpp>
|
||||
#include <Source/Exit/AuExit.hpp>
|
||||
|
||||
#include <WerApi.h>
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "Debug.hpp"
|
||||
#include "Panic.hpp"
|
||||
//#include <intrin.h>
|
||||
#include <Source/Grug/Grug.hpp>
|
||||
#include <Source/Grug/AuGrug.hpp>
|
||||
|
||||
namespace Aurora::Debug
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
File: Exit.Unix.cpp
|
||||
File: AuExit.Unix.cpp
|
||||
Date: 2022-4-7
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Exit.hpp"
|
||||
#include "Exit.Unix.hpp"
|
||||
#include "AuExit.hpp"
|
||||
#include "AuExit.Unix.hpp"
|
||||
#include <Source/Grug/Grug.hpp>
|
||||
|
||||
namespace Aurora::Exit
|
@ -1,6 +1,6 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
File: Exit.Unix.hpp
|
||||
File: AuExit.Unix.hpp
|
||||
Date: 2022-4-7
|
||||
Author: Reece
|
||||
***/
|
@ -1,17 +1,17 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Exit.cpp
|
||||
File: AuExit.cpp
|
||||
Date: 2022-2-5
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Exit.hpp"
|
||||
#include <Source/Grug/Grug.hpp>
|
||||
#include "MTWatchDog.hpp"
|
||||
#include "AuExit.hpp"
|
||||
#include <Source/Grug/AuGrug.hpp>
|
||||
#include "AuMTWatchDog.hpp"
|
||||
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
#include "Exit.Unix.hpp"
|
||||
#include "AuExit.Unix.hpp"
|
||||
#endif
|
||||
|
||||
namespace Aurora::Exit
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Exit.hpp
|
||||
File: AuExit.hpp
|
||||
Date: 2022-2-5
|
||||
Author: Reece
|
||||
***/
|
@ -1,19 +1,18 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: MTWatchDog.cpp
|
||||
File: AuMTWatchDog.cpp
|
||||
Date: 2022-2-3
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Exit/Exit.hpp"
|
||||
#include "MTWatchDog.hpp"
|
||||
#include "AuExit.hpp"
|
||||
#include "AuMTWatchDog.hpp"
|
||||
|
||||
namespace Aurora::Exit
|
||||
{
|
||||
class MTWatchDog : public AuThreads::IThreadFeature
|
||||
struct MTWatchDog : AuThreads::IThreadFeature
|
||||
{
|
||||
public:
|
||||
void Init() override;
|
||||
// OSThread tls clears should call us first.
|
||||
// if the main thread has valid tls, grug will be informed (sanz type beat, informing hairy beasts)
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: MTWatchDog.hpp
|
||||
File: AuMTWatchDog.hpp
|
||||
Date: 2022-2-3
|
||||
Author: Reece
|
||||
***/
|
@ -1,15 +1,15 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Arrow.cpp
|
||||
File: AuArrow.cpp
|
||||
Date: 2022-02-03
|
||||
Author: Reece
|
||||
Note: NIX signal aware telemetry IPC to cave grug
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Grug.hpp"
|
||||
#include "Arrow.hpp"
|
||||
#include <Source/Exit/Exit.hpp>
|
||||
#include "AuGrug.hpp"
|
||||
#include "AuArrow.hpp"
|
||||
#include <Source/Exit/AuExit.hpp>
|
||||
|
||||
namespace Aurora::Grug
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Arrow.hpp
|
||||
File: AuArrow.hpp
|
||||
Date: 2022-02-03
|
||||
Author: Reece
|
||||
***/
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Grug.cpp
|
||||
File: AuGrug.cpp
|
||||
Date: 2022-01-03
|
||||
File: Flusher.cpp
|
||||
Date: 2021-8-27
|
||||
@ -11,7 +11,7 @@
|
||||
when urgent telemetry events are raised.
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Grug.hpp"
|
||||
#include "AuGrug.hpp"
|
||||
|
||||
#include <Source/Logging/Logger.hpp>
|
||||
#include <Source/Console/ConsoleFIO/ConsoleFIO.hpp>
|
@ -1,14 +1,14 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Grug.hpp
|
||||
File: AuGrug.hpp
|
||||
Date: 2022-02-03
|
||||
Author: Reece
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
#include "GrugThread.hpp"
|
||||
#include "Arrow.hpp"
|
||||
#include "AuGrugThread.hpp"
|
||||
#include "AuArrow.hpp"
|
||||
|
||||
namespace Aurora::Grug
|
||||
{
|
@ -1,22 +1,22 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: GrugThread.cpp
|
||||
File: AuGrugThread.cpp
|
||||
Date: 2022-02-03
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Grug.hpp"
|
||||
#include "GrugThread.hpp"
|
||||
#include "AuGrug.hpp"
|
||||
#include "AuGrugThread.hpp"
|
||||
|
||||
#include <Source/Threading/Threads/ThreadHandles.hpp>
|
||||
#include <Source/Threading/Threads/AuThreadHandles.hpp>
|
||||
|
||||
namespace Aurora::Grug
|
||||
{
|
||||
GrugThread::GrugThread()
|
||||
{
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
nt.pThread = AuThreads::GetThread(); // not thread async safe, but we arent in posix land
|
||||
nt.pThread = AuThreads::GetThread(); // not signal safe, but we arent in posix land
|
||||
#endif
|
||||
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: GrugThread.hpp
|
||||
File: AuGrugThread.hpp
|
||||
Date: 2022-02-03
|
||||
Author: Reece
|
||||
***/
|
@ -1,19 +1,19 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: CpuId.cpp
|
||||
File: AuCpuId.cpp
|
||||
Date: 2022-1-25
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "HWInfo.hpp"
|
||||
#include "CpuId.hpp"
|
||||
#include "AuHWInfo.hpp"
|
||||
#include "AuCpuId.hpp"
|
||||
|
||||
#if defined(AURORA_COMPILER_CLANG) || defined(AURORA_IS_POSIX_DERIVED)
|
||||
#include <cpuid.h>
|
||||
#endif
|
||||
|
||||
#include "CpuInfo.hpp"
|
||||
#include "AuCpuInfo.hpp"
|
||||
|
||||
namespace Aurora::HWInfo
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: CpuId.hpp
|
||||
File: AuCpuId.hpp
|
||||
Date: 2022-1-25
|
||||
Author: Reece
|
||||
***/
|
@ -1,14 +1,14 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: CpuId.Linux.cpp
|
||||
File: AuCpuId.Linux.cpp
|
||||
Date: 2022-1-25
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "HWInfo.hpp"
|
||||
#include "CpuInfo.hpp"
|
||||
#include "CpuInfo.Linux.hpp"
|
||||
#include "AuHWInfo.hpp"
|
||||
#include "AuCpuInfo.hpp"
|
||||
#include "AuCpuInfo.Linux.hpp"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <sys/types.h>
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: CpuId.Linux.hpp
|
||||
File: AuAuCpuId.Linux.hpp
|
||||
Date: 2022-1-25
|
||||
Author: Reece
|
||||
***/
|
@ -1,14 +1,14 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: CpuId.Nt.cpp
|
||||
File: AuCpuId.Nt.cpp
|
||||
Date: 2022-1-25
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "HWInfo.hpp"
|
||||
#include "CpuInfo.hpp"
|
||||
#include "CpuInfo.NT.hpp"
|
||||
#include "AuHWInfo.hpp"
|
||||
#include "AuCpuInfo.hpp"
|
||||
#include "AuCpuInfo.NT.hpp"
|
||||
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
#include <VersionHelpers.h>
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: CpuId.Nt.hpp
|
||||
File: AuCpuId.NT.hpp
|
||||
Date: 2022-1-25
|
||||
Author: Reece
|
||||
***/
|
@ -1,14 +1,14 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: CpuInfo.cpp
|
||||
File: AuCpuInfo.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "HWInfo.hpp"
|
||||
#include "CpuInfo.hpp"
|
||||
#include "CpuId.hpp"
|
||||
#include "AuHWInfo.hpp"
|
||||
#include "AuCpuInfo.hpp"
|
||||
#include "AuCpuId.hpp"
|
||||
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
#include <stdlib.h>
|
||||
@ -16,15 +16,15 @@
|
||||
#endif
|
||||
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
#include "CpuInfo.NT.hpp"
|
||||
#include "AuCpuInfo.NT.hpp"
|
||||
#endif
|
||||
|
||||
#if defined(AURORA_IS_BSD_DERIVED)
|
||||
#include "CpuInfo.BSD.hpp"
|
||||
#include "AuCpuInfo.BSD.hpp"
|
||||
#endif
|
||||
|
||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||
#include "CpuInfo.Linux.hpp"
|
||||
#include "AuCpuInfo.Linux.hpp"
|
||||
#endif
|
||||
|
||||
namespace Aurora::HWInfo
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: CpuInfo.hpp
|
||||
File: AuCpuInfo.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
@ -1,14 +1,14 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: HWInfo.hpp
|
||||
File: AuHWInfo.hpp
|
||||
Date: 2021-6-19
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "HWInfo.hpp"
|
||||
#include "CpuInfo.hpp"
|
||||
#include "RamInfo.hpp"
|
||||
#include "AuHWInfo.hpp"
|
||||
#include "AuCpuInfo.hpp"
|
||||
#include "AuRamInfo.hpp"
|
||||
|
||||
#if defined(AURORA_IS_BSD_DERIVED)
|
||||
#include <sys/types.h>
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: HWInfo.hpp
|
||||
File: AuHWInfo.hpp
|
||||
Date: 2021-6-19
|
||||
Author: Reece
|
||||
***/
|
@ -1,14 +1,13 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RamInfo.cpp
|
||||
File: AuRamInfo.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "HWInfo.hpp"
|
||||
#include "RamInfo.hpp"
|
||||
|
||||
#include "AuHWInfo.hpp"
|
||||
#include "AuRamInfo.hpp"
|
||||
|
||||
#if defined(AURORA_IS_BSD_DERIVED)
|
||||
#include <sys/sysctl.h>
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RamInfo.hpp
|
||||
File: AuRamInfo.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
@ -1,12 +1,12 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Digests.cpp
|
||||
File: AuDigests.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Digests.hpp"
|
||||
#include "AuDigests.hpp"
|
||||
#include <tomcrypt.h>
|
||||
|
||||
namespace Aurora::Hashing
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Open.Unix.hpp
|
||||
File: AuDigests.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
@ -1,13 +1,13 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: HashStream.cpp
|
||||
File: AuHashStream.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include <tomcrypt.h>
|
||||
#include "HashStream.hpp"
|
||||
#include "AuHashStream.hpp"
|
||||
|
||||
namespace Aurora::Hashing
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: HashStream.hpp
|
||||
File: AuHashStream.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
@ -1,12 +1,12 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Hashing.cpp
|
||||
File: AuHashing.cpp
|
||||
Date: 2021-6-17
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Hashing.hpp"
|
||||
#include "AuHashing.hpp"
|
||||
|
||||
namespace Aurora::Hashing
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Hashing.hpp
|
||||
File: AuHashing.hpp
|
||||
Date: 2021-6-17
|
||||
Author: Reece
|
||||
***/
|
@ -7,7 +7,7 @@
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Logger.hpp"
|
||||
#include <Source/Grug/Grug.hpp>
|
||||
#include <Source/Grug/AuGrug.hpp>
|
||||
#include <Source/Console/Hooks/Hooks.hpp>
|
||||
|
||||
namespace Aurora::Logging
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Memory.hpp"
|
||||
#include "Cache.hpp"
|
||||
#include <Source/HWInfo/HWInfo.hpp>
|
||||
#include <Source/HWInfo/AuHWInfo.hpp>
|
||||
|
||||
#define LINUX_SUPPORTS_CACHE_CTL 0
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Memory.hpp"
|
||||
#include <mimalloc.h>
|
||||
#include <Source/HWInfo/HWInfo.hpp>
|
||||
#include <Source/HWInfo/AuHWInfo.hpp>
|
||||
|
||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||
#include <sys/mman.h>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Memory.hpp"
|
||||
#include "SwapLock.hpp"
|
||||
#include <Source/HWInfo/HWInfo.hpp>
|
||||
#include <Source/HWInfo/AuHWInfo.hpp>
|
||||
|
||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||
#include <sys/mman.h>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Memory.hpp"
|
||||
#include "SwapLock.hpp"
|
||||
#include <Source/HWInfo/HWInfo.hpp>
|
||||
#include <Source/HWInfo/AuHWInfo.hpp>
|
||||
|
||||
namespace Aurora::Memory::Transition
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Base32.cpp
|
||||
File: AuBase32.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Base32.hpp"
|
||||
#include "AuBase32.hpp"
|
||||
#include <tomcrypt.h>
|
||||
|
||||
namespace Aurora::Parse
|
||||
@ -14,9 +14,9 @@ namespace Aurora::Parse
|
||||
AUKN_SYM bool Base32Decode(const AuString &in, AuByteBuffer &decoded)
|
||||
{
|
||||
int iRet;
|
||||
unsigned long length = in.size();
|
||||
unsigned long uLength = in.size();
|
||||
|
||||
auto writeView = decoded.GetOrAllocateLinearWriteable(length);
|
||||
auto writeView = decoded.GetOrAllocateLinearWriteable(uLength);
|
||||
if (!writeView)
|
||||
{
|
||||
SysPushErrorMem();
|
||||
@ -24,24 +24,24 @@ namespace Aurora::Parse
|
||||
}
|
||||
|
||||
iRet = ::base32_decode(AuReinterpretCast<const char *>(decoded.writePtr),
|
||||
(unsigned long)length,
|
||||
(unsigned long)uLength,
|
||||
AuReinterpretCast<unsigned char *>(&decoded[0]),
|
||||
&length,
|
||||
&uLength,
|
||||
BASE32_RFC4648);
|
||||
if (iRet != CRYPT_OK)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
decoded.writePtr += length;
|
||||
decoded.writePtr += uLength;
|
||||
return true;
|
||||
}
|
||||
|
||||
AUKN_SYM bool Base32Encode(const Memory::MemoryViewRead &input, AuString &encoded)
|
||||
{
|
||||
unsigned long outLength = ((input.length * 8 + 4) / 5) + 5;
|
||||
unsigned long uOutLength = ((input.length * 8 + 4) / 5) + 5;
|
||||
|
||||
if (!AuTryResize(encoded, outLength))
|
||||
if (!AuTryResize(encoded, uOutLength))
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
||||
@ -50,10 +50,10 @@ namespace Aurora::Parse
|
||||
auto iRet = ::base32_encode(AuReinterpretCast<const unsigned char *>(input.ptr),
|
||||
(unsigned long)input.length,
|
||||
&encoded[0],
|
||||
&outLength,
|
||||
&uOutLength,
|
||||
BASE32_RFC4648);
|
||||
|
||||
if (!AuTryResize(encoded, outLength))
|
||||
if (!AuTryResize(encoded, uOutLength))
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Parser.hpp
|
||||
File: AuBase32.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
@ -1,41 +1,41 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Base64.cpp
|
||||
File: AuBase64.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Base64.hpp"
|
||||
#include "AuBase64.hpp"
|
||||
#include <tomcrypt.h>
|
||||
|
||||
namespace Aurora::Parse
|
||||
{
|
||||
AUKN_SYM bool Base64Decode(const AuString &in, AuByteBuffer &decoded, bool url)
|
||||
AUKN_SYM bool Base64Decode(const AuString &in, AuByteBuffer &decoded, bool bUrl)
|
||||
{
|
||||
int iRet;
|
||||
unsigned long length = (unsigned long)in.size();
|
||||
unsigned long uLength = (unsigned long)in.size();
|
||||
|
||||
auto writeView = decoded.GetOrAllocateLinearWriteable(length);
|
||||
auto writeView = decoded.GetOrAllocateLinearWriteable(uLength);
|
||||
if (!writeView)
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return {};
|
||||
}
|
||||
|
||||
if (url)
|
||||
if (bUrl)
|
||||
{
|
||||
iRet = ::base64url_decode(AuReinterpretCast<const char *>(decoded.writePtr),
|
||||
(unsigned long)length,
|
||||
(unsigned long)uLength,
|
||||
AuReinterpretCast<unsigned char *>(&decoded[0]),
|
||||
&length);
|
||||
&uLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
iRet = ::base64_decode(AuReinterpretCast<const char *>(decoded.writePtr),
|
||||
(unsigned long)length,
|
||||
(unsigned long)uLength,
|
||||
AuReinterpretCast<unsigned char *>(&decoded[0]),
|
||||
&length);
|
||||
&uLength);
|
||||
}
|
||||
|
||||
if (iRet != CRYPT_OK)
|
||||
@ -43,37 +43,37 @@ namespace Aurora::Parse
|
||||
return false;
|
||||
}
|
||||
|
||||
decoded.writePtr += length;
|
||||
decoded.writePtr += uLength;
|
||||
return true;
|
||||
}
|
||||
|
||||
AUKN_SYM bool Base64Encode(const Memory::MemoryViewRead &input, AuString &encoded, bool url)
|
||||
AUKN_SYM bool Base64Encode(const Memory::MemoryViewRead &input, AuString &encoded, bool bUrl)
|
||||
{
|
||||
int iRet;
|
||||
unsigned long outLength = input.length + (input.length / 3.0) + 16;
|
||||
unsigned long uOutLength = input.length + (input.length / 3.0) + 16;
|
||||
|
||||
if (!AuTryResize(encoded, outLength))
|
||||
if (!AuTryResize(encoded, uOutLength))
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
||||
}
|
||||
|
||||
if (url)
|
||||
if (bUrl)
|
||||
{
|
||||
iRet = ::base64url_encode(AuReinterpretCast<const unsigned char*>(input.ptr),
|
||||
(unsigned long)input.length,
|
||||
&encoded[0],
|
||||
&outLength);
|
||||
&uOutLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
iRet = ::base64_encode(AuReinterpretCast<const unsigned char*>(input.ptr),
|
||||
(unsigned long)input.length,
|
||||
&encoded[0],
|
||||
&outLength);
|
||||
&uOutLength);
|
||||
}
|
||||
|
||||
if (!AuTryResize(encoded, outLength))
|
||||
if (!AuTryResize(encoded, uOutLength))
|
||||
{
|
||||
SysPushErrorMem();
|
||||
return false;
|
@ -1,12 +1,12 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Hex.cpp
|
||||
File: AuHex.cpp
|
||||
Date: 2021-8-28
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Hex.hpp"
|
||||
#include "AuHex.hpp"
|
||||
|
||||
namespace Aurora::Parse
|
||||
{
|
||||
@ -41,14 +41,19 @@ namespace Aurora::Parse
|
||||
return true;
|
||||
}
|
||||
|
||||
AUKN_SYM bool HexToInt(const char *hex, AuUInt32 length, AuUInt64 &val)
|
||||
AUKN_SYM bool HexToInt(const char *pHex, AuUInt32 uLength, AuUInt64 &val)
|
||||
{
|
||||
val = 0;
|
||||
length = AuMin(AuUInt32(sizeof(AuUInt64) * 2), length);
|
||||
uLength = AuMin(AuUInt32(sizeof(AuUInt64) * 2), uLength);
|
||||
|
||||
for (auto i = 0u; i < length; i++)
|
||||
if (!pHex && uLength)
|
||||
{
|
||||
AuUInt8 byte = *hex++;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto i = 0u; i < uLength; i++)
|
||||
{
|
||||
AuUInt8 byte = *pHex++;
|
||||
|
||||
if (byte >= '0' && byte <= '9')
|
||||
{
|
||||
@ -198,7 +203,7 @@ namespace Aurora::Parse
|
||||
return true;
|
||||
}
|
||||
|
||||
AUKN_SYM bool EncodeHex(const void *pBuf, AuUInt32 length, EHexDump formatting, AuString &in)
|
||||
AUKN_SYM bool EncodeHex(const void *pBuf, AuUInt32 uLength, EHexDump formatting, AuString &in)
|
||||
{
|
||||
bool hexedit = formatting == EHexDump::eHexEditor;
|
||||
|
||||
@ -211,10 +216,15 @@ namespace Aurora::Parse
|
||||
|
||||
bool space = formatting != EHexDump::eString;
|
||||
|
||||
if (!pBuf && uLength)
|
||||
{
|
||||
SysPushErrorArg();
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
in.reserve(length * 4);
|
||||
AuTryReserve(in, uLength * 4);
|
||||
|
||||
auto &newLine = AuLocale::NewLine();
|
||||
|
||||
@ -238,7 +248,7 @@ namespace Aurora::Parse
|
||||
in.insert(in.size(), newLine);
|
||||
}
|
||||
|
||||
for (auto i = 0u; i < length; )
|
||||
for (auto i = 0u; i < uLength; )
|
||||
{
|
||||
AuUInt32 x, rowMax;
|
||||
|
||||
@ -255,7 +265,7 @@ namespace Aurora::Parse
|
||||
in.insert(in.size(), " ");
|
||||
}
|
||||
|
||||
rowMax = AuMin(AuUInt32(i + 16), AuUInt32(length));
|
||||
rowMax = AuMin(AuUInt32(i + 16), AuUInt32(uLength));
|
||||
|
||||
for (x = i;
|
||||
x < rowMax;
|
||||
@ -280,7 +290,7 @@ namespace Aurora::Parse
|
||||
in.insert(in.size(), hex, 2);
|
||||
}
|
||||
|
||||
if (x != (length - 1))
|
||||
if (x != (uLength - 1))
|
||||
{
|
||||
if (squareBracket || curlyBracket)
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Parser.cpp
|
||||
File: AuParser.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
Note: Horrible gen 1 parser.
|
||||
@ -9,7 +9,7 @@
|
||||
Just build around what works, could probably wrangle a command list parser on top.
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Parser.hpp"
|
||||
#include "AuParser.hpp"
|
||||
|
||||
namespace Aurora::Parse
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Base32.hpp
|
||||
File: AuParser.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
@ -9,7 +9,7 @@
|
||||
*
|
||||
*/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "ArgvQuote.hpp"
|
||||
#include "AuArgvQuote.hpp"
|
||||
|
||||
void
|
||||
ArgvQuote(
|
@ -1,13 +1,13 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Open.Unix.cpp
|
||||
File: AuOpen.Unix.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <RuntimeInternal.hpp>
|
||||
#include "Processes.hpp"
|
||||
#include "Open.Unix.hpp"
|
||||
#include "AuProcesses.hpp"
|
||||
#include "AuOpen.Unix.hpp"
|
||||
|
||||
#include <unistd.h>
|
||||
#include <Source/IO/FS/FS.hpp>
|
@ -1,8 +1,9 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: ConditionEx.hpp
|
||||
File: AuOpen.Unix.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#pragma once
|
||||
|
@ -1,13 +1,13 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Open.Win32.cpp
|
||||
File: AuOpen.Win32.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Processes.hpp"
|
||||
#include "Open.Win32.hpp"
|
||||
#include "AuProcesses.hpp"
|
||||
#include "AuOpen.Win32.hpp"
|
||||
|
||||
#include <shellapi.h>
|
||||
#include <tlhelp32.h>
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Open.Win32.hpp
|
||||
File: AuOpen.Win32.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
@ -1,26 +1,26 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Process.NT.cpp
|
||||
File: AuProcess.NT.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Process.NT.hpp"
|
||||
#include "Processes.hpp"
|
||||
#include "AuProcess.NT.hpp"
|
||||
#include "AuProcesses.hpp"
|
||||
#include <process.h>
|
||||
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
#include "Process.Win32.hpp"
|
||||
#include "AuProcess.Win32.hpp"
|
||||
#endif
|
||||
|
||||
#include "ArgvQuote.hpp"
|
||||
#include "AuArgvQuote.hpp"
|
||||
|
||||
#include <Source/IO/FS/FS.hpp>
|
||||
#include <Source/IO/FS/Async.NT.hpp>
|
||||
#include <Source/IO/Loop/LSHandle.hpp>
|
||||
|
||||
#include "CreatePipeEx.NT.hpp"
|
||||
#include "AuCreatePipeEx.NT.hpp"
|
||||
|
||||
namespace Aurora::Processes
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Process.NT.hpp
|
||||
File: AuProcess.NT.hpp
|
||||
Date: 2022-1-29
|
||||
Author: Reece
|
||||
***/
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Process.Unix.hpp
|
||||
File: AuProcess.Unix.hpp
|
||||
File: Process.Linux.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
@ -1,12 +1,12 @@
|
||||
/***
|
||||
Copyright (C) 2021-2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Process.Win32.cpp
|
||||
File: AuProcess.Win32.cpp
|
||||
Date: 2022-1-29
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Process.Win32.hpp"
|
||||
#include "AuProcess.Win32.hpp"
|
||||
#include <shellapi.h>
|
||||
#include <tlhelp32.h>
|
||||
#include <process.h>
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Process.Win32.hpp
|
||||
File: AuProcess.Win32.hpp
|
||||
Date: 2022-1-29
|
||||
Author: Reece
|
||||
***/
|
@ -1,16 +1,16 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Processes.cpp
|
||||
File: AuProcesses.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Processes.hpp"
|
||||
#include "AuProcesses.hpp"
|
||||
|
||||
#if defined (AURORA_PLATFORM_WIN32)
|
||||
#include "Process.Win32.hpp"
|
||||
#include "Open.Win32.hpp"
|
||||
#include "AuProcess.Win32.hpp"
|
||||
#include "AuOpen.Win32.hpp"
|
||||
#endif
|
||||
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Processes.hpp
|
||||
File: AuProcesses.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
@ -1,14 +0,0 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: UtilRun.cpp
|
||||
Date:
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "UtilRun.hpp"
|
||||
|
||||
namespace Aurora::Processes
|
||||
{
|
||||
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: UtilRun.hpp
|
||||
Date:
|
||||
Author: Reece
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
namespace Aurora::Processes
|
||||
{
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
* http://www.sultanik.com/Mersenne_twister
|
||||
*/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "mtwister.hpp"
|
||||
#include "AuMTwister.hpp"
|
||||
|
||||
#define UPPER_MASK 0x80000000
|
||||
#define LOWER_MASK 0x7fffffff
|
@ -1,40 +1,44 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RNG.cpp
|
||||
File: AuRNG.cpp
|
||||
Date: 2021-6-11
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "RNG.hpp"
|
||||
#include "RNGEntropy.hpp"
|
||||
#include "WELL.hpp"
|
||||
#include "AuRNG.hpp"
|
||||
#include "AuRNGEntropy.hpp"
|
||||
#include "AuWELL.hpp"
|
||||
|
||||
namespace Aurora::RNG
|
||||
{
|
||||
static WELLRand gWellRand;
|
||||
RandomUnique_t gFastDevice;
|
||||
|
||||
AUKN_SYM void ReadSecureRNG(void *in, AuUInt32 length)
|
||||
AUKN_SYM void ReadSecureRNG(void *pBuffer, AuUInt32 uBytes)
|
||||
{
|
||||
AuUInt32 offset;
|
||||
AuUInt8 *headPtr;
|
||||
|
||||
headPtr = reinterpret_cast<AuUInt8 *>(in);
|
||||
SysAssert(pBuffer, "Null RNG out buffer");
|
||||
|
||||
headPtr = reinterpret_cast<AuUInt8 *>(pBuffer);
|
||||
offset = 0;
|
||||
|
||||
while (offset != length)
|
||||
while (offset != uBytes)
|
||||
{
|
||||
auto req = length - offset;
|
||||
auto req = uBytes - offset;
|
||||
auto bytes = RngGetBytes(headPtr + offset, req);
|
||||
SysAssertExp(bytes, "Couldn't consume {} RNG bytes", req);
|
||||
offset += bytes;
|
||||
}
|
||||
}
|
||||
|
||||
AUKN_SYM void ReadFastRNG(void *in, AuUInt32 length)
|
||||
AUKN_SYM void ReadFastRNG(void *pBuffer, AuUInt32 uBytes)
|
||||
{
|
||||
WELL_NextBytes(&gWellRand, in, length);
|
||||
SysAssert(pBuffer, "Null RNG out buffer");
|
||||
|
||||
WELL_NextBytes(&gWellRand, pBuffer, uBytes);
|
||||
}
|
||||
|
||||
static void InitFastRng()
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RNG.hpp
|
||||
File: AURNG.hpp
|
||||
Date: 2021-6-11
|
||||
Author: Reece
|
||||
***/
|
@ -1,15 +1,15 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RNGEntropy.cpp
|
||||
File: AuRNGEntropy.cpp
|
||||
Date: 2022-9-17
|
||||
File: RNG.cpp
|
||||
Date: 2021-6-11
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "RNG.hpp"
|
||||
#include "RNGEntropy.hpp"
|
||||
#include "AuRNG.hpp"
|
||||
#include "AuRNGEntropy.hpp"
|
||||
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
#include <wincrypt.h>
|
||||
@ -21,7 +21,7 @@
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
#include "WELL.hpp"
|
||||
#include "AuWELL.hpp"
|
||||
|
||||
namespace Aurora::RNG
|
||||
{
|
||||
@ -42,14 +42,14 @@ namespace Aurora::RNG
|
||||
}
|
||||
}
|
||||
|
||||
static AuUInt32 RngUnix(AuUInt8 *buf, AuUInt32 len)
|
||||
static AuUInt32 RngUnix(AuUInt8 *pBuf, AuUInt32 uLen)
|
||||
{
|
||||
if (gDevURand == -1)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return ::read(gDevURand, buf, len);
|
||||
return ::read(gDevURand, pBuf, uLen);
|
||||
}
|
||||
|
||||
#elif defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
@ -73,7 +73,7 @@ namespace Aurora::RNG
|
||||
#endif
|
||||
}
|
||||
|
||||
static AuUInt32 RngWin32(AuUInt8 *buf, AuUInt32 len)
|
||||
static AuUInt32 RngWin32(AuUInt8 *pBuf, AuUInt32 uLen)
|
||||
{
|
||||
#if defined(USE_OLD_NTCRYPT)
|
||||
if (!gCryptoProv)
|
||||
@ -81,24 +81,24 @@ namespace Aurora::RNG
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!::CryptGenRandom(gCryptoProv, len, buf))
|
||||
if (!::CryptGenRandom(gCryptoProv, uLen, pBuf))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return len;
|
||||
return uLen;
|
||||
#else
|
||||
|
||||
#if !defined(AURORA_DONT_PREFER_WIN32_USERLAND_AES_RNG)
|
||||
if (::BCryptGenRandom(BCRYPT_RNG_ALG_HANDLE, reinterpret_cast<PUCHAR>(buf), len, 0) == 0)
|
||||
if (::BCryptGenRandom(BCRYPT_RNG_ALG_HANDLE, reinterpret_cast<PUCHAR>(pBuf), uLen, 0) == 0)
|
||||
{
|
||||
return len;
|
||||
return uLen;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (::BCryptGenRandom(NULL, reinterpret_cast<PUCHAR>(buf), len, BCRYPT_USE_SYSTEM_PREFERRED_RNG) == 0)
|
||||
if (::BCryptGenRandom(NULL, reinterpret_cast<PUCHAR>(pBuf), uLen, BCRYPT_USE_SYSTEM_PREFERRED_RNG) == 0)
|
||||
{
|
||||
return len;
|
||||
return uLen;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -114,16 +114,16 @@ namespace Aurora::RNG
|
||||
|
||||
#endif
|
||||
|
||||
static AuUInt32 RngStdC(AuUInt8 *buf, AuUInt32 len)
|
||||
static AuUInt32 RngStdC(AuUInt8 *pBuf, AuUInt32 uLen)
|
||||
{
|
||||
clock_t t1;
|
||||
int l, acc, bits, a, b;
|
||||
|
||||
l = len;
|
||||
l = uLen;
|
||||
acc = a = b = 0;
|
||||
bits = 8;
|
||||
|
||||
while (len--)
|
||||
while (uLen--)
|
||||
{
|
||||
while (bits--) // for each bit in byte
|
||||
{
|
||||
@ -144,7 +144,7 @@ namespace Aurora::RNG
|
||||
acc = (acc << 1) | a; // push the first bit state
|
||||
}
|
||||
|
||||
*buf++ = acc;
|
||||
*pBuf++ = acc;
|
||||
|
||||
acc = 0;
|
||||
bits = 8;
|
||||
@ -153,23 +153,23 @@ namespace Aurora::RNG
|
||||
return l;
|
||||
}
|
||||
|
||||
AuUInt32 RngGetBytes(AuUInt8 *out, AuUInt32 outlen)
|
||||
AuUInt32 RngGetBytes(AuUInt8 *pBuffer, AuUInt32 uBytes)
|
||||
{
|
||||
AuUInt32 x;
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
x = RngWin32(out, outlen);
|
||||
x = RngWin32(pBuffer, uBytes);
|
||||
if (x != 0)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
#elif defined(AURORA_IS_POSIX_DERIVED)
|
||||
x = RngUnix(out, outlen);
|
||||
x = RngUnix(out, uBytes);
|
||||
if (x != 0)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
x = RngStdC(out, outlen);
|
||||
x = RngStdC(pBuffer, uBytes);
|
||||
if (x != 0)
|
||||
{
|
||||
return x;
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RNGEntropy.hpp
|
||||
File: AuRNGEntropy.hpp
|
||||
Date: 2022-9-17
|
||||
Author: Reece
|
||||
***/
|
@ -1,26 +1,26 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RNGStaticUtilities.cpp
|
||||
File: AuRNGStaticUtilities.cpp
|
||||
Date: 2022-9-17
|
||||
File: RNG.cpp
|
||||
Date: 2021-6-11
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "RNG.hpp"
|
||||
#include "RNGStaticUtilities.hpp"
|
||||
#include "AuRNG.hpp"
|
||||
#include "AuRNGStaticUtilities.hpp"
|
||||
|
||||
namespace Aurora::RNG
|
||||
{
|
||||
AUKN_SYM AuString ReadString(AuUInt32 length, ERngStringCharacters type)
|
||||
AUKN_SYM AuString ReadString(AuUInt32 dwLength, ERngStringCharacters type)
|
||||
{
|
||||
return gFastDevice->NextString(length, type);
|
||||
return gFastDevice->NextString(dwLength, type);
|
||||
}
|
||||
|
||||
AUKN_SYM void RngString(char *string, AuUInt32 length, ERngStringCharacters type)
|
||||
AUKN_SYM void RngString(char *pString, AuUInt32 dwLength, ERngStringCharacters type)
|
||||
{
|
||||
gFastDevice->NextString(string, length, type);
|
||||
gFastDevice->NextString(pString, dwLength, type);
|
||||
}
|
||||
|
||||
AUKN_SYM AuUInt8 RngByte()
|
||||
@ -38,9 +38,9 @@ namespace Aurora::RNG
|
||||
return gFastDevice->NextU32();
|
||||
}
|
||||
|
||||
AUKN_SYM AuUInt32 RngU32(AuUInt32 min, AuUInt32 max)
|
||||
AUKN_SYM AuUInt32 RngU32(AuUInt32 uMin, AuUInt32 uMax)
|
||||
{
|
||||
return gFastDevice->NextU32(min, max);
|
||||
return gFastDevice->NextU32(uMin, uMax);
|
||||
}
|
||||
|
||||
AUKN_SYM AuUInt64 RngU64()
|
||||
@ -48,9 +48,9 @@ namespace Aurora::RNG
|
||||
return gFastDevice->NextU64();
|
||||
}
|
||||
|
||||
AUKN_SYM AuInt32 RngInt(AuInt32 min, AuInt32 max)
|
||||
AUKN_SYM AuInt32 RngInt(AuInt32 uMin, AuInt32 uMax)
|
||||
{
|
||||
return gFastDevice->NextInt(min, max);
|
||||
return gFastDevice->NextInt(uMin, uMax);
|
||||
}
|
||||
|
||||
AUKN_SYM double RngDecimal()
|
||||
@ -63,8 +63,8 @@ namespace Aurora::RNG
|
||||
return gFastDevice->NextNumber(min, max);
|
||||
}
|
||||
|
||||
AUKN_SYM AuUInt32 RngIndex(AuUInt32 count /* = max + 1*/)
|
||||
AUKN_SYM AuUInt32 RngIndex(AuUInt32 uCount /* = max + 1*/)
|
||||
{
|
||||
return gFastDevice->NextIndex(count);
|
||||
return gFastDevice->NextIndex(uCount);
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RNGStaticUtilities.hpp
|
||||
File: AuRNGStaticUtilities.hpp
|
||||
Date: 2022-9-17
|
||||
Author: Reece
|
||||
***/
|
@ -1,39 +1,15 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RandomDevice.cpp
|
||||
File: AuRandomDevice.cpp
|
||||
Date: 2021-9-3
|
||||
Author: Reece
|
||||
***/
|
||||
#include <AuroraRuntime.hpp>
|
||||
#include <Source/RNG/WELL.hpp>
|
||||
#include "RandomDevice.hpp"
|
||||
#include "AuRandomDevice.hpp"
|
||||
|
||||
namespace Aurora::RNG
|
||||
{
|
||||
struct RandomDevice : IRandomDevice
|
||||
{
|
||||
void Read(void *in, AuUInt32 length) override;
|
||||
|
||||
AuString NextString(AuUInt32 length, ERngStringCharacters type) override;
|
||||
void NextString(char *string, AuUInt32 length, ERngStringCharacters type) override;
|
||||
AuUInt8 NextByte() override;
|
||||
bool NextBoolean() override;
|
||||
AuUInt32 NextU32() override;
|
||||
AuUInt64 NextU64() override;
|
||||
AuInt32 NextInt(AuInt32 min, AuInt32 max) override;
|
||||
AuUInt32 NextU32(AuUInt32 min, AuUInt32 max) override;
|
||||
double NextDecimal() override;
|
||||
float NextNumber(float min, float max) override;
|
||||
AuUInt32 NextIndex(AuUInt32 count /* = max + 1*/) override;
|
||||
|
||||
void Init(const RandomDef &def);
|
||||
|
||||
private:
|
||||
RandomDef def_;
|
||||
WELLRand fast_;
|
||||
};
|
||||
|
||||
void RandomDevice::Init(const RandomDef &def)
|
||||
{
|
||||
this->def_ = def;
|
||||
@ -62,26 +38,32 @@ namespace Aurora::RNG
|
||||
// secure rng requires no init -> we just passthrough to the global ReadSecureRNG function
|
||||
}
|
||||
|
||||
void RandomDevice::Read(void *in, AuUInt32 length)
|
||||
void RandomDevice::Read(void *pIn, AuUInt32 uLength)
|
||||
{
|
||||
if (!pIn)
|
||||
{
|
||||
SysPushErrorArg();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this->def_.bSecure)
|
||||
{
|
||||
ReadSecureRNG(in, length);
|
||||
ReadSecureRNG(pIn, uLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
WELL_NextBytes(&this->fast_, in, length);
|
||||
WELL_NextBytes(&this->fast_, pIn, uLength);
|
||||
}
|
||||
}
|
||||
|
||||
AuString RandomDevice::NextString(AuUInt32 length, ERngStringCharacters type)
|
||||
AuString RandomDevice::NextString(AuUInt32 uLength, ERngStringCharacters type)
|
||||
{
|
||||
AuString ret(length, '\00');
|
||||
AuString ret(uLength, '\00');
|
||||
NextString(ret.data(), AuUInt32(ret.size()), type);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void RandomDevice::NextString(char *string, AuUInt32 length, ERngStringCharacters type)
|
||||
void RandomDevice::NextString(char *pString, AuUInt32 uLength, ERngStringCharacters type)
|
||||
{
|
||||
static AuPair<const char *, int> rngSequence[static_cast<int>(ERngStringCharacters::eEnumCount)] =
|
||||
{
|
||||
@ -93,7 +75,13 @@ namespace Aurora::RNG
|
||||
{"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890=-+!$%^*.[];:", 75}
|
||||
};
|
||||
|
||||
ReadSecureRNG(string, length);
|
||||
if (!pString)
|
||||
{
|
||||
SysPushErrorArg();
|
||||
return;
|
||||
}
|
||||
|
||||
ReadSecureRNG(pString, uLength);
|
||||
|
||||
if (!ERngStringCharactersIsValid(type))
|
||||
{
|
||||
@ -103,9 +91,9 @@ namespace Aurora::RNG
|
||||
|
||||
const auto &pair = rngSequence[static_cast<int>(type)];
|
||||
|
||||
for (auto i = 0u; i < length; i++)
|
||||
for (auto i = 0u; i < uLength; i++)
|
||||
{
|
||||
string[i] = pair.first[reinterpret_cast<const AuUInt8 *>(string)[i] % static_cast<int>(pair.second)];
|
||||
pString[i] = pair.first[reinterpret_cast<const AuUInt8 *>(pString)[i] % static_cast<int>(pair.second)];
|
||||
}
|
||||
}
|
||||
|
||||
@ -129,16 +117,16 @@ namespace Aurora::RNG
|
||||
return NextFillTmpl<AuUInt64>();
|
||||
}
|
||||
|
||||
AuInt32 RandomDevice::NextInt(AuInt32 min, AuInt32 max)
|
||||
AuInt32 RandomDevice::NextInt(AuInt32 uMin, AuInt32 uMax)
|
||||
{
|
||||
auto range = max - min;
|
||||
return (NextU64() % range) + min;
|
||||
auto range = uMax - uMin;
|
||||
return (NextU64() % range) + uMin;
|
||||
}
|
||||
|
||||
AuUInt32 RandomDevice::NextU32(AuUInt32 min, AuUInt32 max)
|
||||
AuUInt32 RandomDevice::NextU32(AuUInt32 uMin, AuUInt32 uMax)
|
||||
{
|
||||
auto range = max - min;
|
||||
return (NextU64() % range) + min;
|
||||
auto range = uMax - uMin;
|
||||
return (NextU64() % range) + uMin;
|
||||
}
|
||||
|
||||
double RandomDevice::NextDecimal()
|
||||
@ -146,9 +134,9 @@ namespace Aurora::RNG
|
||||
return double(NextU32()) * (double(1.0) / double(AuNumericLimits<AuUInt32>::max()));
|
||||
}
|
||||
|
||||
AuUInt32 RandomDevice::NextIndex(AuUInt32 count /* = max + 1*/)
|
||||
AuUInt32 RandomDevice::NextIndex(AuUInt32 uCount /* = max + 1*/)
|
||||
{
|
||||
return NextU32() % count;
|
||||
return NextU32() % uCount;
|
||||
}
|
||||
|
||||
float RandomDevice::NextNumber(float min, float max)
|
36
Source/RNG/AuRandomDevice.hpp
Normal file
36
Source/RNG/AuRandomDevice.hpp
Normal file
@ -0,0 +1,36 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: AuRandomDevice.hpp
|
||||
Date: 2021-9-3
|
||||
Author: Reece
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
#include "AuWELL.hpp"
|
||||
|
||||
namespace Aurora::RNG
|
||||
{
|
||||
struct RandomDevice : IRandomDevice
|
||||
{
|
||||
void Read(void *pIn, AuUInt32 uLength) override;
|
||||
|
||||
AuString NextString(AuUInt32 uLength, ERngStringCharacters type) override;
|
||||
void NextString(char *pString, AuUInt32 uLength, ERngStringCharacters type) override;
|
||||
AuUInt8 NextByte() override;
|
||||
bool NextBoolean() override;
|
||||
AuUInt32 NextU32() override;
|
||||
AuUInt64 NextU64() override;
|
||||
AuInt32 NextInt(AuInt32 uMin, AuInt32 uMax) override;
|
||||
AuUInt32 NextU32(AuUInt32 uMin, AuUInt32 uMax) override;
|
||||
double NextDecimal() override;
|
||||
float NextNumber(float min, float max) override;
|
||||
AuUInt32 NextIndex(AuUInt32 uCount /* = max + 1*/) override;
|
||||
|
||||
void Init(const RandomDef &def);
|
||||
|
||||
private:
|
||||
RandomDef def_;
|
||||
WELLRand fast_;
|
||||
};
|
||||
}
|
@ -6,8 +6,8 @@
|
||||
* http://lomont.org/papers/2008/Lomont_PRNG_2008.pdf
|
||||
*/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "WELL.hpp"
|
||||
#include "mtwister.hpp"
|
||||
#include "AuWELL.hpp"
|
||||
#include "AuMTwister.hpp"
|
||||
|
||||
// WELL should provide us reasonably 'secure' and, more importantly, fast RNG for
|
||||
// general purpose use. It isn't fundamentally broken unlike MT, I dont think 512
|
@ -1,12 +0,0 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: RandomDevice.hpp
|
||||
Date: 2021-9-3
|
||||
Author: Reece
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
namespace Aurora::RNG
|
||||
{
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: SWInfo.Linux.cpp
|
||||
File: AuSWInfo.Linux.cpp
|
||||
Date: 2022-4-6
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "SWInfo.hpp"
|
||||
#include "SWInfo.Linux.hpp"
|
||||
#include "AuSWInfo.hpp"
|
||||
#include "AuSWInfo.Linux.hpp"
|
||||
|
||||
namespace Aurora::SWInfo
|
||||
{
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: SWInfo.Linux.hpp
|
||||
File: AuSWInfo.Linux.hpp
|
||||
Date: 2022-4-6
|
||||
Author: Reece
|
||||
***/
|
@ -1,13 +1,13 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: SWInfo.NT.cpp
|
||||
File: AuSWInfo.NT.cpp
|
||||
Date: 2022-2-1
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "SWInfo.hpp"
|
||||
#include "SWInfo.NT.hpp"
|
||||
#include "AuSWInfo.hpp"
|
||||
#include "AuSWInfo.NT.hpp"
|
||||
|
||||
#if defined(AURORA_PLATFORM_WIN32)
|
||||
#include <VersionHelpers.h>
|
||||
@ -31,11 +31,11 @@ namespace Aurora::SWInfo
|
||||
return !VerifyVersionInfoW(&osvi, VER_SUITENAME, dwlConditionMask);
|
||||
}
|
||||
|
||||
auline bool Win32ReadRegistry(HKEY hKey, const wchar_t *key, AuString &strValue)
|
||||
auline bool Win32ReadRegistry(HKEY hKey, const wchar_t *pWideKey, AuString &strValue)
|
||||
{
|
||||
DWORD dwBufferSize {};
|
||||
|
||||
if (RegQueryValueExW(hKey, key, 0, NULL, NULL, &dwBufferSize) != ERROR_SUCCESS)
|
||||
if (RegQueryValueExW(hKey, pWideKey, 0, NULL, NULL, &dwBufferSize) != ERROR_SUCCESS)
|
||||
{
|
||||
SysPushErrorUnavailableError("Couldn't access registery key");
|
||||
return false;
|
||||
@ -49,7 +49,7 @@ namespace Aurora::SWInfo
|
||||
return false;
|
||||
}
|
||||
|
||||
if (RegQueryValueExW(hKey, key, 0, NULL, reinterpret_cast<LPBYTE>(in.data()), &dwBufferSize) != ERROR_SUCCESS)
|
||||
if (RegQueryValueExW(hKey, pWideKey, 0, NULL, reinterpret_cast<LPBYTE>(in.data()), &dwBufferSize) != ERROR_SUCCESS)
|
||||
{
|
||||
SysPushErrorUnavailableError("Couldn't access registery key");
|
||||
return false;
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: SWInfo.NT.hpp
|
||||
File: AuSWInfo.NT.hpp
|
||||
Date: 2022-2-1
|
||||
Author: Reece
|
||||
***/
|
@ -1,19 +1,19 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: SWInfo.cpp
|
||||
File: AuSWInfo.cpp
|
||||
Date: 2022-1-25
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "SWInfo.hpp"
|
||||
#include "AuSWInfo.hpp"
|
||||
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
#include "SWInfo.NT.hpp"
|
||||
#include "AuSWInfo.NT.hpp"
|
||||
#endif
|
||||
|
||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||
#include "SWInfo.Linux.hpp"
|
||||
#include "AuSWInfo.Linux.hpp"
|
||||
#endif
|
||||
|
||||
namespace Aurora::SWInfo
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: SWInfo.hpp
|
||||
File: AuSWInfo.hpp
|
||||
Date: 2022-1-25
|
||||
Author: Reece
|
||||
***/
|
@ -1,12 +1,12 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: VersionHelpers.cpp
|
||||
File: AuVersionHelpers.cpp
|
||||
Date: 2022-1-25
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "SWInfo.hpp"
|
||||
#include "AuSWInfo.hpp"
|
||||
// NO HEADER (note -> .hpp wouldn't clash with windows' sdk)
|
||||
|
||||
namespace Aurora::SWInfo
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: VersionHelpers.hpp
|
||||
File: AuVersionHelpers.hpp
|
||||
Date: 2022-25-13
|
||||
Author: Reece
|
||||
***/
|
@ -1,13 +1,13 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Sleep.cpp
|
||||
File: AuSleep.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "Sleep.hpp"
|
||||
#include "WaitFor.hpp"
|
||||
#include "AuSleep.hpp"
|
||||
#include "AuWaitFor.hpp"
|
||||
|
||||
#if defined(AURORA_IS_POSIX_DERIVED)
|
||||
#include <unistd.h>
|
||||
@ -25,30 +25,30 @@ namespace Aurora::Threading
|
||||
static NtDelayExecution_f NtDelayExecution;
|
||||
#endif
|
||||
|
||||
AUKN_SYM void Sleep(AuUInt64 timeout)
|
||||
AUKN_SYM void Sleep(AuUInt64 qwTimeout)
|
||||
{
|
||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||
|
||||
SleepNs(AuMSToNS<AuUInt64>(timeout));
|
||||
SleepNs(AuMSToNS<AuUInt64>(qwTimeout));
|
||||
|
||||
#elif defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
|
||||
::Sleep(timeout);
|
||||
::Sleep(qwTimeout);
|
||||
|
||||
#else
|
||||
std::atomic<bool> value = false;
|
||||
BooleanWaitable waitable(value);
|
||||
WaitFor(&waitable, timeout);
|
||||
WaitFor(&waitable, qwTimeout);
|
||||
#endif
|
||||
}
|
||||
|
||||
AUKN_SYM void SleepNs(AuUInt64 timeout)
|
||||
AUKN_SYM void SleepNs(AuUInt64 qwTimeout)
|
||||
{
|
||||
#if defined(AURORA_IS_LINUX_DERIVED) || defined(AURORA_IS_BSD_DERIVED)
|
||||
|
||||
auto endTime = AuTime::CurrentClockNS() + timeout;
|
||||
auto endTime = AuTime::CurrentClockNS() + qwTimeout;
|
||||
|
||||
if ((usleep(timeout / 1000) == -1) &&
|
||||
if ((usleep(qwTimeout / 1000) == -1) &&
|
||||
(errno == EINTR))
|
||||
{
|
||||
AuUInt64 now;
|
||||
@ -64,7 +64,7 @@ namespace Aurora::Threading
|
||||
|
||||
if (NtDelayExecution)
|
||||
{
|
||||
auto endTime = AuTime::CurrentClockNS() + timeout;
|
||||
auto endTime = AuTime::CurrentClockNS() + qwTimeout;
|
||||
auto targetTime = AuTime::ConvertTimestampNs(endTime);
|
||||
|
||||
while (AuTime::CurrentClockNS() < endTime)
|
||||
@ -79,7 +79,7 @@ namespace Aurora::Threading
|
||||
|
||||
#endif
|
||||
|
||||
auto status = YieldPollNs(true, timeout + Time::CurrentInternalClockNS(), [=]()
|
||||
auto status = YieldPollNs(true, qwTimeout + Time::CurrentInternalClockNS(), [=]()
|
||||
{
|
||||
return false;
|
||||
});
|
@ -1,12 +1,13 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: WaitFor.cpp
|
||||
File: AuWaitFor.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "WaitFor.hpp"
|
||||
#include "AuWaitFor.hpp"
|
||||
|
||||
#if defined(AURORA_IS_LINUX_DERIVED)
|
||||
#include <sched.h>
|
||||
#include <sys/resource.h>
|
@ -1,14 +1,14 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: ConditionEx.cpp
|
||||
File: AuConditionEx.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "ConditionEx.hpp"
|
||||
#include "Mutex.Generic.hpp"
|
||||
#include "Semaphore.Generic.hpp"
|
||||
#include "AuConditionEx.hpp"
|
||||
#include "AuMutex.Generic.hpp"
|
||||
#include "AuSemaphore.Generic.hpp"
|
||||
|
||||
namespace Aurora::Threading::Primitives
|
||||
{
|
||||
@ -18,8 +18,8 @@ namespace Aurora::Threading::Primitives
|
||||
{
|
||||
SemaphoreConditionVariableImpl();
|
||||
|
||||
void WaitForSignal(Aurora::Threading::IWaitable *waitable) override;
|
||||
void WaitForSignal(const AuSPtr<Threading::IWaitable> &waitable) override;
|
||||
void WaitForSignal(Aurora::Threading::IWaitable *pWaitable) override;
|
||||
void WaitForSignal(const AuSPtr<Threading::IWaitable> &pWaitable) override;
|
||||
void WaitForSignal() override;
|
||||
void Signal() override;
|
||||
void Broadcast() override;
|
||||
@ -30,33 +30,35 @@ namespace Aurora::Threading::Primitives
|
||||
SpinLock x_;
|
||||
};
|
||||
|
||||
SemaphoreConditionVariableImpl::SemaphoreConditionVariableImpl() : s_(0), h_(0)
|
||||
SemaphoreConditionVariableImpl::SemaphoreConditionVariableImpl() :
|
||||
s_(0),
|
||||
h_(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void SemaphoreConditionVariableImpl::WaitForSignal(Aurora::Threading::IWaitable *waitable)
|
||||
void SemaphoreConditionVariableImpl::WaitForSignal(Aurora::Threading::IWaitable *pWaitable)
|
||||
{
|
||||
return WaitForSignal(AuUnsafeRaiiToShared(waitable));
|
||||
return WaitForSignal(AuUnsafeRaiiToShared(pWaitable));
|
||||
}
|
||||
|
||||
void SemaphoreConditionVariableImpl::WaitForSignal(const AuSPtr<Threading::IWaitable> &waitable)
|
||||
void SemaphoreConditionVariableImpl::WaitForSignal(const AuSPtr<Threading::IWaitable> &pWaitable)
|
||||
{
|
||||
x_.Lock();
|
||||
waiters_++;
|
||||
x_.Unlock();
|
||||
this->x_.Lock();
|
||||
this->waiters_++;
|
||||
this->x_.Unlock();
|
||||
|
||||
if (waitable)
|
||||
if (pWaitable)
|
||||
{
|
||||
waitable->Unlock();
|
||||
pWaitable->Unlock();
|
||||
}
|
||||
|
||||
s_.Lock();
|
||||
h_.Unlock();
|
||||
this->s_.Lock();
|
||||
this->h_.Unlock();
|
||||
|
||||
if (waitable)
|
||||
if (pWaitable)
|
||||
{
|
||||
waitable->Lock();
|
||||
pWaitable->Lock();
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,26 +69,26 @@ namespace Aurora::Threading::Primitives
|
||||
|
||||
void SemaphoreConditionVariableImpl::Signal()
|
||||
{
|
||||
x_.Lock();
|
||||
if (waiters_ > 0)
|
||||
this->x_.Lock();
|
||||
if (this->waiters_ > 0)
|
||||
{
|
||||
waiters_--;
|
||||
s_.Unlock(); // 1 may pass
|
||||
h_.Lock(); // finish operation - wait for the alive signal back
|
||||
this->waiters_--;
|
||||
this->s_.Unlock(); // 1 may pass
|
||||
this->h_.Lock(); // finish operation - wait for the alive signal back
|
||||
}
|
||||
x_.Unlock();
|
||||
this->x_.Unlock();
|
||||
}
|
||||
|
||||
void SemaphoreConditionVariableImpl::Broadcast()
|
||||
{
|
||||
x_.Lock();
|
||||
s_.Unlock(waiters_); // all may pass at once
|
||||
for (auto i = 0; i < waiters_; i++)
|
||||
this->x_.Lock();
|
||||
this->s_.Unlock(this->waiters_); // all may pass at once
|
||||
for (auto i = 0; i < this->waiters_; i++)
|
||||
{
|
||||
h_.Lock(); // finish operation - wait for the alive signal back
|
||||
this->h_.Lock(); // finish operation - wait for the alive signal back
|
||||
}
|
||||
waiters_ = 0;
|
||||
x_.Unlock();
|
||||
this->waiters_ = 0;
|
||||
this->x_.Unlock();
|
||||
}
|
||||
|
||||
AUKN_SYM ConditionEx *FeaturefulConditionNew()
|
||||
@ -94,8 +96,8 @@ namespace Aurora::Threading::Primitives
|
||||
return _new SemaphoreConditionVariableImpl();
|
||||
}
|
||||
|
||||
AUKN_SYM void FeaturefulConditionRelease(ConditionEx *semaphore)
|
||||
AUKN_SYM void FeaturefulConditionRelease(ConditionEx *pCVEx)
|
||||
{
|
||||
AuSafeDelete<SemaphoreConditionVariableImpl *>(semaphore);
|
||||
AuSafeDelete<SemaphoreConditionVariableImpl *>(pCVEx);
|
||||
}
|
||||
}
|
@ -1,7 +1,7 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: SpinLock.hpp
|
||||
File: AuConditionEx.hpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
@ -1,12 +1,12 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: ConditionMutex.Generic.cpp
|
||||
File: AuConditionMutex.Generic.cpp
|
||||
Date: 2021-6-14
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "ConditionMutex.Generic.hpp"
|
||||
#include "AuConditionMutex.Generic.hpp"
|
||||
|
||||
#if defined(_AURUNTIME_GENERICCM)
|
||||
|
||||
@ -22,18 +22,18 @@ namespace Aurora::Threading::Primitives
|
||||
|
||||
void ConditionMutexImpl::Lock()
|
||||
{
|
||||
mutex_.Lock();
|
||||
this->mutex_.Lock();
|
||||
}
|
||||
|
||||
void ConditionMutexImpl::Unlock()
|
||||
{
|
||||
mutex_.Unlock()
|
||||
this->mutex_.Unlock()
|
||||
}
|
||||
|
||||
AuUInt ConditionMutexImpl::GetOSHandle()
|
||||
{
|
||||
AuMach handle = 0;
|
||||
SysAssertExp(mutex_.HasOSHandle(handle));
|
||||
SysAssertExp(this->mutex_.HasOSHandle(handle));
|
||||
return handle;
|
||||
}
|
||||
|
||||
@ -42,9 +42,9 @@ namespace Aurora::Threading::Primitives
|
||||
return _new ConditionMutexImpl();
|
||||
}
|
||||
|
||||
AUKN_SYM void ConditionMutexRelease(IConditionMutex * mutex)
|
||||
AUKN_SYM void ConditionMutexRelease(IConditionMutex *pMutex)
|
||||
{
|
||||
AuSafeDelete<ConditionMutexImpl *>(mutex);
|
||||
AuSafeDelete<ConditionMutexImpl *>(pMutex);
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +1,22 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: ConditionMutex.Generic.hpp
|
||||
File: AuConditionMutex.Generic.hpp
|
||||
Date: 2021-6-14
|
||||
Author: Reece
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
#include "IConditionMutexEx.hpp"
|
||||
#include "AuIConditionMutexEx.hpp"
|
||||
|
||||
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||||
#include "ConditionMutex.NT.hpp"
|
||||
#include "AuConditionMutex.NT.hpp"
|
||||
#elif defined(AURORA_HAS_PTHREADS)
|
||||
#include "ConditionMutex.Unix.hpp"
|
||||
#include "AuConditionMutex.Unix.hpp"
|
||||
#else
|
||||
#define _AURUNTIME_GENERICCM
|
||||
|
||||
#include "Mutex.Generic.hpp"
|
||||
#include "AuMutex.Generic.hpp"
|
||||
|
||||
namespace Aurora::Threading::Primitives
|
||||
{
|
@ -1,12 +1,12 @@
|
||||
/***
|
||||
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: ConditionMutex.Win32.cpp
|
||||
File: AuConditionMutex.Win32.cpp
|
||||
Date: 2021-6-12
|
||||
Author: Reece
|
||||
***/
|
||||
#include <Source/RuntimeInternal.hpp>
|
||||
#include "ConditionMutex.Generic.hpp"
|
||||
#include "AuConditionMutex.Generic.hpp"
|
||||
|
||||
#if !defined(_AURUNTIME_GENERICCM)
|
||||
|
||||
@ -14,7 +14,7 @@ namespace Aurora::Threading::Primitives
|
||||
{
|
||||
Win32ConditionMutex::Win32ConditionMutex()
|
||||
{
|
||||
InitializeSRWLock(&lock_);
|
||||
InitializeSRWLock(&this->lock_);
|
||||
}
|
||||
|
||||
Win32ConditionMutex::~Win32ConditionMutex()
|
||||
@ -23,17 +23,17 @@ namespace Aurora::Threading::Primitives
|
||||
|
||||
void Win32ConditionMutex::Lock()
|
||||
{
|
||||
AcquireSRWLockExclusive(&lock_);
|
||||
AcquireSRWLockExclusive(&this->lock_);
|
||||
}
|
||||
|
||||
void Win32ConditionMutex::Unlock()
|
||||
{
|
||||
ReleaseSRWLockExclusive(&lock_);
|
||||
ReleaseSRWLockExclusive(&this->lock_);
|
||||
}
|
||||
|
||||
AuUInt Win32ConditionMutex::GetOSHandle()
|
||||
{
|
||||
return reinterpret_cast<AuUInt>(&lock_);
|
||||
return reinterpret_cast<AuUInt>(&this->lock_);
|
||||
}
|
||||
|
||||
AUKN_SYM IConditionMutex *ConditionMutexNew()
|
||||
@ -41,9 +41,9 @@ namespace Aurora::Threading::Primitives
|
||||
return _new Win32ConditionMutex();
|
||||
}
|
||||
|
||||
AUKN_SYM void ConditionMutexRelease(IConditionMutex * mutex)
|
||||
AUKN_SYM void ConditionMutexRelease(IConditionMutex *pMutex)
|
||||
{
|
||||
AuSafeDelete<Win32ConditionMutex *>(mutex);
|
||||
AuSafeDelete<Win32ConditionMutex *>(pMutex);
|
||||
}
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user