/* * Linux-style /proc/cpuinfo. * Only used when procfs is mounted with -o linux. * * In the multiprocessor case, this should be a loop over all CPUs. */ int procfs_getcpuinfstr(char *bf, int *len) { struct cpu_info *ci; CPU_INFO_ITERATOR cii; int i = 0, used = *len, total = *len; *len = 0; for (CPU_INFO_FOREACH(cii, ci)) { if (procfs_getonecpu(i++, ci, bf, &used) == 0) { *len += used; total = 0; break; } total -= used; if (total > 0) { bf += used; *bf++ = '\n'; *len += used + 1; used = --total; if (used == 0) break; } else { *len += used; break; } } return total == 0 ? -1 : 0; }
/* * Linux-style /proc/cpuinfo. * Only used when procfs is mounted with -o linux. * * In the multiprocessor case, this should be a loop over all CPUs. */ int procfs_getcpuinfstr(char *bf, size_t *len) { struct cpu_info *ci; CPU_INFO_ITERATOR cii; size_t i, total, size, used; i = total = 0; used = size = *len; for (CPU_INFO_FOREACH(cii, ci)) { procfs_getonecpu(i++, ci, bf, &used); total += used + 1; if (used + 1 < size) { bf += used; *bf++ = '\n'; size -= used + 1; used = size; } else used = 0; } size = *len; *len = total; return size < *len ? -1 : 0; }