openjdk-17: use dlopen

android_mallopt seems not availabke in API 24 libc
This commit is contained in:
Leonid Pliushch 2021-07-30 15:24:57 +03:00
parent 4ad7c66215
commit da13243aa0
No known key found for this signature in database
GPG Key ID: 45F2964132545795

View File

@ -1,34 +1,36 @@
diff -uNr mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/share/native/libjli/java.c mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/share/native/libjli/java.c
--- mobile-ec285598849a27f681ea6269342cf03cf382eb56/src/java.base/share/native/libjli/java.c 2021-07-06 14:29:24.000000000 +0300
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/share/native/libjli/java.c 2021-07-30 13:28:40.900486911 +0300
@@ -50,7 +50,7 @@
* the CreateExecutionEnviroment will remove the -d<n> flags.
*/
-
+#include <stdbool.h>
+++ mobile-ec285598849a27f681ea6269342cf03cf382eb56.mod/src/java.base/share/native/libjli/java.c 2021-07-30 15:23:39.352949077 +0300
@@ -54,6 +54,24 @@
#include "java.h"
#include "jni.h"
@@ -219,6 +219,10 @@
#define STACK_SIZE_MINIMUM (64 * KB)
#endif
+#ifdef __TERMUX__
+extern bool android_mallopt(int opcode, void* arg, size_t arg_size);
+#include <stdbool.h>
+#include <dlfcn.h>
+static void android_disable_tags() {
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
+ if (lib_handle) {
+ bool (*android_mallopt)(int opcode, void* arg, size_t arg_size) = dlsym(lib_handle, "android_mallopt");
+ if (android_mallopt) {
+ int android_malloc_tag_level = 0;
+ android_mallopt(8, &android_malloc_tag_level, sizeof(android_malloc_tag_level));
+ }
+ dlclose(lib_handle);
+ }
+}
+#else
+static void android_disable_tags(){}
+#endif
+
/*
* Entry point.
*/
@@ -252,6 +256,11 @@
* A NOTE TO DEVELOPERS: For performance reasons it is important that
* the program image remain relatively small until after SelectVersion
@@ -252,6 +270,8 @@
_is_java_args = javaargs;
_wc_enabled = cpwildcard;
+#ifdef __TERMUX__
+ int android_malloc_tag_level = 0;
+ android_mallopt(8, &android_malloc_tag_level, sizeof(android_malloc_tag_level));
+#endif
+ android_disable_tags();
+
InitLauncher(javaw);
DumpState();