#include "inspector.hpp" #include static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER ; static std::map exec_count_container ; ScopedMutex::ScopedMutex ( pthread_mutex_t & p_mutex ): m_mutex(p_mutex) { pthread_mutex_lock(&m_mutex); } ScopedMutex::~ScopedMutex() { pthread_mutex_unlock(&m_mutex); } int register_exec_count_ts ( const char * p_exec_count_location, int & p_exec_count ) { ScopedMutex scoped_mutex(mutex); return(register_exec_count(p_exec_count_location, p_exec_count)); } void reset_exec_count_ts ( const char * p_exec_count_location ) { ScopedMutex scoped_mutex(mutex); reset_exec_count(p_exec_count_location); } pthread_mutex_t & get_mutex() { return(mutex); } int register_exec_count ( const char * p_exec_count_location, int & p_exec_count ) { exec_count_container.insert(std::pair(p_exec_count_location, &p_exec_count)); return(0); } void reset_exec_count ( const char * p_exec_count_location ) { if (!p_exec_count_location) { for (std::map::const_iterator it = exec_count_container.begin(); it != exec_count_container.end(); ++it) { *(it->second) = 0; } } else { std::map::const_iterator it = exec_count_container.find(p_exec_count_location); if (it != exec_count_container.end()) { *(it->second) = 0; } } } std::ostream & print ( std::ostream & p_ostream, const char * p_location, int p_exec_count, bool p_condition_value ) { if (0 < p_exec_count) { p_ostream << p_location << "@" << p_exec_count << "@" << std::boolalpha << p_condition_value << std::noboolalpha << "@"; } else { p_ostream << p_location << "@" << "N/A" << "@" << "N/A" << "@"; } return(p_ostream); } #define if(p_condition) if(EXPRESSION(p_condition)) #define while(p_condition) while(EXPRESSION(p_condition)) void foo() { if (0 == 0) ; EXPRESSION(1 != 1); } int main() { foo(); foo(); reset_exec_count_ts(); foo(); PRINT(0, false) << "end of program" << std::endl; return(0); } #undef if #undef while