| 361 | } |
| 362 | |
| 363 | u64 OS::getTotalCpuTime(u64* utime, u64* stime) { |
| 364 | int fd = open("/proc/stat", O_RDONLY); |
| 365 | if (fd == -1) { |
| 366 | return (u64)-1; |
| 367 | } |
| 368 | |
| 369 | u64 real = (u64)-1; |
| 370 | char buf[128] = {0}; |
| 371 | if (read(fd, buf, sizeof(buf)) >= 12) { |
| 372 | u64 user, nice, system, idle; |
| 373 | if (sscanf(buf + 4, "%llu %llu %llu %llu", &user, &nice, &system, &idle) == 4) { |
| 374 | *utime = user + nice; |
| 375 | *stime = system; |
| 376 | real = user + nice + system + idle; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | close(fd); |
| 381 | return real; |
| 382 | } |
| 383 | |
| 384 | int OS::createMemoryFile(const char* name) { |
| 385 | return syscall(__NR_memfd_create, name, 0); |
nothing calls this directly
no outgoing calls
no test coverage detected