Itoyori  v0.0.1
util.hpp File Reference
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstdarg>
#include <ctime>
#include <unistd.h>
#include <iostream>
#include <sstream>
#include <new>
#include <optional>
#include <limits>
#include <vector>
#include <tuple>
#include <memory>
#include <utility>
Include dependency graph for util.hpp:

Go to the source code of this file.

Classes

class  ityr::common::singleton< T >
 
class  ityr::common::singleton_initializer< Singleton >
 
class  ityr::common::move_only_t
 

Namespaces

 ityr
 
 ityr::common
 

Macros

#define ITYR_CONCAT_(x, y)   x##y
 
#define ITYR_CONCAT(x, y)   ITYR_CONCAT_(x, y)
 
#define ITYR_ANON_NAME(x)   ITYR_CONCAT(x, __LINE__)
 
#define ITYR_SUBCASE(name)
 
#define ITYR_REQUIRE(cond)   if (!(cond)) { ityr::common::die("Assertion failed (%s:%d)", __FILE__, __LINE__); }
 
#define ITYR_REQUIRE_MESSAGE(cond, msg, ...)   if (!(cond)) { ityr::common::die(msg " (%s:%d)", ##__VA_ARGS__, __FILE__, __LINE__); }
 
#define ITYR_CHECK(cond)   ITYR_REQUIRE(cond)
 
#define ITYR_CHECK_MESSAGE(cond, ...)   ITYR_REQUIRE_MESSAGE(cond, __VA_ARGS__)
 
#define ITYR_CHECK_THROWS_AS(exp, exception)   exp
 
#define ITYR_ANON_VAR   ITYR_CONCAT(anon_, __LINE__)
 

Functions

uint64_t ityr::common::clock_gettime_ns ()
 
 ityr::common::__attribute__ ((noinline)) inline void die(const char *fmt
 
 ityr::common::va_start (args, fmt)
 
 ityr::common::vsnprintf (msg, slen, fmt, args)
 
 ityr::common::va_end (args)
 
 ityr::common::fprintf (stderr, "\x1b[31m%s\x1b[39m\n", msg)
 
 ityr::common::fflush (stderr)
 
template<typename T >
ityr::common::getenv_with_default (const char *env_var, T default_val)
 
uint64_t ityr::common::next_pow2 (uint64_t x)
 
template<typename T >
bool ityr::common::is_pow2 (T x)
 
template<typename T >
ityr::common::round_down_pow2 (T x, T alignment)
 
template<typename T >
T * ityr::common::round_down_pow2 (T *x, uintptr_t alignment)
 
template<typename T >
ityr::common::round_up_pow2 (T x, T alignment)
 
template<typename T >
T * ityr::common::round_up_pow2 (T *x, uintptr_t alignment)
 
std::size_t ityr::common::get_page_size ()
 
move_only_t ityr::common::operator+ (const move_only_t &mo1, const move_only_t &mo2)
 

Variables

constexpr std::size_t ityr::common::hardware_destructive_interference_size = 64
 
va_list ityr::common::args
 

Macro Definition Documentation

◆ ITYR_ANON_NAME

#define ITYR_ANON_NAME (   x)    ITYR_CONCAT(x, __LINE__)

◆ ITYR_ANON_VAR

#define ITYR_ANON_VAR   ITYR_CONCAT(anon_, __LINE__)

◆ ITYR_CHECK

#define ITYR_CHECK (   cond)    ITYR_REQUIRE(cond)

◆ ITYR_CHECK_MESSAGE

#define ITYR_CHECK_MESSAGE (   cond,
  ... 
)    ITYR_REQUIRE_MESSAGE(cond, __VA_ARGS__)

◆ ITYR_CHECK_THROWS_AS

#define ITYR_CHECK_THROWS_AS (   exp,
  exception 
)    exp

◆ ITYR_CONCAT

#define ITYR_CONCAT (   x,
 
)    ITYR_CONCAT_(x, y)

◆ ITYR_CONCAT_

#define ITYR_CONCAT_ (   x,
 
)    x##y

◆ ITYR_REQUIRE

#define ITYR_REQUIRE (   cond)    if (!(cond)) { ityr::common::die("Assertion failed (%s:%d)", __FILE__, __LINE__); }

◆ ITYR_REQUIRE_MESSAGE

#define ITYR_REQUIRE_MESSAGE (   cond,
  msg,
  ... 
)    if (!(cond)) { ityr::common::die(msg " (%s:%d)", ##__VA_ARGS__, __FILE__, __LINE__); }

◆ ITYR_SUBCASE

#define ITYR_SUBCASE (   name)