Index: libop/op_alloc_counter.c =================================================================== RCS file: /cvsroot/oprofile/oprofile/libop/op_alloc_counter.c,v retrieving revision 1.8 diff -r1.8 op_alloc_counter.c 14a15,16 > #include > #include 133c135 < return 0; --- > continue; 145a148,183 > /* determine which directories are counter directories > */ > static int perfcounterdir(const struct dirent * entry) > { > return (isdigit(entry->d_name[0])); > } > > > /** > * @param mask pointer where to place bit mask of unavailable counters > * > * return >= 0 number of counters that are available > * < 0 could not determine number of counters > * > */ > static int op_get_counter_mask(u32 * mask) > { > struct dirent **counterlist; > int count, i; > /* assume nothing is available */ > u32 available=0; > > count = scandir("/dev/oprofile", &counterlist, perfcounterdir, > alphasort); > if (count < 0) > /* unable to determine bit mask */ > return -1; > /* convert to bit map (0 where counter exists) */ > for (i=0; i available |= 1 << atoi(counterlist[i]->d_name); > free(counterlist[i]); > } > *mask=~available; > free(counterlist); > return count; > } 152a191 > u32 unavailable_counters = 0; 154c193,195 < nr_counters = op_get_nr_counters(cpu_type); --- > nr_counters = op_get_counter_mask(&unavailable_counters); > if (nr_counters < 0) > nr_counters = op_get_nr_counters(cpu_type); 162c203,204 < if (!allocate_counter(ctr_arc, nr_events, 0, 0, counter_map)) { --- > if (!allocate_counter(ctr_arc, nr_events, 0, unavailable_counters, > counter_map)) {