+#if defined(LINUX)
+ else if (BEGINS_WITH(walk + 1, "cpu")) {
+ int number = 0;
+ sscanf(walk + 1, "cpu%d", &number);
+ if (number < 0 || number >= cpu_count) {
+ fprintf(stderr, "provided CPU number '%d' above detected number of CPU %d\n", number, cpu_count);
+ } else {
+ int cpu_diff_idle = curr_cpus[number].idle - prev_cpus[number].idle;
+ int cpu_diff_total = curr_cpus[number].total - prev_cpus[number].total;
+ int cpu_diff_usage = (cpu_diff_total ? (1000 * (cpu_diff_total - cpu_diff_idle) / cpu_diff_total + 5) / 10 : 0);
+ outwalk += sprintf(outwalk, "%02d%s", cpu_diff_usage, pct_mark);
+ }
+ int padding = 1;
+ int step = 10;
+ while (step < number) {
+ step *= 10;
+ padding++;
+ }
+ walk += strlen("cpu") + padding;
+ }
+#endif
+ else {
+ *(outwalk++) = '%';
+ }