Here are two sets of utility definitions and functions. These utilities are called by the example benchmark/application programs.
test_common.h and test_common.c contain definitions, declarations and functions to perform everyday tasks such as creating/closing the results file, writing platform information to the results file, writing run statistics to the file, and so forth. A few of these routines are stubbed out on Linux.
rpi_pmu.h and rpi_pmu.c define symbolic constants for the ARM 1176 (Raspberry Pi) performance events and provide a handful of routines to configure and control the performance counters. There are also a few handy routines to accumulate and display event counts.
I usually keep this code in its own directory with the name test_common. The test common directory is a peer of the directories containing the benchmark/application programs which use the common code. The makefiles assume this directory structure.