#include #include #include #include #include "sysfs.h" #include "zenmonitor.h" #define CPUD_MAX 512 struct bitset { guint bits[CPUD_MAX/32]; }; static int bitset_set(struct bitset *set, int id) { if (id < CPUD_MAX) { int v = (set->bits[id/32] >> (id & 31)) & 1; set->bits[id/32] |= 1 << (id & 31); return v; } return 1; } static int cmp_cpudev(const void *ap, const void *bp) { return ((struct cpudev *)ap)->cpuid - ((struct cpudev *)bp)->cpuid; } struct cpudev* get_cpu_dev_ids(void) { struct cpudev *cpu_dev_ids; gshort coreid, cpuid, siblingid; GDir *dir; const gchar *entry; gchar *filename, *buffer; gchar **cpusiblings; gchar **ptr; guint cores; gboolean found; struct bitset seen = { 0 }; int i; cores = get_core_count(); cpu_dev_ids = malloc(cores * sizeof (*cpu_dev_ids)); for (i=0;i