General Purpose library for Freestanding C++ and POSIX systems
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

189 regels
4.2 KiB

3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
3 jaren geleden
4 jaren geleden
3 jaren geleden
3 jaren geleden
4 jaren geleden
3 jaren geleden
3 jaren geleden
4 jaren geleden
4 jaren geleden
3 jaren geleden
3 jaren geleden
  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. extern void log_failure(const char* failure);
  15. extern void log_segment(const char* name, const char* text, int16_t prio = 0);
  16. /**
  17. * @brief This namespace contains the configuration.
  18. *
  19. * This namespace is expected to be fully defined in an include accessible from the root
  20. * of your header list:
  21. * \code{.cpp}
  22. * #include "gp_config.hpp"
  23. * \endcode
  24. *
  25. * The code line above should always be the one including that config and that namespace.
  26. */
  27. namespace gp_config{
  28. namespace rendering {
  29. /**
  30. * @brief The default type used for rendering processes
  31. */
  32. using default_type = float;
  33. /**
  34. * @brief The small enough value used in signed distance function resolution
  35. */
  36. constexpr default_type epsilon = 0.01;
  37. /**
  38. * @brief The default color type
  39. */
  40. #define GP_CONFIG__RENDERING__COLOR_T vec4
  41. }
  42. /**
  43. * @brief This namespace contains artificial limitations put on the runtime
  44. */
  45. namespace limits {
  46. /**
  47. * @brief the total number of processes the system is allowed to have
  48. */
  49. constexpr size_t max_processes = 4096;
  50. /**
  51. * @brief the maximum size a channel can address
  52. */
  53. constexpr size_t channel_max_size = 1 << 20;
  54. /**
  55. * @brief the default size a channel will take
  56. */
  57. constexpr size_t channel_default_size = 1 << 16;
  58. /**
  59. * @brief the number of open files each process is allowed to have
  60. */
  61. constexpr size_t max_fd_per_process = 128;
  62. /**
  63. * @brief the stack size for the new stacks generated by the concurrency system
  64. */
  65. constexpr size_t process_stack = 1024;
  66. /**
  67. * @brief expected stack alignment
  68. */
  69. constexpr size_t process_stack_align_to = 16;
  70. /**
  71. * @brief presents the direction of stack growth
  72. */
  73. constexpr size_t stack_grow_upwards = false;
  74. #if __cpp_lib_hardware_interference_size >= 201603
  75. constexpr size_t hardware_constructive_interference_size = std::hardware_constructive_interference_size;
  76. constexpr size_t hardware_destructive_interference_size = std::hardware_destructive_interference_size;
  77. #else
  78. constexpr size_t hardware_constructive_interference_size = 128;
  79. constexpr size_t hardware_destructive_interference_size = 128;
  80. #endif
  81. constexpr size_t loggers_segment_size = 128;
  82. }
  83. namespace memory_module{
  84. constexpr bool is_ok = true;
  85. constexpr bool prefer_constant_memory = true;
  86. }
  87. typedef uint32_t file_descriptor_t;
  88. /**
  89. * @brief set to true to enable exceptions
  90. */
  91. constexpr bool has_exceptions = true;
  92. /**
  93. * @brief set to true to activate bounds checking
  94. */
  95. constexpr bool has_buffer_bounds = true;
  96. //
  97. //
  98. //
  99. /**
  100. * @brief A value used to determine the strength used by random number generators
  101. *
  102. * Value of 8 is considered not cryptographically secure
  103. * Value of 12 offers a good compromise of performance and robustness
  104. * Value of 20 offers maximum robustness
  105. */
  106. constexpr size_t arc4random_strength = 20;
  107. /**
  108. * @brief an exception that represents an assertion failure
  109. */
  110. struct assert_failure{
  111. assert_failure(const char* reason)
  112. : what_str{reason}
  113. {}
  114. const char* what_str;
  115. const char* what() {return what_str;}
  116. };
  117. /**
  118. * @brief UNUSED
  119. */
  120. constexpr size_t assert_buffer_size = 0;
  121. /**
  122. * @brief an assertion function
  123. */
  124. constexpr auto assertion = [](bool pred, const char* reason) -> void{
  125. if(!pred) {
  126. log_failure(reason);
  127. if constexpr (has_exceptions)
  128. throw assert_failure(reason);
  129. }
  130. };
  131. enum class cbor_tag {
  132. datetime = 0,
  133. unix_time = 1,
  134. ubignum = 2,
  135. nbignum = 3,
  136. decimal = 4,
  137. bigfloat = 5,
  138. cose_encrypt0 = 16,
  139. cose_mac0 = 17,
  140. cose_sign1 = 18,
  141. expected_base64url = 21,
  142. expected_base64 = 22,
  143. expected_base16 = 23,
  144. encoded_cbor = 24,
  145. url = 32,
  146. base64url = 33,
  147. base64 = 34,
  148. regexp = 35,
  149. mime = 36,
  150. cose_encrypt = 96,
  151. cose_mac = 97,
  152. cose_sign = 98,
  153. signature = 55799
  154. };
  155. }
  156. /**
  157. * @brief a list of error codes
  158. */
  159. enum class gp_errorcodes : int {
  160. /**
  161. * @brief this error code is activated upon reaching a skipstone limit that seems like infinity.
  162. */
  163. infinite_skipstone = 3000
  164. };