#pragma once
|
|
|
|
#include <new>
|
|
#include <type_traits>
|
|
|
|
#include <cstddef>
|
|
#include <cstdint>
|
|
#include <cstdlib>
|
|
|
|
#ifdef GP_TESTS
|
|
class static_mapper;
|
|
#else
|
|
namespace gp {
|
|
class c_allocator;
|
|
}
|
|
#endif
|
|
|
|
extern void log_failure(const char* failure);
|
|
extern void log_segment(const char* name, const char* text, int16_t prio = 0);
|
|
|
|
/**
|
|
* @brief This namespace contains the configuration.
|
|
*
|
|
* This namespace is expected to be fully defined in an include accessible from the root
|
|
* of your header list:
|
|
* \code{.cpp}
|
|
* #include "gp_config.hpp"
|
|
* \endcode
|
|
*
|
|
* The code line above should always be the one including that config and that namespace.
|
|
*/
|
|
namespace gp_config{
|
|
namespace rendering {
|
|
/**
|
|
* @brief The default type used for rendering processes
|
|
*/
|
|
using default_type = float;
|
|
|
|
/**
|
|
* @brief The small enough value used in signed distance function resolution
|
|
*/
|
|
constexpr default_type epsilon = 0.01;
|
|
|
|
/**
|
|
* @brief The default color type
|
|
*/
|
|
#define GP_CONFIG__RENDERING__COLOR_T vec4
|
|
}
|
|
|
|
/**
|
|
* @brief This namespace contains artificial limitations put on the runtime
|
|
*/
|
|
namespace limits {
|
|
/**
|
|
* @brief the total number of processes the system is allowed to have
|
|
*/
|
|
constexpr size_t max_processes = 4096;
|
|
|
|
/**
|
|
* @brief the maximum size a channel can address
|
|
*/
|
|
constexpr size_t channel_max_size = 1 << 20;
|
|
|
|
/**
|
|
* @brief the default size a channel will take
|
|
*/
|
|
constexpr size_t channel_default_size = 1 << 16;
|
|
|
|
/**
|
|
* @brief the number of open files each process is allowed to have
|
|
*/
|
|
constexpr size_t max_fd_per_process = 128;
|
|
|
|
/**
|
|
* @brief the stack size for the new stacks generated by the concurrency system
|
|
*/
|
|
constexpr size_t process_stack = 1024;
|
|
|
|
/**
|
|
* @brief expected stack alignment
|
|
*/
|
|
constexpr size_t process_stack_align_to = 16;
|
|
|
|
/**
|
|
* @brief presents the direction of stack growth
|
|
*/
|
|
constexpr size_t stack_grow_upwards = false;
|
|
|
|
#if __cpp_lib_hardware_interference_size >= 201603
|
|
constexpr size_t hardware_constructive_interference_size = std::hardware_constructive_interference_size;
|
|
constexpr size_t hardware_destructive_interference_size = std::hardware_destructive_interference_size;
|
|
#else
|
|
constexpr size_t hardware_constructive_interference_size = 128;
|
|
constexpr size_t hardware_destructive_interference_size = 128;
|
|
#endif
|
|
|
|
constexpr size_t loggers_segment_size = 128;
|
|
}
|
|
|
|
namespace memory_module{
|
|
constexpr bool is_ok = true;
|
|
}
|
|
|
|
typedef uint32_t file_descriptor_t;
|
|
|
|
/**
|
|
* @brief set to true to enable exceptions
|
|
*/
|
|
constexpr bool has_exceptions = true;
|
|
|
|
/**
|
|
* @brief set to true to activate bounds checking
|
|
*/
|
|
constexpr bool has_buffer_bounds = true;
|
|
|
|
//
|
|
//
|
|
//
|
|
/**
|
|
* @brief A value used to determine the strength used by random number generators
|
|
*
|
|
* 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;
|
|
|
|
/**
|
|
* @brief an exception that represents an assertion failure
|
|
*/
|
|
struct assert_failure{
|
|
assert_failure(const char* reason)
|
|
: what_str{reason}
|
|
{}
|
|
const char* what_str;
|
|
const char* what() {return what_str;}
|
|
};
|
|
|
|
/**
|
|
* @brief UNUSED
|
|
*/
|
|
constexpr size_t assert_buffer_size = 0;
|
|
|
|
/**
|
|
* @brief an assertion function
|
|
*/
|
|
constexpr auto assertion = [](bool pred, const char* reason) -> void{
|
|
if(!pred) {
|
|
log_failure(reason);
|
|
if constexpr (has_exceptions)
|
|
throw assert_failure(reason);
|
|
}
|
|
};
|
|
|
|
enum class cbor_tag {
|
|
datetime = 0,
|
|
unix_time = 1,
|
|
ubignum = 2,
|
|
nbignum = 3,
|
|
decimal = 4,
|
|
bigfloat = 5,
|
|
cose_encrypt0 = 16,
|
|
cose_mac0 = 17,
|
|
cose_sign1 = 18,
|
|
expected_base64url = 21,
|
|
expected_base64 = 22,
|
|
expected_base16 = 23,
|
|
encoded_cbor = 24,
|
|
url = 32,
|
|
base64url = 33,
|
|
base64 = 34,
|
|
regexp = 35,
|
|
mime = 36,
|
|
cose_encrypt = 96,
|
|
cose_mac = 97,
|
|
cose_sign = 98,
|
|
signature = 55799
|
|
};
|
|
}
|
|
|
|
/**
|
|
* @brief a list of error codes
|
|
*/
|
|
enum class gp_errorcodes : int {
|
|
/**
|
|
* @brief this error code is activated upon reaching a skipstone limit that seems like infinity.
|
|
*/
|
|
infinite_skipstone = 3000
|
|
};
|