Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libpmc/libpmc.c
Show First 20 Lines • Show All 417 Lines • ▼ Show 20 Lines | |||||
*/ | */ | ||||
static const char * pmc_capability_names[] = { | static const char * pmc_capability_names[] = { | ||||
#undef __PMC_CAP | #undef __PMC_CAP | ||||
#define __PMC_CAP(N,V,D) #N , | #define __PMC_CAP(N,V,D) #N , | ||||
__PMC_CAPS() | __PMC_CAPS() | ||||
}; | }; | ||||
static const char * pmc_class_names[] = { | struct pmc_class_map { | ||||
enum pmc_class pm_class; | |||||
const char *pm_name; | |||||
}; | |||||
static const struct pmc_class_map pmc_class_names[] = { | |||||
#undef __PMC_CLASS | #undef __PMC_CLASS | ||||
#define __PMC_CLASS(C) #C , | #define __PMC_CLASS(S,V,D) { .pm_class = PMC_CLASS_##S, .pm_name = #S } , | ||||
__PMC_CLASSES() | __PMC_CLASSES() | ||||
}; | }; | ||||
struct pmc_cputype_map { | struct pmc_cputype_map { | ||||
enum pmc_cputype pm_cputype; | enum pmc_cputype pm_cputype; | ||||
const char *pm_name; | const char *pm_name; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 2,920 Lines • ▼ Show 20 Lines | pmc_name_of_capability(enum pmc_caps cap) | ||||
i = ffs(cap); | i = ffs(cap); | ||||
return (pmc_capability_names[i - 1]); | return (pmc_capability_names[i - 1]); | ||||
} | } | ||||
const char * | const char * | ||||
pmc_name_of_class(enum pmc_class pc) | pmc_name_of_class(enum pmc_class pc) | ||||
{ | { | ||||
if ((int) pc >= PMC_CLASS_FIRST && | size_t n; | ||||
pc <= PMC_CLASS_LAST) | |||||
return (pmc_class_names[pc]); | for (n = 0; n < PMC_TABLE_SIZE(pmc_class_names); n++) | ||||
if (pc == pmc_class_names[n].pm_class) | |||||
return (pmc_class_names[n].pm_name); | |||||
errno = EINVAL; | errno = EINVAL; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
const char * | const char * | ||||
pmc_name_of_cputype(enum pmc_cputype cp) | pmc_name_of_cputype(enum pmc_cputype cp) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 378 Lines • Show Last 20 Lines |