General Purpose library for Freestanding C++ and POSIX systems
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

67 líneas
1.8 KiB

  1. #pragma once
  2. #include <cstdint>
  3. #include <cstddef>
  4. #include <cstdlib>
  5. #include <type_traits>
  6. namespace gp_config{
  7. namespace memory_module{
  8. enum class memory_mode_t{
  9. other,
  10. clib,
  11. buffer,
  12. arena_buffer
  13. };
  14. constexpr memory_mode_t memory_mode = memory_mode_t::clib;
  15. template<memory_mode_t T = memory_mode_t::other>
  16. constexpr void*(*memory_allocator)(std::size_t)=nullptr;
  17. template<memory_mode_t T = memory_mode_t::other>
  18. constexpr void(*memory_deallocator)(void*)=nullptr;
  19. // C Standard library memory usage
  20. template<>
  21. constexpr void*(*memory_allocator<memory_mode_t::clib>)(std::size_t) = malloc;
  22. template<>
  23. constexpr void(*memory_deallocator<memory_mode_t::clib>)(void*) = free;
  24. // Buffer memory usage only
  25. template<>
  26. constexpr void*(*memory_allocator<memory_mode_t::buffer>)(std::size_t) = nullptr;
  27. template<>
  28. constexpr void(*memory_deallocator<memory_mode_t::buffer>)(void*) = nullptr;
  29. // Buffer of arena memory usage
  30. template<>
  31. constexpr void*(*memory_allocator<memory_mode_t::arena_buffer>)(std::size_t) = nullptr;
  32. template<>
  33. constexpr void(*memory_deallocator<memory_mode_t::arena_buffer>)(void*) = nullptr;
  34. constexpr bool is_ok =
  35. ( memory_allocator<memory_mode> != nullptr )
  36. && ( memory_deallocator<memory_mode> != nullptr );
  37. }
  38. constexpr bool has_exceptions = true;
  39. // Value of 8 is considered not cryptographically secure
  40. // Value of 12 offers a good compromise of performance and robustness
  41. // Value of 20 offers maximum robustness
  42. constexpr size_t arc4random_strength = 20;
  43. constexpr size_t assert_buffer_size = 0;
  44. constexpr auto assert = [](bool, const char*) -> void{};
  45. /** Simple exit assert
  46. constexpr auto assert = [](bool pred, const char*) -> void
  47. {
  48. if(pred)
  49. return;
  50. else
  51. std::exit(-1);};
  52. */
  53. }
  54. enum class gp_errorcodes : int {
  55. infinite_skipstone = 3000
  56. };