diff --git a/configure.ac b/configure.ac index 8ba787823..8b9f4ecd6 100644 --- a/configure.ac +++ b/configure.ac @@ -331,20 +331,9 @@ if test "$my_htop_platform" = darwin; then AC_CHECK_DECLS([IOMainPort], [], [], [[#include ]]) AC_CHECK_DECLS([IOMasterPort], [], [], [[#include ]]) - AC_MSG_CHECKING([for vm_statistics64 supported]) - AC_COMPILE_IFELSE([ - AC_LANG_PROGRAM([[ -#include -#include - ]], [[ - mach_msg_type_number_t info_size = HOST_VM_INFO64_COUNT; - vm_statistics64_data_t vm_stat; - host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t)&vm_stat, &info_size); - ]] - )], - AC_DEFINE([HAVE_VM_STATISTICS64], 1, [The vm_statistics64 features is supported.]) - AC_MSG_RESULT(yes), - AC_MSG_RESULT(no)) + AC_CHECK_FUNCS([host_statistics64], [ + AC_CHECK_TYPES([struct vm_statistics64], [], [], [[#include ]]) + ], [], [[#include ]]) fi if test "$my_htop_platform" = pcp; then diff --git a/darwin/DarwinMachine.c b/darwin/DarwinMachine.c index fff738832..7aba9c8f5 100644 --- a/darwin/DarwinMachine.c +++ b/darwin/DarwinMachine.c @@ -60,7 +60,7 @@ static unsigned DarwinMachine_allocateCPULoadInfo(processor_cpu_load_info_t* p) } static void DarwinMachine_getVMStats(DarwinMachine* this) { -#ifdef HAVE_VM_STATISTICS64 +#ifdef HAVE_STRUCT_VM_STATISTICS64 mach_msg_type_number_t info_size = HOST_VM_INFO64_COUNT; if (host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info_t)&this->vm_stats, &info_size) != 0) { diff --git a/darwin/DarwinMachine.h b/darwin/DarwinMachine.h index 70cb55528..a4ca1a02e 100644 --- a/darwin/DarwinMachine.h +++ b/darwin/DarwinMachine.h @@ -18,7 +18,7 @@ typedef struct DarwinMachine_ { Machine super; host_basic_info_data_t host_info; -#ifdef HAVE_VM_STATISTICS64 +#ifdef HAVE_STRUCT_VM_STATISTICS64 vm_statistics64_data_t vm_stats; #else vm_statistics_data_t vm_stats; diff --git a/darwin/Platform.c b/darwin/Platform.c index 4b7ff646a..543615d74 100644 --- a/darwin/Platform.c +++ b/darwin/Platform.c @@ -292,7 +292,7 @@ double Platform_setCPUValues(Meter* mtr, unsigned int cpu) { void Platform_setMemoryValues(Meter* mtr) { const DarwinMachine* dhost = (const DarwinMachine*) mtr->host; -#ifdef HAVE_VM_STATISTICS64 +#ifdef HAVE_STRUCT_VM_STATISTICS64 const struct vm_statistics64* vm = &dhost->vm_stats; #else const struct vm_statistics* vm = &dhost->vm_stats; @@ -300,7 +300,7 @@ void Platform_setMemoryValues(Meter* mtr) { double page_K = (double)vm_page_size / (double)1024; mtr->total = dhost->host_info.max_mem / 1024; -#ifdef HAVE_VM_STATISTICS64 +#ifdef HAVE_STRUCT_VM_STATISTICS64 natural_t used = vm->active_count + vm->inactive_count + vm->speculative_count + vm->wire_count + vm->compressor_page_count - vm->purgeable_count - vm->external_page_count; @@ -309,7 +309,7 @@ void Platform_setMemoryValues(Meter* mtr) { mtr->values[MEMORY_METER_USED] = (double)(vm->active_count + vm->wire_count) * page_K; #endif // mtr->values[MEMORY_METER_SHARED] = "shared memory, like tmpfs and shm" -#ifdef HAVE_VM_STATISTICS64 +#ifdef HAVE_STRUCT_VM_STATISTICS64 mtr->values[MEMORY_METER_COMPRESSED] = (double)vm->compressor_page_count * page_K; #else // mtr->values[MEMORY_METER_COMPRESSED] = "compressed memory, like zswap on linux"