--- old/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c 2020-05-20 18:03:36.322227327 -0700 +++ new/src/jdk.management/unix/native/libmanagement_ext/OperatingSystemImpl.c 2020-05-20 18:03:35.934219877 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,63 +85,7 @@ // true = get available swap in bytes // false = get total swap in bytes static jlong get_total_or_available_swap_space_size(JNIEnv* env, jboolean available) { -#ifdef __solaris__ - long total, avail; - int nswap, i, count; - swaptbl_t *stbl; - char *strtab; - - // First get the number of swap resource entries - if ((nswap = swapctl(SC_GETNSWP, NULL)) == -1) { - throw_internal_error(env, "swapctl failed to get nswap"); - return -1; - } - if (nswap == 0) { - return 0; - } - - // Allocate storage for resource entries - stbl = (swaptbl_t*) malloc(nswap * sizeof(swapent_t) + - sizeof(struct swaptable)); - if (stbl == NULL) { - JNU_ThrowOutOfMemoryError(env, 0); - return -1; - } - - // Allocate storage for the table - strtab = (char*) malloc((nswap + 1) * MAXPATHLEN); - if (strtab == NULL) { - free(stbl); - JNU_ThrowOutOfMemoryError(env, 0); - return -1; - } - - for (i = 0; i < (nswap + 1); i++) { - stbl->swt_ent[i].ste_path = strtab + (i * MAXPATHLEN); - } - stbl->swt_n = nswap + 1; - - // Get the entries - if ((count = swapctl(SC_LIST, stbl)) < 0) { - free(stbl); - free(strtab); - throw_internal_error(env, "swapctl failed to get swap list"); - return -1; - } - - // Sum the entries to get total and free swap - total = 0; - avail = 0; - for (i = 0; i < count; i++) { - total += stbl->swt_ent[i].ste_pages; - avail += stbl->swt_ent[i].ste_free; - } - - free(stbl); - free(strtab); - return available ? ((jlong)avail * page_size) : - ((jlong)total * page_size); -#elif defined(__linux__) +#if defined(__linux__) int ret; FILE *fp; jlong total = 0, avail = 0; @@ -183,37 +127,7 @@ Java_com_sun_management_internal_OperatingSystemImpl_getCommittedVirtualMemorySize0 (JNIEnv *env, jobject mbean) { -#ifdef __solaris__ - psinfo_t psinfo; - ssize_t result; - size_t remaining; - char* addr; - int fd; - - fd = open64("/proc/self/psinfo", O_RDONLY, 0); - if (fd < 0) { - throw_internal_error(env, "Unable to open /proc/self/psinfo"); - return -1; - } - - addr = (char *)&psinfo; - for (remaining = sizeof(psinfo_t); remaining > 0;) { - result = read(fd, addr, remaining); - if (result < 0) { - if (errno != EINTR) { - close(fd); - throw_internal_error(env, "Unable to read /proc/self/psinfo"); - return -1; - } - } else { - remaining -= result; - addr += result; - } - } - - close(fd); - return (jlong) psinfo.pr_size * 1024; -#elif defined(__linux__) +#if defined(__linux__) FILE *fp; unsigned long vsize = 0; @@ -286,7 +200,7 @@ * BSDNOTE: FreeBSD implements _SC_CLK_TCK since FreeBSD 5, so * add a magic to handle it */ -#if defined(__solaris__) || defined(_SC_CLK_TCK) +#if defined(_SC_CLK_TCK) clk_tck = (jlong) sysconf(_SC_CLK_TCK); #elif defined(__linux__) || defined(_ALLBSD_SOURCE) clk_tck = 100;