add new changes for FreeBSD from Harald.
add new changes for FreeBSD from Harald.

pyrovski/papi,arm-hpc/papi,arm-hpc/papi,arm-hpc/papi,pyrovski/papi,pyrovski/papi,pyrovski/papi,pyrovski/papi,pyrovski/papi,arm-hpc/papi,arm-hpc/papi,arm-hpc/papi,pyrovski/papi,arm-hpc/papi,pyrovski/papi