| 46 | */ |
| 47 | |
| 48 | static int checkCpuCount() { |
| 49 | for (int i = 0; i < 128; i++) { |
| 50 | char buf[64]; |
| 51 | memset(buf, 0, 64); |
| 52 | snprintf(buf, 63, "/sys/devices/system/cpu/cpu%d", i); |
| 53 | |
| 54 | DIR *d = opendir(buf); |
| 55 | if (d) { |
| 56 | closedir(d); |
| 57 | } else { |
| 58 | return i; |
| 59 | } |
| 60 | } |
| 61 | return 0; |
| 62 | } |
| 63 | |
| 64 | const static int CPU_COUNT = checkCpuCount(); |
| 65 | const static uint32_t STAT_USER_JIFFIES_INDEX = 13; |