Skip to content

Commit

Permalink
#1652: remove win XP code path checking avilability of GetTickCount64
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Jan 11, 2020
1 parent 3880e3f commit 4526fb1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
14 changes: 8 additions & 6 deletions psutil/_psutil_common.c
Expand Up @@ -281,14 +281,16 @@ psutil_loadlibs() {
"ntdll", "RtlNtStatusToDosErrorNoTeb");
if (! RtlNtStatusToDosErrorNoTeb)
return 1;

// --- Optional
// not available on Wine
RtlIpv6AddressToStringA = psutil_GetProcAddressFromLib(
"ntdll.dll", "RtlIpv6AddressToStringA");
// minimum requirement: Win Vista
GetTickCount64 = psutil_GetProcAddress(
"kernel32", "GetTickCount64");
if (! GetTickCount64)
return 1;
RtlIpv6AddressToStringA = psutil_GetProcAddressFromLib(
"ntdll.dll", "RtlIpv6AddressToStringA");
if (! RtlIpv6AddressToStringA)
return 1;

// --- Optional
// minimum requirement: Win 7
GetActiveProcessorCount = psutil_GetProcAddress(
"kernel32", "GetActiveProcessorCount");
Expand Down
12 changes: 1 addition & 11 deletions psutil/_psutil_windows.c
Expand Up @@ -101,17 +101,7 @@ psutil_boot_time(PyObject *self, PyObject *args) {
ll = (((ULONGLONG)
(fileTime.dwHighDateTime)) << 32) + fileTime.dwLowDateTime;
pt = (time_t)((ll - 116444736000000000ull) / 10000000ull);

if (GetTickCount64 != NULL) {
// Windows >= Vista
uptime = GetTickCount64() / 1000ull;
}
else {
// Windows XP.
// GetTickCount() time will wrap around to zero if the
// system is run continuously for 49.7 days.
uptime = (ULONGLONG)GetTickCount() / 1000ull;
}
uptime = GetTickCount64() / 1000ull;
return Py_BuildValue("K", pt - uptime);
}

Expand Down

0 comments on commit 4526fb1

Please sign in to comment.