General Purpose library for Freestanding C++ and POSIX systems
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

156 satır
3.5 KiB

#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
/**
* @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
}
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 constexpr (has_exceptions)
if(!pred) throw assert_failure(reason);
};
}
/**
* @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
};