0
0
mirror of https://github.com/termux/termux-packages.git synced 2024-12-11 23:00:52 +00:00
termux-packages/packages/openjdk-21/0029-os-linux-add-getloadavg-implementation-for-android.patch
eval Nya 940a37f5f0 addpkg(main/openjdk-21): 21.0.3-ga
cherry-pick all patches, apply them on upstream JDK, and adapted for
newer $UPDATE version

fix: type redefinition introduced in 21.0.2
2024-10-17 14:02:06 +02:00

38 lines
1.1 KiB
Diff

From aea37453514b2fbb4dcd7d000e152e0f7cc9ceb8 Mon Sep 17 00:00:00 2001
From: Henrik Grimler <grimler@termux.dev>
Date: Sun, 5 Feb 2023 09:14:50 +0100
Subject: [PATCH 29/37] 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 95f808a59..d8a460519 100644
--- a/src/hotspot/os/linux/os_linux.cpp
+++ b/src/hotspot/os/linux/os_linux.cpp
@@ -5271,7 +5271,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.45.2