#pragma once #include #include #include #include namespace gp_config{ namespace memory_module{ enum class memory_mode_t{ other, clib, buffer, arena_buffer }; constexpr memory_mode_t memory_mode = memory_mode_t::clib; template constexpr void*(*memory_allocator)(std::size_t)=nullptr; template constexpr void(*memory_deallocator)(void*)=nullptr; // C Standard library memory usage template<> constexpr void*(*memory_allocator)(std::size_t) = malloc; template<> constexpr void(*memory_deallocator)(void*) = free; // Buffer memory usage only template<> constexpr void*(*memory_allocator)(std::size_t) = nullptr; template<> constexpr void(*memory_deallocator)(void*) = nullptr; // Buffer of arena memory usage template<> constexpr void*(*memory_allocator)(std::size_t) = nullptr; template<> constexpr void(*memory_deallocator)(void*) = nullptr; constexpr bool is_ok = ( memory_allocator != nullptr ) && ( memory_deallocator != nullptr ); } constexpr bool has_exceptions = true; constexpr bool has_buffer_bounds = true; // Value of 8 is considered not cryptographically secure // Value of 12 offers a good compromise of performance and robustness // Value of 20 offers maximum robustness constexpr size_t arc4random_strength = 20; struct assert_failure{ assert_failure(const char* reason) : what_str{reason} {} const char* what_str; const char* what() {return what_str;} }; constexpr size_t assert_buffer_size = 0; constexpr auto assertion = [](bool pred, const char* reason) -> void{ if constexpr (has_exceptions) if(!pred) throw assert_failure(reason); }; } enum class gp_errorcodes : int { infinite_skipstone = 3000 };