Index: usr.sbin/pmcstat/pmcstat.c =================================================================== --- usr.sbin/pmcstat/pmcstat.c (revision 224587) +++ usr.sbin/pmcstat/pmcstat.c (working copy) @@ -114,6 +114,59 @@ struct kinfo_proc *pmcstat_plist; struct pmcstat_args args; +static void +pmcstat_clone_event_descriptor(struct pmcstat_ev *ev, + uint32_t cpumask) +{ + int cpu; + struct pmcstat_ev *ev_clone; + + while ((cpu = ffs(cpumask)) > 0) { + cpu--; + + if ((ev_clone = malloc(sizeof(*ev_clone))) == NULL) + errx(EX_SOFTWARE, "ERROR: Out of memory"); + (void) memset(ev_clone, 0, sizeof(*ev_clone)); + + ev_clone->ev_count = ev->ev_count; + ev_clone->ev_cpu = cpu; + ev_clone->ev_cumulative = ev->ev_cumulative; + ev_clone->ev_flags = ev->ev_flags; + ev_clone->ev_mode = ev->ev_mode; + ev_clone->ev_name = strdup(ev->ev_name); + ev_clone->ev_pmcid = ev->ev_pmcid; + ev_clone->ev_saved = ev->ev_saved; + ev_clone->ev_spec = strdup(ev->ev_spec); + + STAILQ_INSERT_TAIL(&args.pa_events, ev_clone, ev_next); + + cpumask &= ~(1 << cpu); + } +} + +static uint32_t +pmcstat_get_cpumask(const char *cpuspec) +{ + uint32_t cpumask; + int cpu; + const char *s; + char *end; + + s = cpuspec; + cpumask = 0ULL; + + do { + cpu = strtol(s, &end, 0); + if (cpu < 0 || end == s) + errx(EX_USAGE, "ERROR: Illegal CPU specification " + "\"%s\".", cpuspec); + cpumask |= (1 << cpu); + s = end + strspn(end, ", \t"); + } while (*s); + + return (cpumask); +} + void pmcstat_attach_pmcs(void) { @@ -173,36 +226,6 @@ } void -pmcstat_clone_event_descriptor(struct pmcstat_ev *ev, - uint32_t cpumask) -{ - int cpu; - struct pmcstat_ev *ev_clone; - - while ((cpu = ffs(cpumask)) > 0) { - cpu--; - - if ((ev_clone = malloc(sizeof(*ev_clone))) == NULL) - errx(EX_SOFTWARE, "ERROR: Out of memory"); - (void) memset(ev_clone, 0, sizeof(*ev_clone)); - - ev_clone->ev_count = ev->ev_count; - ev_clone->ev_cpu = cpu; - ev_clone->ev_cumulative = ev->ev_cumulative; - ev_clone->ev_flags = ev->ev_flags; - ev_clone->ev_mode = ev->ev_mode; - ev_clone->ev_name = strdup(ev->ev_name); - ev_clone->ev_pmcid = ev->ev_pmcid; - ev_clone->ev_saved = ev->ev_saved; - ev_clone->ev_spec = strdup(ev->ev_spec); - - STAILQ_INSERT_TAIL(&args.pa_events, ev_clone, ev_next); - - cpumask &= ~(1 << cpu); - } -} - -void pmcstat_create_process(void) { char token; @@ -322,29 +345,6 @@ /*NOTREACHED*/ } -uint32_t -pmcstat_get_cpumask(const char *cpuspec) -{ - uint32_t cpumask; - int cpu; - const char *s; - char *end; - - s = cpuspec; - cpumask = 0ULL; - - do { - cpu = strtol(s, &end, 0); - if (cpu < 0 || end == s) - errx(EX_USAGE, "ERROR: Illegal CPU specification " - "\"%s\".", cpuspec); - cpumask |= (1 << cpu); - s = end + strspn(end, ", \t"); - } while (*s); - - return (cpumask); -} - void pmcstat_kill_process(void) { Index: usr.sbin/pmcstat/pmcstat.h =================================================================== --- usr.sbin/pmcstat/pmcstat.h (revision 224587) +++ usr.sbin/pmcstat/pmcstat.h (working copy) @@ -159,8 +159,6 @@ /* Function prototypes */ void pmcstat_attach_pmcs(void); void pmcstat_cleanup(void); -void pmcstat_clone_event_descriptor( - struct pmcstat_ev *_ev, uint32_t _cpumask); int pmcstat_close_log(void); void pmcstat_create_process(void); void pmcstat_find_targets(const char *_arg); @@ -178,7 +176,6 @@ int pmcstat_keypress_log(void); void pmcstat_display_log(void); void pmcstat_pluginconfigure_log(char *_opt); -uint32_t pmcstat_get_cpumask(const char *_a); void pmcstat_topexit(void); #endif /* _PMCSTAT_H_ */