diff --git a/lib/libpmc/libpmc.c b/lib/libpmc/libpmc.c --- a/lib/libpmc/libpmc.c +++ b/lib/libpmc/libpmc.c @@ -1091,11 +1091,6 @@ assert(pmc_config.pm_ev < PMC_EVENT_FIRST); goto found; } - - /* Otherwise, reset any changes */ - pmc_config.pm_ev = 0; - pmc_config.pm_caps = 0; - pmc_config.pm_class = 0; } free(spec_copy); spec_copy = NULL; diff --git a/lib/libpmc/libpmc_pmu_util.c b/lib/libpmc/libpmc_pmu_util.c --- a/lib/libpmc/libpmc_pmu_util.c +++ b/lib/libpmc/libpmc_pmu_util.c @@ -572,8 +572,8 @@ return (0); } -int -pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) +static int +pmc_pmu_pmcallocate_md(const char *event_name, struct pmc_op_pmcallocate *pm) { const struct pmu_event *pe; struct pmu_event_desc ped; @@ -604,8 +604,8 @@ #elif defined(__powerpc64__) -int -pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) +static int +pmc_pmu_pmcallocate_md(const char *event_name, struct pmc_op_pmcallocate *pm) { const struct pmu_event *pe; struct pmu_event_desc ped; @@ -631,8 +631,8 @@ #elif defined(__aarch64__) -int -pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) +static int +pmc_pmu_pmcallocate_md(const char *event_name, struct pmc_op_pmcallocate *pm) { const struct pmu_event *pe; struct pmu_event_desc ped; @@ -658,9 +658,27 @@ #else -int -pmc_pmu_pmcallocate(const char *e __unused, struct pmc_op_pmcallocate *p __unused) +static int +pmc_pmu_pmcallocate_md(const char *e __unused, struct pmc_op_pmcallocate *p __unused) { return (EOPNOTSUPP); } #endif + +int +pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm) +{ + int error; + + error = pmc_pmu_pmcallocate_md(event_name, pm); + if (error != 0) { + /* Reset any changes. */ + pm->pm_ev = 0; + pm->pm_caps = 0; + pm->pm_class = 0; + + return (error); + } + + return (0); +}