| 327 | } |
| 328 | |
| 329 | bool OS::getCpuDescription(char* buf, size_t size) { |
| 330 | int fd = open("/proc/cpuinfo", O_RDONLY); |
| 331 | if (fd == -1) { |
| 332 | return false; |
| 333 | } |
| 334 | |
| 335 | ssize_t r = read(fd, buf, size); |
| 336 | close(fd); |
| 337 | if (r <= 0) { |
| 338 | return false; |
| 339 | } |
| 340 | buf[r < size ? r : size - 1] = 0; |
| 341 | |
| 342 | char* c; |
| 343 | do { |
| 344 | c = strchr(buf, '\n'); |
| 345 | } while (c != NULL && *(buf = c + 1) != '\n'); |
| 346 | |
| 347 | *buf = 0; |
| 348 | return true; |
| 349 | } |
| 350 | |
| 351 | int OS::getCpuCount() { |
| 352 | return sysconf(_SC_NPROCESSORS_ONLN); |
nothing calls this directly
no outgoing calls
no test coverage detected