Processor Counter Monitor
Classes | Macros | Typedefs | Enumerations | Functions
utils.h File Reference

Some common utility routines. More...

#include <cstdio>
#include <cstring>
#include <fstream>
#include <time.h>
#include "types.h"
#include <vector>
#include <chrono>
#include <math.h>
#include <assert.h>
#include <csignal>
#include <ctime>
#include <cmath>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  pcm::null_stream
 
class  pcm::checked_uint64
 
class  pcm::s_expect
 
class  pcm::MainLoop
 
struct  pcm::StackedBarItem
 
union  pcm::PCM_CPUID_INFO
 

Macros

#define PCM_UNUSED(x)   (void)(x)
 
#define PCM_COMPILE_ASSERT(condition)
 

Typedefs

typedef void(* pcm::print_usage_func) (const std::string &progname)
 
typedef std::istringstream pcm::pcm_sscanf
 

Enumerations

enum  CsvOutputType {
  Header1, Header2, Data, Header21,
  Json
}
 

Functions

double pcm::parse_delay (const char *arg, const std::string &progname, print_usage_func print_usage_func)
 
bool pcm::extract_argument_value (const char *arg, std::initializer_list< const char *> arg_names, std::string &value)
 
bool pcm::check_argument_equals (const char *arg, std::initializer_list< const char *> arg_names)
 
void pcm::exit_cleanup (void)
 handler of exit() call
 
void pcm::set_signal_handlers (void)
 install various handlers for system signals
 
void pcm::set_real_time_priority (const bool &silent)
 
void pcm::restore_signal_handlers (void)
 Restores default signal handlers under Linux/UNIX.
 
void pcm::sigINT_handler (int signum)
 handles signals that lead to termination of the program such as SIGINT, SIGQUIT, SIGABRT, SIGSEGV, SIGTERM, SIGCHLD this function specifically works when the client application launched by pcm – terminates
 
void pcm::sigHUP_handler (int)
 handles signals that lead to restart the application such as SIGHUP. for example to re-read environment variables controlling PCM execution
 
void pcm::sigUSR_handler (int)
 handles signals that lead to update of configuration such as SIGUSR1 and SIGUSR2. for the future extensions
 
void pcm::sigSTOP_handler (int)
 handles signals that lead to update of configuration such as SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU
 
void pcm::sigCONT_handler (int)
 handles signals that lead to update of configuration such as SIGCONT
 
void pcm::set_post_cleanup_callback (void(*cb)(void))
 
void pcm::MySleep (int delay)
 
void pcm::MySleepMs (int delay_ms)
 
void pcm::MySystem (char *sysCmd, char **sysArgv)
 launches external program in a separate process
 
template<class IntType >
std::string pcm::unit_format (IntType n)
 
void pcm::print_cpu_details ()
 
std::istream & pcm::operator>> (std::istream &istr, s_expect &&s)
 
std::istream & pcm::operator>> (std::istream &&istr, s_expect &&s)
 
std::pair< tm, uint64 > pcm::pcm_localtime ()
 
template<class H1 , class H2 , class D >
void pcm::choose (const CsvOutputType outputType, H1 h1Func, H2 h2Func, D dataFunc)
 
void pcm::printDateForCSV (const CsvOutputType outputType, std::string separator=std::string(","))
 
void pcm::printDateForJson (const std::string &separator, const std::string &jsonSeparator)
 
std::vector< std::string > pcm::split (const std::string &str, const char delim)
 
bool pcm::CheckAndForceRTMAbortMode (const char *arg, PCM *m)
 
void pcm::print_help_force_rtm_abort_mode (const int alignment)
 
template<class F >
void pcm::parseParam (int argc, char *argv[], const char *param, F f)
 
int pcm::calibratedSleep (const double delay, const char *sysCmd, const MainLoop &mainLoop, PCM *m)
 
void pcm::drawStackedBar (const std::string &label, std::vector< StackedBarItem > &h, const int width)
 
bool pcm::match (const std::string &subtoken, const std::string &sname, uint64 *result)
 
uint64 pcm::read_number (const char *str)
 
void pcm::pcm_cpuid (int leaf, PCM_CPUID_INFO &info)
 
void pcm::clear_screen ()
 
uint32 pcm::build_bit_ui (uint32 beg, uint32 end)
 
uint32 pcm::extract_bits_ui (uint32 myin, uint32 beg, uint32 end)
 
uint64 pcm::build_bit (uint32 beg, uint32 end)
 
uint64 pcm::extract_bits (uint64 myin, uint32 beg, uint32 end)
 
std::string pcm::safe_getenv (const char *env)
 
void pcm::check_and_set_silent (int argc, char *argv[], null_stream &nullStream2)
 
void pcm::print_pid_collection_message (int pid)
 
bool pcm::isPIDOption (char *argv [])
 
void pcm::parsePID (int argc, char *argv[], int &pid)
 

Detailed Description

Some common utility routines.

Macro Definition Documentation

◆ PCM_COMPILE_ASSERT

#define PCM_COMPILE_ASSERT (   condition)
Value:
typedef char pcm_compile_assert_failed[(condition) ? 1 : -1]; \
pcm_compile_assert_failed pcm_compile_assert_failed_; \
PCM_UNUSED(pcm_compile_assert_failed_);