MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / getCpuDescription

Method getCpuDescription

src/os_linux.cpp:329–349  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

327}
328
329bool 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
351int OS::getCpuCount() {
352 return sysconf(_SC_NPROCESSORS_ONLN);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected