perf_counter tools: Move perfstat supporting code into perfcounters.h