mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-06 17:18:32 +00:00
libpmc: make pmc_pmu_pmcallocate() machine-independent
Have it call the platform-dependent version. For better layering, move the reset logic inside the new function. This is mainly to facilitate an upcoming change. Reviewed by: jkoshy MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D40752
This commit is contained in:
parent
525bc87f54
commit
45dcc17e2f
|
@ -1091,11 +1091,6 @@ pmc_allocate(const char *ctrspec, enum pmc_mode mode,
|
|||
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;
|
||||
|
|
|
@ -572,8 +572,8 @@ pmc_pmu_intel_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm,
|
|||
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 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
|
|||
|
||||
#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 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
|
|||
|
||||
#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 @@ pmc_pmu_pmcallocate(const char *event_name, struct pmc_op_pmcallocate *pm)
|
|||
|
||||
#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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue