General Purpose library for Freestanding C++ and POSIX systems
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

155 rindas
3.5 KiB

pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
pirms 4 gadiem
  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.01;
  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 maximum size a channel can address
  50. */
  51. constexpr size_t channel_max_size = 1 << 20;
  52. /**
  53. * @brief the default size a channel will take
  54. */
  55. constexpr size_t channel_default_size = 1 << 16;
  56. /**
  57. * @brief the number of open files each process is allowed to have
  58. */
  59. constexpr size_t max_fd_per_process = 128;
  60. /**
  61. * @brief the stack size for the new stacks generated by the concurrency system
  62. */
  63. constexpr size_t process_stack = 1024;
  64. /**
  65. * @brief expected stack alignment
  66. */
  67. constexpr size_t process_stack_align_to = 16;
  68. /**
  69. * @brief presents the direction of stack growth
  70. */
  71. constexpr size_t stack_grow_upwards = false;
  72. #if __cpp_lib_hardware_interference_size >= 201603
  73. constexpr size_t hardware_constructive_interference_size = std::hardware_constructive_interference_size;
  74. constexpr size_t hardware_destructive_interference_size = std::hardware_destructive_interference_size;
  75. #else
  76. constexpr size_t hardware_constructive_interference_size = 128;
  77. constexpr size_t hardware_destructive_interference_size = 128;
  78. #endif
  79. }
  80. namespace memory_module{
  81. constexpr bool is_ok = true;
  82. }
  83. typedef uint32_t file_descriptor_t;
  84. /**
  85. * @brief set to true to enable exceptions
  86. */
  87. constexpr bool has_exceptions = true;
  88. /**
  89. * @brief set to true to activate bounds checking
  90. */
  91. constexpr bool has_buffer_bounds = true;
  92. //
  93. //
  94. //
  95. /**
  96. * @brief A value used to determine the strength used by random number generators
  97. *
  98. * Value of 8 is considered not cryptographically secure
  99. * Value of 12 offers a good compromise of performance and robustness
  100. * Value of 20 offers maximum robustness
  101. */
  102. constexpr size_t arc4random_strength = 20;
  103. /**
  104. * @brief an exception that represents an assertion failure
  105. */
  106. struct assert_failure{
  107. assert_failure(const char* reason)
  108. : what_str{reason}
  109. {}
  110. const char* what_str;
  111. const char* what() {return what_str;}
  112. };
  113. /**
  114. * @brief UNUSED
  115. */
  116. constexpr size_t assert_buffer_size = 0;
  117. /**
  118. * @brief an assertion function
  119. */
  120. constexpr auto assertion = [](bool pred, const char* reason) -> void{
  121. if constexpr (has_exceptions)
  122. if(!pred) throw assert_failure(reason);
  123. };
  124. }
  125. /**
  126. * @brief a list of error codes
  127. */
  128. enum class gp_errorcodes : int {
  129. /**
  130. * @brief this error code is activated upon reaching a skipstone limit that seems like infinity.
  131. */
  132. infinite_skipstone = 3000
  133. };