Browse Source
Added idle time detection for macOS.
pull/2122/head
XMRig
3 years ago
No known key found for this signature in database
GPG Key ID: 446A53638BE94409
3 changed files with
13 additions and
5 deletions
-
CMakeLists.txt
-
src/base/kernel/Platform_mac.cpp
-
src/hw/dmi/dmi.cmake
|
|
@ -147,8 +147,10 @@ elseif (XMRIG_OS_APPLE) |
|
|
|
src/App_unix.cpp |
|
|
|
src/crypto/common/VirtualMemory_unix.cpp |
|
|
|
) |
|
|
|
|
|
|
|
find_library(IOKIT_LIBRARY IOKit) |
|
|
|
set(EXTRA_LIBS ${IOKIT_LIBRARY}) |
|
|
|
find_library(CORESERVICES_LIBRARY CoreServices) |
|
|
|
set(EXTRA_LIBS ${IOKIT_LIBRARY} ${CORESERVICES_LIBRARY}) |
|
|
|
else() |
|
|
|
list(APPEND SOURCES_OS |
|
|
|
src/App_unix.cpp |
|
|
|
|
|
@ -25,7 +25,6 @@ |
|
|
|
#include <uv.h> |
|
|
|
#include <thread> |
|
|
|
#include <fstream> |
|
|
|
#include <limits> |
|
|
|
|
|
|
|
|
|
|
|
#include "base/kernel/Platform.h" |
|
|
@ -112,5 +111,14 @@ bool xmrig::Platform::isOnBatteryPower() |
|
|
|
|
|
|
|
uint64_t xmrig::Platform::idleTime() |
|
|
|
{ |
|
|
|
return std::numeric_limits<uint64_t>::max(); |
|
|
|
uint64_t idle_time = 0; |
|
|
|
const auto service = IOServiceGetMatchingService(kIOMasterPortDefault, IOServiceMatching("IOHIDSystem")); |
|
|
|
const auto property = IORegistryEntryCreateCFProperty(service, CFSTR("HIDIdleTime"), kCFAllocatorDefault, 0); |
|
|
|
|
|
|
|
CFNumberGetValue((CFNumberRef)property, kCFNumberSInt64Type, &idle_time); |
|
|
|
|
|
|
|
CFRelease(property); |
|
|
|
IOObjectRelease(service); |
|
|
|
|
|
|
|
return idle_time / 1000000U; |
|
|
|
} |
|
|
|
|
|
@ -27,8 +27,6 @@ if (WITH_DMI) |
|
|
|
list(APPEND SOURCES src/hw/dmi/DmiReader_unix.cpp) |
|
|
|
elseif(XMRIG_OS_MACOS) |
|
|
|
list(APPEND SOURCES src/hw/dmi/DmiReader_mac.cpp) |
|
|
|
find_library(CORESERVICES_LIBRARY CoreServices) |
|
|
|
list(APPEND EXTRA_LIBS ${CORESERVICES_LIBRARY}) |
|
|
|
endif() |
|
|
|
else() |
|
|
|
remove_definitions(/DXMRIG_FEATURE_DMI) |
|
|
|