mirror of https://git.FreeBSD.org/ports.git
openjdk: remove need for fdescfs(5) and probably procfs(5)
Implement getCommittedVirtualMemorySize() directly using sysctl kern.proc.vmmap Implement getOpenFileDescriptorCount() directly using sysctl kern.proc.nfds Note on openjdk17 use closefrom where possible (note this use case is only in openjdk 17, 21, 23 and 24) Remove the message about the use of fdescfs(5) as this is not needed for sure, keep the information about procfs(5) as I have not analysed enough the source code to make sure it is not used anywhere else, but I don't think it is.
This commit is contained in:
parent
8fdc28d864
commit
3a407ba074
|
@ -1,6 +1,7 @@
|
|||
PORTNAME= openjdk
|
||||
DISTVERSIONPREFIX= jdk-
|
||||
DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION}
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= java devel
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
--- src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c.orig 2025-04-19 23:57:10 UTC
|
||||
+++ src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -261,23 +262,43 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -487,6 +508,21 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent64* dentp;
|
|
@ -1,17 +1,15 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation may require fdescfs(5) mounted on /dev/fd
|
||||
and procfs(5) mounted on /proc for some applications.
|
||||
This OpenJDK implementation may require procfs(5) mounted on /proc for some
|
||||
applications.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
PORTNAME= openjdk
|
||||
DISTVERSIONPREFIX= jdk-
|
||||
DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION}
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= java devel
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
--- src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c.orig 2025-06-27 12:18:08 UTC
|
||||
+++ src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c
|
||||
@@ -70,6 +70,9 @@ closeDescriptors(void)
|
||||
int
|
||||
closeDescriptors(void)
|
||||
{
|
||||
+#if defined(__FreeBSD__)
|
||||
+ closefrom(STDERR_FILENO + 1);
|
||||
+#else
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
/* leave out standard input/output/error descriptors */
|
||||
@@ -114,6 +117,7 @@ closeDescriptors(void)
|
||||
|
||||
(void)closedir(dp);
|
||||
|
||||
+#endif
|
||||
return 1; // success
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
--- src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c.orig 2025-04-19 18:17:03 UTC
|
||||
+++ src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -178,23 +179,45 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ /* if (kve->kve_type != KVME_TYPE_VNODE)
|
||||
+ continue;*/
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -404,6 +427,21 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent* dentp;
|
|
@ -1,17 +1,15 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation may require fdescfs(5) mounted on /dev/fd
|
||||
and procfs(5) mounted on /proc for some applications.
|
||||
This OpenJDK implementation may require procfs(5) mounted on /proc for some
|
||||
applications.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PORTNAME= openjdk
|
||||
DISTVERSIONPREFIX= jdk-
|
||||
DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION}
|
||||
PORTREVISION= 2
|
||||
PORTREVISION= 3
|
||||
CATEGORIES= java devel
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
--- src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c.orig 2022-07-20 22:54:48 UTC
|
||||
+++ src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -178,23 +179,43 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -404,6 +425,21 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent* dentp;
|
|
@ -1,17 +1,15 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation may require fdescfs(5) mounted on /dev/fd
|
||||
and procfs(5) mounted on /proc for some applications.
|
||||
This OpenJDK implementation may require procfs(5) mounted on /proc for some
|
||||
applications.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PORTNAME= openjdk
|
||||
DISTVERSIONPREFIX= jdk-
|
||||
DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION}
|
||||
PORTREVISION= 1
|
||||
PORTREVISION= 2
|
||||
CATEGORIES= java devel
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
--- src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c.orig 2022-07-20 22:54:48 UTC
|
||||
+++ src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -178,23 +179,43 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -404,6 +425,21 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent* dentp;
|
|
@ -1,17 +1,15 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation may require fdescfs(5) mounted on /dev/fd
|
||||
and procfs(5) mounted on /proc for some applications.
|
||||
This OpenJDK implementation may require procfs(5) mounted on /proc for some
|
||||
applications.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
PORTNAME= openjdk
|
||||
DISTVERSIONPREFIX= jdk-
|
||||
DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION}
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= java devel
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
--- src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c.orig 2023-10-01 03:54:04 UTC
|
||||
+++ src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -177,23 +178,43 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -403,6 +424,21 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent* dentp;
|
|
@ -1,17 +1,15 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation may require fdescfs(5) mounted on /dev/fd
|
||||
and procfs(5) mounted on /proc for some applications.
|
||||
This OpenJDK implementation may require procfs(5) mounted on /proc for some
|
||||
applications.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ DISTVERSIONPREFIX= jdk-
|
|||
DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION}
|
||||
CATEGORIES= java devel
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
PORTREVISION= 1
|
||||
|
||||
MAINTAINER= java@FreeBSD.org
|
||||
COMMENT?= Java Development Kit ${JDK_MAJOR_VERSION}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
--- src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c.orig 2025-06-27 12:18:08 UTC
|
||||
+++ src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c
|
||||
@@ -70,6 +70,9 @@ closeDescriptors(void)
|
||||
int
|
||||
closeDescriptors(void)
|
||||
{
|
||||
+#if defined(__FreeBSD__)
|
||||
+ closefrom(STDERR_FILENO + 1);
|
||||
+#else
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
/* leave out standard input/output/error descriptors */
|
||||
@@ -114,6 +117,7 @@ closeDescriptors(void)
|
||||
|
||||
(void)closedir(dp);
|
||||
|
||||
+#endif
|
||||
return 1; // success
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
--- src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c.orig 2023-10-01 03:54:04 UTC
|
||||
+++ src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -177,23 +178,43 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -403,6 +424,21 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent* dentp;
|
|
@ -1,17 +1,15 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation may require fdescfs(5) mounted on /dev/fd
|
||||
and procfs(5) mounted on /proc for some applications.
|
||||
This OpenJDK implementation may require procfs(5) mounted on /proc for some
|
||||
applications.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
PORTNAME= openjdk
|
||||
DISTVERSIONPREFIX= jdk-
|
||||
DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION}
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= java devel
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
--- src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c.orig 2023-10-01 03:54:04 UTC
|
||||
+++ src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -177,23 +178,43 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -403,6 +424,21 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent* dentp;
|
|
@ -1,17 +1,15 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation may require fdescfs(5) mounted on /dev/fd
|
||||
and procfs(5) mounted on /proc for some applications.
|
||||
This OpenJDK implementation may require procfs(5) mounted on /proc for some
|
||||
applications.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ DISTVERSIONPREFIX= jdk-
|
|||
DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION}
|
||||
CATEGORIES= java devel
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
PORTREVISION= 1
|
||||
PORTREVISION= 2
|
||||
|
||||
MAINTAINER= java@FreeBSD.org
|
||||
COMMENT= Java Development Kit ${JDK_MAJOR_VERSION}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
--- src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c.orig 2025-06-27 12:18:08 UTC
|
||||
+++ src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c
|
||||
@@ -70,6 +70,9 @@ closeDescriptors(void)
|
||||
int
|
||||
closeDescriptors(void)
|
||||
{
|
||||
+#if defined(__FreeBSD__)
|
||||
+ closefrom(STDERR_FILENO + 1);
|
||||
+#else
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
/* leave out standard input/output/error descriptors */
|
||||
@@ -114,6 +117,7 @@ closeDescriptors(void)
|
||||
|
||||
(void)closedir(dp);
|
||||
|
||||
+#endif
|
||||
return 1; // success
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
--- src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c.orig 2023-10-01 03:54:04 UTC
|
||||
+++ src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -177,23 +178,43 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -403,6 +424,21 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent* dentp;
|
|
@ -1,17 +1,14 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation requires fdescfs(5) mounted on /dev/fd and
|
||||
procfs(5) mounted on /proc.
|
||||
This OpenJDK implementation may require procfs(5) mounted on /proc.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ DISTVERSIONPREFIX= jdk-
|
|||
DISTVERSION= ${JDK_MAJOR_VERSION}.${JDK_MINOR_VERSION}.${JDK_PATCH_VERSION}+${JDK_BUILD_NUMBER}-${BSD_JDK_VERSION}
|
||||
CATEGORIES= java devel
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
PORTREVISION= 1
|
||||
|
||||
MAINTAINER= java@FreeBSD.org
|
||||
COMMENT= Java Development Kit ${JDK_MAJOR_VERSION}
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
--- src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c.orig 2025-06-27 12:18:08 UTC
|
||||
+++ src/jdk.jdwp.agent/unix/native/libjdwp/exec_md.c
|
||||
@@ -70,6 +70,9 @@ closeDescriptors(void)
|
||||
int
|
||||
closeDescriptors(void)
|
||||
{
|
||||
+#if defined(__FreeBSD__)
|
||||
+ closefrom(STDERR_FILENO + 1);
|
||||
+#else
|
||||
DIR *dp;
|
||||
struct dirent *dirp;
|
||||
/* leave out standard input/output/error descriptors */
|
||||
@@ -114,6 +117,7 @@ closeDescriptors(void)
|
||||
|
||||
(void)closedir(dp);
|
||||
|
||||
+#endif
|
||||
return 1; // success
|
||||
}
|
||||
|
|
@ -0,0 +1,89 @@
|
|||
--- src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c.orig 2023-10-01 03:54:04 UTC
|
||||
+++ src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c
|
||||
@@ -58,6 +58,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -177,23 +178,43 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
-
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -403,6 +424,21 @@ Java_com_sun_management_internal_OperatingSystemImpl_g
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent* dentp;
|
|
@ -1,17 +1,14 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation requires fdescfs(5) mounted on /dev/fd and
|
||||
procfs(5) mounted on /proc.
|
||||
This OpenJDK implementation may requires procfs(5) mounted on /proc.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
PORTNAME= openjdk
|
||||
PORTVERSION= ${JDK_MAJOR_VERSION}.${JDK_UPDATE_VERSION}.${JDK_BUILD_NUMBER}.${BSD_JDK_VERSION}
|
||||
PORTREVISION= 1
|
||||
CATEGORIES= java devel
|
||||
MASTER_SITES= LOCAL/jkim:jtreg
|
||||
PKGNAMESUFFIX?= ${JDK_MAJOR_VERSION}
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
--- jdk/src/solaris/native/sun/management/OperatingSystemImpl.c.orig 2025-04-19 16:48:54 UTC
|
||||
+++ jdk/src/solaris/native/sun/management/OperatingSystemImpl.c
|
||||
@@ -57,6 +57,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#ifdef __FreeBSD__
|
||||
+#include <sys/user.h>
|
||||
#include <vm/vm_param.h>
|
||||
#endif
|
||||
|
||||
@@ -266,23 +267,45 @@ Java_sun_management_OperatingSystemImpl_getCommittedVi
|
||||
}
|
||||
return t_info.virtual_size;
|
||||
#elif defined(__FreeBSD__)
|
||||
- FILE *fp;
|
||||
- unsigned long end, start;
|
||||
- jlong total = 0;
|
||||
+ int mib[4];
|
||||
+ struct kinfo_vmentry *kve;
|
||||
+ long total = 0;
|
||||
+ size_t len = 0;
|
||||
+ int error;
|
||||
+ char *buf, *bp, *eb;
|
||||
|
||||
- if ((fp = fopen("/proc/curproc/map", "r")) == NULL) {
|
||||
- throw_internal_error(env, "Unable to open /proc/curproc/map");
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_VMMAP;
|
||||
+ mib[3] = getpid();
|
||||
+
|
||||
+ error = sysctl(mib, 4, NULL, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
return -1;
|
||||
}
|
||||
|
||||
- for (;;) {
|
||||
- // Ignore everything except start and end entries
|
||||
- if (fscanf(fp, "0x%lx 0x%lx %*[^\n]\n", &start, &end) != 2 || start > end)
|
||||
- break;
|
||||
- total += end - start;
|
||||
+ len = len * 4 / 3;
|
||||
+ buf = malloc(len);
|
||||
+ if (buf == NULL) {
|
||||
+ throw_internal_error(env, "Fail to allocate memory");
|
||||
+ return -1;
|
||||
}
|
||||
-
|
||||
- fclose(fp);
|
||||
+ error = sysctl(mib, 4, buf, &len, NULL, 0);
|
||||
+ if (error) {
|
||||
+ throw_internal_error(env, "Cannot sysctl(kern.proc.vvmap)");
|
||||
+ return -1;
|
||||
+ }
|
||||
+ bp = buf;
|
||||
+ eb = buf + len;
|
||||
+ while (bp < eb) {
|
||||
+ kve = (struct kinfo_vmentry *)(uintptr_t)bp;
|
||||
+ if (kve->kve_structsize == 0)
|
||||
+ break;
|
||||
+ bp += kve->kve_structsize;
|
||||
+ total += kve->kve_end - kve->kve_start;
|
||||
+ }
|
||||
+ free(buf);
|
||||
return total;
|
||||
#else /* _ALLBSD_SOURCE */
|
||||
/*
|
||||
@@ -486,6 +509,21 @@ Java_sun_management_OperatingSystemImpl_getOpenFileDes
|
||||
return nfiles;
|
||||
#elif defined(__OpenBSD__)
|
||||
return getdtablecount();
|
||||
+#elif defined(__FreeBSD__)
|
||||
+ int mib[4];
|
||||
+ int error;
|
||||
+ int nfds;
|
||||
+ size_t len;
|
||||
+
|
||||
+ len = sizeof(nfds);
|
||||
+ mib[0] = CTL_KERN;
|
||||
+ mib[1] = KERN_PROC;
|
||||
+ mib[2] = KERN_PROC_NFDS;
|
||||
+ mib[3] = 0;
|
||||
+
|
||||
+ if (sysctl(mib, 4, &nfds, &len, NULL, 0) == -1)
|
||||
+ return -1;
|
||||
+ return nfds;
|
||||
#else /* solaris/linux */
|
||||
DIR *dirp;
|
||||
struct dirent dbuf;
|
|
@ -1,17 +1,15 @@
|
|||
[
|
||||
{ type: install
|
||||
message: <<EOM
|
||||
This OpenJDK implementation may require fdescfs(5) mounted on /dev/fd
|
||||
and procfs(5) mounted on /proc for some applications.
|
||||
This OpenJDK implementation may require procfs(5) mounted on /proc for some
|
||||
applications.
|
||||
|
||||
If you have not done it yet, please do the following:
|
||||
|
||||
mount -t fdescfs fdesc /dev/fd
|
||||
mount -t procfs proc /proc
|
||||
|
||||
To make it permanent, you need the following lines in /etc/fstab:
|
||||
|
||||
fdesc /dev/fd fdescfs rw 0 0
|
||||
proc /proc procfs rw 0 0
|
||||
EOM
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue