win: return fractional seconds in uv_uptime() (#3455)
Some systems return fractional seconds, some return full seconds. On Windows uptime was artificially rounded down. Fixes #3447.
This commit is contained in:
parent
de24da8c11
commit
50c1d00839
@ -312,7 +312,7 @@ API
|
||||
|
||||
.. c:function:: int uv_uptime(double* uptime)
|
||||
|
||||
Gets the current system uptime.
|
||||
Gets the current system uptime. Depending on the system full or fractional seconds are returned.
|
||||
|
||||
.. c:function:: int uv_getrusage(uv_rusage_t* rusage)
|
||||
|
||||
|
||||
@ -608,8 +608,8 @@ int uv_uptime(double* uptime) {
|
||||
BYTE* address = (BYTE*) object_type + object_type->DefinitionLength +
|
||||
counter_definition->CounterOffset;
|
||||
uint64_t value = *((uint64_t*) address);
|
||||
*uptime = floor((double) (object_type->PerfTime.QuadPart - value) /
|
||||
(double) object_type->PerfFreq.QuadPart);
|
||||
*uptime = (double) (object_type->PerfTime.QuadPart - value) /
|
||||
(double) object_type->PerfFreq.QuadPart;
|
||||
uv__free(malloced_buffer);
|
||||
return 0;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user