|
#define | NVSL_NODISCARD [[nodiscard]] |
|
#define | NVSL_UNUSED __attribute__((unused)) |
|
#define | NVSL_EXPORT __attribute__((visibility("default"))) |
|
#define | NVSL_NOINLINE __attribute__((noinline)) |
|
#define | NVSL_BEGIN_IGNORE_WPEDANTIC |
|
#define | NVSL_END_IGNORE_WPEDANTIC _Pragma("GCC diagnostic pop") |
|
#define | NVSL_LINE_NAME(prefix) NVSL_JOIN(prefix, __LINE__) |
|
#define | NVSL_JOIN(symbol1, symbol2) NVSL_DO_JOIN(symbol1, symbol2) |
|
#define | NVSL_DO_JOIN(symbol1, symbol2) symbol1##symbol2 |
|
#define | NVSL_GUARD(mtx) std::lock_guard<std::mutex> NVSL_LINE_NAME(nvsl_macro_lock_guard)((mtx)) |
| Wrapper for std::lock_guard.
|
|
#define | NVSL_GUARD_PTR(mtx) std::lock_guard<std::mutex> NVSL_LINE_NAME(nvsl_macro_lock_guard)((*mtx)) |
| Wrapper for ptr to std::lock_guard.
|
|
#define | DBG (std::cerr) |
|
#define | DBGF(l) (DBGH(l) << std::string(__FUNCTION__) << "() called." << std::endl); |
|
#define | DBGW |
|
#define | DBGE |
|
|
bool | nvsl::wildcard (const std::string &pat, const std::string &str) |
| Match a pattern using wildcar.
|
|
std::string | nvsl_cur_time_str () |
|
template<typename T > |
const DBGH & | operator<< (const DBGH &dbgh, const T &obj) |
|
const DBGH & | operator<< (const DBGH &s, std::ostream &(*f)(std::ostream &)) |
|
const DBGH & | operator<< (const DBGH &s, std::ostream &(*f)(std::ios &)) |
|
const DBGH & | operator<< (const DBGH &s, std::ostream &(*f)(std::ios_base &)) |
|
constexpr void * | nvsl::align_cl (auto *ptr) |
| Align ptr to the next cache line (64 bytes)
|
|
constexpr void * | nvsl::align_4kb (auto *ptr) |
| Align a ptr to 4KiB page boundary.
|
|
constexpr void * | nvsl::align_2mb (auto *ptr) |
| Align a ptr to 2MiB page boundary.
|
|
constexpr auto | nvsl::round_bytes (auto bytes, auto mult) -> decltype(bytes) |
| Rounds bytes to the multiple of mult greater than it.
|
|
auto | nvsl::page_num (auto ptr) -> decltype(ptr) |
| Get page number from virtual memory address.
|
|
| nvsl::result<< std::hex;size_t cur_byte=0;std::stringstream val;while(cur_byte< bytes) { result<< "0x"<< std::hex<< std::setfill( '0')<< std::setw(8)<<((uint64_t)(buf+cur_byte) >> 4)<< 4<< " ";for(size_t i=0;i< 16;i++) { const size_t idx=cur_byte+i;if(i % 4==0 &&i !=0) { result<< " ";} uint32_t elem=static_cast< uint8_t > (buf[idx]) |
|
result<< std::hex<< std::setfill( '0')<< std::setw(2)<< std::uppercase<< elem;if(buf[idx] >=' ' and buf[idx]<='~') { val<< buf[idx];} else { val<< ".";} } cur_byte+=16;if(cur_byte< bytes) { result<< " "<< val.str()<< std::endl;std::stringstream().swap(val);} } return result.str();} inline bool is_pid_running(pid_t pid) { while(waitpid(-1, 0, WNOHANG) > 0) { } if(0==kill(pid, 0)) return 1;return 0;} template< typename A, typename B, typename C > uint64_t | nvsl::rebase_ptr (A old_base, B new_base, C ptr) |
|
std::string | nvsl::ns_to_hr (size_t ns_total) |
|
template<typename T > |
std::string | nvsl::to_latex (const std::string &name, T val, const std::string &suffix, size_t div_factor=1) |
|
std::string | nvsl::ns_to_latex (size_t ns, const std::string &name, time_unit unit=time_unit::any_unit) |
|
std::string | nvsl::uint64_to_base64 (uint64_t val) |
|
uint64_t | nvsl::base64_to_uint64 (std::string val) |
|
Common macros, constexpr and function definitions.
- Date
- December 25, 2020
Definition in file common.hh.