0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-07-29 15:30:24 +00:00
Files
termux-packages/packages/openjdk-21/0027-os-linux-add-getloadavg-implementation-for-android.patch
alexytomi f1a75afe78 fix(openjdk-21): Readd deleted comments to commit message
Also regenerates for 21.0.8-ga
2025-07-23 00:33:24 -05:00

38 lines
1.1 KiB
Diff

From 1a01c1a1ea8339544e1e4dfc58d81d801180a55d Mon Sep 17 00:00:00 2001
From: Henrik Grimler <grimler@termux.dev>
Date: Sun, 5 Feb 2023 09:14:50 +0100
Subject: [PATCH 27/40] os: linux: add getloadavg implementation for android
---
src/hotspot/os/linux/os_linux.cpp | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
index c5403225fd6..850ec2a594c 100644
--- a/src/hotspot/os/linux/os_linux.cpp
+++ b/src/hotspot/os/linux/os_linux.cpp
@@ -5373,7 +5373,20 @@ bool os::is_thread_cpu_time_supported() {
// Linux doesn't yet have a (official) notion of processor sets,
// so just return the system wide load average.
int os::loadavg(double loadavg[], int nelem) {
+#if defined(__ANDROID__) && __ANDROID_API__ < 29
+ if (nelem < 0) return -1;
+ if (nelem > 3) nelem = 3;
+
+ struct sysinfo si;
+ if (sysinfo(&si) == -1) return -1;
+
+ for (int i = 0; i < nelem; ++i) {
+ loadavg[i] = (double)(si.loads[i]) / (double)(1 << SI_LOAD_SHIFT);
+ }
+ return nelem;
+#else
return ::getloadavg(loadavg, nelem);
+#endif
}
// Get the default path to the core file
--
2.50.1