-
-
Notifications
You must be signed in to change notification settings - Fork 456
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
darwin: fix conversion from nano-seconds to centi-seconds
Fixes: #1619
- Loading branch information
1 parent
802494f
commit 9944d55
Showing
1 changed file
with
1 addition
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -275,13 +275,6 @@ static void DarwinProcess_updateCmdLine(const struct kinfo_proc* k, Process* pro | |
Process_updateCmdline(proc, k->kp_proc.p_comm, 0, strlen(k->kp_proc.p_comm)); | ||
} | ||
|
||
// Converts nanoseconds to hundredths of a second (centiseconds) as needed by the "time" field of the Process struct. | ||
static long long int nanosecondsToCentiseconds(uint64_t nanoseconds) { | ||
const uint64_t centiseconds_per_second = 100; | ||
const uint64_t nanoseconds_per_second = 1e9; | ||
return nanoseconds / nanoseconds_per_second * centiseconds_per_second; | ||
} | ||
|
||
static char* DarwinProcess_getDevname(dev_t dev) { | ||
if (dev == NODEV) { | ||
return NULL; | ||
|
@@ -391,7 +384,7 @@ void DarwinProcess_setFromLibprocPidinfo(DarwinProcess* proc, DarwinProcessTable | |
Process_updateCPUFieldWidths(proc->super.percent_cpu); | ||
|
||
proc->super.state = pti.pti_numrunning > 0 ? RUNNING : SLEEPING; | ||
proc->super.time = nanosecondsToCentiseconds(total_current_time_ns); | ||
proc->super.time = total_current_time_ns / 1e7; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
aestriplex
Author
Contributor
|
||
proc->super.nlwp = pti.pti_threadnum; | ||
proc->super.m_virt = pti.pti_virtual_size / ONE_K; | ||
proc->super.m_resident = pti.pti_resident_size / ONE_K; | ||
|
@aestriplex Maybe I was too late to review this one, but what the point of removing the
nanosecondsToCentiseconds
function?Isn't it more convenient to keep an inline function like this?
By the way, note the
(uint64_t)
cast, because we don't need a floating point devision for this.