Page MenuHomeFreeBSD

D2586.diff
No OneTemporary

D2586.diff

Index: head/lib/libpmc/libpmc.c
===================================================================
--- head/lib/libpmc/libpmc.c
+++ head/lib/libpmc/libpmc.c
@@ -423,9 +423,14 @@
__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
-#define __PMC_CLASS(C) #C ,
+#define __PMC_CLASS(S,V,D) { .pm_class = PMC_CLASS_##S, .pm_name = #S } ,
__PMC_CLASSES()
};
@@ -3362,9 +3367,11 @@
const char *
pmc_name_of_class(enum pmc_class pc)
{
- if ((int) pc >= PMC_CLASS_FIRST &&
- pc <= PMC_CLASS_LAST)
- return (pmc_class_names[pc]);
+ size_t n;
+
+ 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;
return (NULL);
Index: head/sys/dev/hwpmc/hwpmc_mod.c
===================================================================
--- head/sys/dev/hwpmc/hwpmc_mod.c
+++ head/sys/dev/hwpmc/hwpmc_mod.c
@@ -4625,12 +4625,20 @@
/*
* initialization
*/
+static const char *
+pmc_name_of_pmcclass(enum pmc_class class)
+{
-static const char *pmc_name_of_pmcclass[] = {
+ switch (class) {
#undef __PMC_CLASS
-#define __PMC_CLASS(N) #N ,
- __PMC_CLASSES()
-};
+#define __PMC_CLASS(S,V,D) \
+ case PMC_CLASS_##S: \
+ return #S;
+ __PMC_CLASSES();
+ default:
+ return ("<unknown>");
+ }
+}
/*
* Base class initializer: allocate structure and set default classes.
@@ -4909,7 +4917,7 @@
for (n = 0; n < (int) md->pmd_nclass; n++) {
pcd = &md->pmd_classdep[n];
printf(" %s/%d/%d/0x%b",
- pmc_name_of_pmcclass[pcd->pcd_class],
+ pmc_name_of_pmcclass(pcd->pcd_class),
pcd->pcd_num,
pcd->pcd_width,
pcd->pcd_caps,
Index: head/sys/sys/pmc.h
===================================================================
--- head/sys/sys/pmc.h
+++ head/sys/sys/pmc.h
@@ -123,30 +123,30 @@
*/
#define __PMC_CLASSES() \
- __PMC_CLASS(TSC) /* CPU Timestamp counter */ \
- __PMC_CLASS(K7) /* AMD K7 performance counters */ \
- __PMC_CLASS(K8) /* AMD K8 performance counters */ \
- __PMC_CLASS(P5) /* Intel Pentium counters */ \
- __PMC_CLASS(P6) /* Intel Pentium Pro counters */ \
- __PMC_CLASS(P4) /* Intel Pentium-IV counters */ \
- __PMC_CLASS(IAF) /* Intel Core2/Atom, fixed function */ \
- __PMC_CLASS(IAP) /* Intel Core...Atom, programmable */ \
- __PMC_CLASS(UCF) /* Intel Uncore fixed function */ \
- __PMC_CLASS(UCP) /* Intel Uncore programmable */ \
- __PMC_CLASS(XSCALE) /* Intel XScale counters */ \
- __PMC_CLASS(ARMV7) /* ARMv7 */ \
- __PMC_CLASS(ARMV8) /* ARMv8 */ \
- __PMC_CLASS(MIPS24K) /* MIPS 24K */ \
- __PMC_CLASS(OCTEON) /* Cavium Octeon */ \
- __PMC_CLASS(MIPS74K) /* MIPS 74K */ \
- __PMC_CLASS(PPC7450) /* Motorola MPC7450 class */ \
- __PMC_CLASS(PPC970) /* IBM PowerPC 970 class */ \
- __PMC_CLASS(E500) /* Freescale e500 class */ \
- __PMC_CLASS(SOFT) /* Software events */
+ __PMC_CLASS(TSC, 0x000, "CPU Timestamp counter") \
+ __PMC_CLASS(K7, 0x100, "AMD K7 performance counters") \
+ __PMC_CLASS(K8, 0x101, "AMD K8 performance counters") \
+ __PMC_CLASS(P5, 0x102, "Intel Pentium counters") \
+ __PMC_CLASS(P6, 0x103, "Intel Pentium Pro counters") \
+ __PMC_CLASS(P4, 0x104, "Intel Pentium-IV counters") \
+ __PMC_CLASS(IAF, 0x105, "Intel Core2/Atom, fixed function") \
+ __PMC_CLASS(IAP, 0x106, "Intel Core...Atom, programmable") \
+ __PMC_CLASS(UCF, 0x107, "Intel Uncore fixed function") \
+ __PMC_CLASS(UCP, 0x108, "Intel Uncore programmable") \
+ __PMC_CLASS(XSCALE, 0x200, "Intel XScale counters") \
+ __PMC_CLASS(ARMV7, 0x201, "ARMv7") \
+ __PMC_CLASS(ARMV8, 0x202, "ARMv8") \
+ __PMC_CLASS(MIPS24K, 0x300, "MIPS 24K") \
+ __PMC_CLASS(OCTEON, 0x301, "Cavium Octeon") \
+ __PMC_CLASS(MIPS74K, 0x302, "MIPS 74K") \
+ __PMC_CLASS(PPC7450, 0x400, "Motorola MPC7450 class") \
+ __PMC_CLASS(PPC970, 0x401, "IBM PowerPC 970 class") \
+ __PMC_CLASS(E500, 0x402, "Freescale e500 class") \
+ __PMC_CLASS(SOFT, 0x8000, "Software events")
enum pmc_class {
#undef __PMC_CLASS
-#define __PMC_CLASS(N) PMC_CLASS_##N ,
+#define __PMC_CLASS(S,V,D) PMC_CLASS_##S = V,
__PMC_CLASSES()
};

File Metadata

Mime Type
text/plain
Expires
Sun, Feb 2, 6:23 PM (21 h, 30 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16407719
Default Alt Text
D2586.diff (4 KB)

Event Timeline