From 98b8cd66ab707cee579e59ad0632529083902e31 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sun, 7 Jul 2024 19:14:09 +0800 Subject: [PATCH] os_bsd.cpp: fix vm_statistics --- hotspot/src/os/bsd/vm/os_bsd.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git hotspot/src/os/bsd/vm/os_bsd.cpp hotspot/src/os/bsd/vm/os_bsd.cpp index 6d1009b84c..5bc3693334 100644 --- hotspot/src/os/bsd/vm/os_bsd.cpp +++ hotspot/src/os/bsd/vm/os_bsd.cpp @@ -112,6 +112,7 @@ # include # include # include +# include #endif #ifndef MAP_ANONYMOUS @@ -171,12 +172,21 @@ julong os::available_memory() { julong os::Bsd::available_memory() { uint64_t available = physical_memory() >> 2; #ifdef __APPLE__ +#if defined __ppc__ || defined __i386__ + mach_msg_type_number_t count = HOST_VM_INFO_COUNT; + vm_statistics_data_t vmstat; + kern_return_t kerr = host_statistics(mach_host_self(), HOST_VM_INFO, + (host_info_t)&vmstat, &count); + assert(kerr == KERN_SUCCESS, + "host_statistics failed - check mach_host_self() and count"); +#else // 64-bit mach_msg_type_number_t count = HOST_VM_INFO64_COUNT; vm_statistics64_data_t vmstat; kern_return_t kerr = host_statistics64(mach_host_self(), HOST_VM_INFO64, (host_info64_t)&vmstat, &count); assert(kerr == KERN_SUCCESS, "host_statistics64 failed - check mach_host_self() and count"); +#endif if (kerr == KERN_SUCCESS) { available = vmstat.free_count * os::vm_page_size(); }