24 #ifndef PCM_UTILS_HEADER
25 #define PCM_UTILS_HEADER
50 inline void win_usleep(
int delay_us)
52 uint64 t1 = 0, t2 = 0, freq = 0;
54 QueryPerformanceFrequency((LARGE_INTEGER *) &freq);
55 wait_tick = freq * delay_us / 1000000ULL;
56 QueryPerformanceCounter((LARGE_INTEGER *) &t1);
58 QueryPerformanceCounter((LARGE_INTEGER *) &t2);
60 }
while ((t2-t1) < wait_tick);
64 inline void MySleep(
int delay)
67 if(delay) Sleep(delay*1000);
73 inline void MySleepMs(
int delay_ms)
76 if(delay_ms) Sleep(delay_ms);
78 struct timespec sleep_intrval;
79 double complete_seconds;
80 sleep_intrval.tv_nsec =
static_cast<long>(1000000000.0*(::modf(delay_ms/1000.0,&complete_seconds)));
81 sleep_intrval.tv_sec =
static_cast<time_t
>(complete_seconds);
82 ::nanosleep(&sleep_intrval, NULL);
86 inline void MySleepUs(
int delay_us)
89 if(delay_us) win_usleep(delay_us);
96 void MySystem(
char * sysCmd,
char ** argc);
100 void overflow(
char) { }
103 template <
class IntType>
104 inline std::string unit_format(IntType n)
109 sprintf(buffer,
"%4d ", int32(n));
114 sprintf(buffer,
"%4d K", int32(n / 1000ULL));
117 if (n <= 9999999999ULL)
119 sprintf(buffer,
"%4d M", int32(n / 1000000ULL));
122 if (n <= 9999999999999ULL)
124 sprintf(buffer,
"%4d G", int32(n / 1000000000ULL));
128 sprintf(buffer,
"%4d T", int32(n / (1000000000ULL * 1000ULL)));
133 #define PCM_UNUSED(x) (void)(x)
135 #define PCM_COMPILE_ASSERT(condition) \
136 typedef char pcm_compile_assert_failed [ (condition) ? 1 : -1 ]; \
137 pcm_compile_assert_failed pcm_compile_assert_failed_; \
138 PCM_UNUSED(pcm_compile_assert_failed_);
140 #ifdef COMPILE_FOR_WINDOWS_7
142 class ThreadGroupTempAffinity
144 GROUP_AFFINITY PreviousGroupAffinity;
146 ThreadGroupTempAffinity();
147 ThreadGroupTempAffinity(
const ThreadGroupTempAffinity &);
149 ThreadGroupTempAffinity(uint32 core_id);
150 ~ThreadGroupTempAffinity();
void sigCONT_handler(int signum)
handles signals that lead to update of configuration such as SIGCONT
Definition: utils.cpp:214
void set_signal_handlers(void)
install various handlers for system signals
Definition: utils.cpp:223
Main CPU counters header.
void sigSTOP_handler(int signum)
handles signals that lead to update of configuration such as SIGSTOP, SIGTSTP, SIGTTIN, SIGTTOU
Definition: utils.cpp:192
void MySystem(char *sysCmd, char **argc)
launches external program in a separate process
Definition: utils.cpp:333
void sigUSR_handler(int signum)
handles signals that lead to update of configuration such as SIGUSR1 and SIGUSR2. for the future exte...
Definition: utils.cpp:180
void sigHUP_handler(int signum)
handles signals that lead to restart the application such as SIGHUP. for example to re-read environme...
Definition: utils.cpp:166
void restore_signal_handlers(void)
Restores default signal handlers under Linux/UNIX.
Definition: utils.cpp:296
void 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 aplication launched by pcm – terminates
Definition: utils.cpp:147
void exit_cleanup(void)
handler of exit() call
Definition: utils.cpp:33