diff --git a/Include/Aurora/Memory/ByteBuffer.hpp b/Include/Aurora/Memory/ByteBuffer.hpp index 7c01a4f6..9f225059 100644 --- a/Include/Aurora/Memory/ByteBuffer.hpp +++ b/Include/Aurora/Memory/ByteBuffer.hpp @@ -8,6 +8,7 @@ #pragma once #include +#include namespace Aurora::Memory { @@ -44,10 +45,16 @@ namespace Aurora::Memory */ struct ByteBuffer { + /////////////////////////////////////////////////////////////////////// + // User storage: // + /////////////////////////////////////////////////////////////////////// + AURT_ADD_USR_DATA; + /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// // Stable ByteBuffer ABI Header; length and read/write head pointers // /////////////////////////////////////////////////////////////////////// - + /// Internal capacity to mitigate trivial reallocs AuUInt allocSize; @@ -56,32 +63,38 @@ namespace Aurora::Memory /// Buffer pointer AuUInt8 *base {}; - /// Stream pointer + /// Read stream pointer AuUInt8 *readPtr {}; - /// Stream pointer + /// Write stream pointer AuUInt8 *writePtr {}; - - /////////////////////////////////////////////////////////////////////// - // Stable ByteBuffer ABI Header; u32 flags // - /////////////////////////////////////////////////////////////////////// - /// Is ring buffer? - AuUInt8 flagCircular : 1 {}; - /// Should resize linear buffer to accommodate additional writes - AuUInt8 flagExpandable : 1 {}; - - AuUInt8 flagReadError : 1 {}; - AuUInt8 flagWriteError : 1 {}; - AuUInt8 flagNoFree : 1 {}; - AuUInt8 flagNoRealloc: 1 {}; - AuUInt8 flagAlwaysExpandable : 1 {}; - // TODO: flag: allow circular overrun to allow for 100% access of the buffer from either read head - // - implicit padding - AuUInt8 scaleSize {};// - AuUInt8 alignment {}; + /////////////////////////////////////////////////////////////////////// + // Memory protection + // (resize/free/etc fails when this value is not zero. free-during-use protection) + /////////////////////////////////////////////////////////////////////// AuAUInt32 uInUseCounter { 0 }; /////////////////////////////////////////////////////////////////////// + /////////////////////////////////////////////////////////////////////// + // Stable ByteBuffer ABI Header; u8 flags // + /////////////////////////////////////////////////////////////////////// + + AuUInt8 flagCircular : 1 {}; /// Is ring buffer? + AuUInt8 flagExpandable : 1 {}; /// Should resize linear buffer to accommodate additional writes + AuUInt8 flagReadError : 1 {}; /// Has error? Has read error? + AuUInt8 flagWriteError : 1 {}; /// Has error? Has write error? + AuUInt8 flagNoFree : 1 {}; /// Prevents all free operations + AuUInt8 flagNoRealloc : 1 {}; /// Prevents a subset of free options, specifically realloc, operations + AuUInt8 flagAlwaysExpandable : 1 {}; /// Internal flag. Do not use. + AuUInt8 flagReserveA : 1 {}; /// Placeholder + + /////////////////////////////////////////////////////////////////////// + // Special flags/values + /////////////////////////////////////////////////////////////////////// + AuUInt8 alignment {}; // Internal value: keeps track of explicit Allocate of alignment values + AuUInt8 scaleSize {}; // TODO: + /////////////////////////////////////////////////////////////////////// + /** * @brief Move constructor * @param buffer diff --git a/Include/Aurora/Utility/PrivData.hpp b/Include/Aurora/Utility/PrivData.hpp index b2a1c561..6cbcd055 100644 --- a/Include/Aurora/Utility/PrivData.hpp +++ b/Include/Aurora/Utility/PrivData.hpp @@ -94,7 +94,8 @@ namespace Aurora::Utility inline void PrivateUserDataClear()\ {\ AuResetMember(this->_auReservedUserData.pData);\ - } + }\ + public: #define AURT_ADD_USR_DATA_EXP(exp) \ inline virtual AURT_PRIVATE_DATA_PTR PrivateUserDataGet()\