XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Functions
Common.hpp File Reference
#include <type_traits>
#include <cstddef>
#include <cstdint>
Include dependency graph for Common.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  is_ptr_or_uint64< T >
 

Macros

#define RAW_OFFSET(type, x, offset)   (type)((size_t)x + offset)
 
#define RAW_DIFF(p1, p2)   ((intptr_t)p1 - (intptr_t)p2)
 
#define MEM_AFTER(type, p)   ((type)(&(p)[1]))
 
#define DIV_ROUND_UP(x, y)    ((x + y - 1) / y)
 
#define ALIGN_UP(x, y)   (DIV_ROUND_UP(x,y)*y)
 

Functions

template<typename T , std::enable_if_t< is_ptr_or_uint64< T >::value, int > = 0>
std::ptrdiff_t raw_diff (T p1, T p2)
 
template<typename T , typename U , std::enable_if_t< is_ptr_or_uint64< T >::value &&is_ptr_or_uint64< U >::value, int > = 0>
raw_offset (U p1, std::ptrdiff_t offset)
 
template<typename T , std::enable_if_t< is_ptr_or_uint64< T >::value, int > = 0>
mem_after (T p1)
 

Macro Definition Documentation

◆ ALIGN_UP

#define ALIGN_UP (   x,
 
)    (DIV_ROUND_UP(x,y)*y)

◆ DIV_ROUND_UP

#define DIV_ROUND_UP (   x,
 
)     ((x + y - 1) / y)

◆ MEM_AFTER

#define MEM_AFTER (   type,
 
)    ((type)(&(p)[1]))

◆ RAW_DIFF

#define RAW_DIFF (   p1,
  p2 
)    ((intptr_t)p1 - (intptr_t)p2)

◆ RAW_OFFSET

#define RAW_OFFSET (   type,
  x,
  offset 
)    (type)((size_t)x + offset)

Function Documentation

◆ mem_after()

template<typename T , std::enable_if_t< is_ptr_or_uint64< T >::value, int > = 0>
T mem_after ( p1)

◆ raw_diff()

template<typename T , std::enable_if_t< is_ptr_or_uint64< T >::value, int > = 0>
std::ptrdiff_t raw_diff ( p1,
p2 
)

◆ raw_offset()

template<typename T , typename U , std::enable_if_t< is_ptr_or_uint64< T >::value &&is_ptr_or_uint64< U >::value, int > = 0>
T raw_offset ( p1,
std::ptrdiff_t  offset 
)