General Purpose library for Freestanding C++ and POSIX systems
Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

145 Zeilen
3.3 KiB

vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
  1. #pragma once
  2. #include <new>
  3. #include <type_traits>
  4. #include <cstddef>
  5. #include <cstdint>
  6. #include <cstdlib>
  7. #ifdef GP_TESTS
  8. class static_mapper;
  9. #else
  10. namespace gp {
  11. class c_allocator;
  12. }
  13. #endif
  14. /**
  15. * @brief This namespace contains the configuration.
  16. *
  17. * This namespace is expected to be fully defined in an include accessible from the root
  18. * of your header list:
  19. * \code{.cpp}
  20. * #include "gp_config.hpp"
  21. * \endcode
  22. *
  23. * The code line above should always be the one including that config and that namespace.
  24. */
  25. namespace gp_config{
  26. namespace rendering {
  27. /**
  28. * @brief The default type used for rendering processes
  29. */
  30. using default_type = float;
  31. /**
  32. * @brief The small enough value used in signed distance function resolution
  33. */
  34. constexpr default_type epsilon = 0.001;
  35. /**
  36. * @brief The default color type
  37. */
  38. #define GP_CONFIG__RENDERING__COLOR_T vec4
  39. }
  40. /**
  41. * @brief This namespace contains artificial limitations put on the runtime
  42. */
  43. namespace limits {
  44. /**
  45. * @brief the total number of processes the system is allowed to have
  46. */
  47. constexpr size_t max_processes = 4096;
  48. /**
  49. * @brief the number of open files each process is allowed to have
  50. */
  51. constexpr size_t max_fd_per_process = 128;
  52. /**
  53. * @brief the stack size for the new stacks generated by the concurrency system
  54. */
  55. constexpr size_t process_stack = 1024;
  56. /**
  57. * @brief expected stack alignment
  58. */
  59. constexpr size_t process_stack_align_to = 16;
  60. /**
  61. * @brief presents the direction of stack growth
  62. */
  63. constexpr size_t stack_grow_upwards = false;
  64. #if __cpp_lib_hardware_interference_size >= 201603
  65. constexpr size_t hardware_constructive_interference_size = std::hardware_constructive_interference_size;
  66. constexpr size_t hardware_destructive_interference_size = std::hardware_destructive_interference_size;
  67. #else
  68. constexpr size_t hardware_constructive_interference_size = 128;
  69. constexpr size_t hardware_destructive_interference_size = 128;
  70. #endif
  71. }
  72. namespace memory_module{
  73. constexpr bool is_ok = true;
  74. }
  75. typedef uint32_t file_descriptor_t;
  76. /**
  77. * @brief set to true to enable exceptions
  78. */
  79. constexpr bool has_exceptions = true;
  80. /**
  81. * @brief set to true to activate bounds checking
  82. */
  83. constexpr bool has_buffer_bounds = true;
  84. //
  85. //
  86. //
  87. /**
  88. * @brief A value used to determine the strength used by random number generators
  89. *
  90. * Value of 8 is considered not cryptographically secure
  91. * Value of 12 offers a good compromise of performance and robustness
  92. * Value of 20 offers maximum robustness
  93. */
  94. constexpr size_t arc4random_strength = 20;
  95. /**
  96. * @brief an exception that represents an assertion failure
  97. */
  98. struct assert_failure{
  99. assert_failure(const char* reason)
  100. : what_str{reason}
  101. {}
  102. const char* what_str;
  103. const char* what() {return what_str;}
  104. };
  105. /**
  106. * @brief UNUSED
  107. */
  108. constexpr size_t assert_buffer_size = 0;
  109. /**
  110. * @brief an assertion function
  111. */
  112. constexpr auto assertion = [](bool pred, const char* reason) -> void{
  113. if constexpr (has_exceptions)
  114. if(!pred) throw assert_failure(reason);
  115. };
  116. }
  117. /**
  118. * @brief a list of error codes
  119. */
  120. enum class gp_errorcodes : int {
  121. /**
  122. * @brief this error code is activated upon reaching a skipstone limit that seems like infinity.
  123. */
  124. infinite_skipstone = 3000
  125. };