0
0
mirror of https://github.com/termux/termux-packages.git synced 2025-08-07 01:02:05 +00:00
Files
termux-packages/packages/openjdk-17/0027-os-linux-add-getloadavg-implementation-for-android.patch
alexytomi 8d30dd9550 fix(openjdk-17): Readd deleted comments to commit message
Also regenerates for 17.0.16-ga
2025-07-23 00:33:24 -05:00

38 lines
1.1 KiB
Diff

From d2ce8690239f278f0e3c90c3f8a6e3a00700692e 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/41] 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 2637a1075d6..81b108c6169 100644
--- a/src/hotspot/os/linux/os_linux.cpp
+++ b/src/hotspot/os/linux/os_linux.cpp
@@ -5300,7 +5300,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
}
void os::pause() {
--
2.50.1