diff options
author | Jung-uk Kim <jkim@FreeBSD.org> | 2012-10-19 22:43:10 +0000 |
---|---|---|
committer | Jung-uk Kim <jkim@FreeBSD.org> | 2012-10-19 22:43:10 +0000 |
commit | 81a8a55b63815f66e325d8ba0051a10e48f90bd1 (patch) | |
tree | 583a72c17d448ec15fd905bf3467d0378376c4de /java/openjdk6/files/patch-set | |
parent | Update to 7u9. (diff) |
- Add 2012/10/16 security patches from IcedTea6 1.11.5. [1]
http://icedtea.classpath.org/hg/release/icedtea6-1.11/rev/d9564350faa6
http://blog.fuseyism.com/index.php/2012/10/19/security-icedtea-1-10-10-1-11-15-2-1-3-2-2-3-2-3-3-released/
- Completely turn off parallel build by default and remove parallel build
hack for HotSpot. There were several reports that it fails to build under
certain environment, ports/162991 for example. Users can still do parallel
build by setting FORCE_MAKE_JOBS (and MAKE_JOBS_NUMBER if desired).
- Implement os::available_memory(). Now it is consistent with "vm.vmtotal"
sysctl(3) MIB rather than bogus (physical memory / 4).
- Prefer sysconf(_SC_NPROCESSORS_CONF) over HW_NCPU sysctl MIB to get the
number of installed processors. There is no functional difference except
for CURRENT, which obtains the information from ELF aux vector.
- Prefer sysconf(_SC_PHYS_PAGES) * sysconf(_SC_PAGESIZE) over HW_USERMEM
sysctl MIB to get size of physical memory. Although it looks more logical
to find currently available memory, it has an inevitable side-effect, i. e.,
it changes dynamically depending on current wired page count. Therefore,
it is unpredictable and not too useful some times. For example, launcher
uses the parameter to determine initial heap size and machine class for i386.
Now it is more consistent with other places (and Linux JDK/JREs, including
the ones we have in ports tree).
- Implement os::active_processor_count() using cpuset_getaffinity(2). For
example, Runtime.getRuntime().availableProcessors() now returns number of
available processors for the current process as it should.
- Sync. launchers (java_md.c) for HotSpot and JDK as much as possible for
maintainability. As a good side-effect, launcher for i386 can now determine
machine class based on the current hardware configuration. Previously,
client VM was always chosen by default.
- Fix CounterGet(), which is only used for debugging launcher.
- Add swap info for os::print_memory_info().
Obtained from: IcedTea project [1]
Feature safe: yes
Diffstat (limited to 'java/openjdk6/files/patch-set')
-rw-r--r-- | java/openjdk6/files/patch-set | 593 |
1 files changed, 452 insertions, 141 deletions
diff --git a/java/openjdk6/files/patch-set b/java/openjdk6/files/patch-set index 960b5c4eeb2f..d64c58204f17 100644 --- a/java/openjdk6/files/patch-set +++ b/java/openjdk6/files/patch-set @@ -4140,7 +4140,7 @@ # include <signal.h> # include <errno.h> # include <dlfcn.h> -@@ -102,21 +101,51 @@ +@@ -102,21 +101,57 @@ # include <sys/utsname.h> # include <sys/socket.h> # include <sys/wait.h> @@ -4166,6 +4166,12 @@ # include <sys/ioctl.h> +#ifdef __FreeBSD__ ++#if __FreeBSD_version > 700109 ++#include <bitset> ++#include <sys/cpuset.h> ++#endif ++#include <vm/swap_pager.h> ++#include <vm/vm_param.h> +#if __FreeBSD_version > 900030 +#include <pthread_np.h> +#else @@ -4193,7 +4199,7 @@ #define MAX_PATH (2 * K) // for timer info max values which include all bits -@@ -127,19 +156,25 @@ +@@ -127,19 +162,25 @@ // global variables julong os::Bsd::_physical_memory = 0; @@ -4219,7 +4225,7 @@ static jlong initial_time_count=0; -@@ -157,8 +192,6 @@ +@@ -157,8 +198,6 @@ static int SR_signum = SIGUSR2; sigset_t SR_sigset; @@ -4228,11 +4234,33 @@ //////////////////////////////////////////////////////////////////////////////// // utility functions -@@ -171,11 +204,16 @@ +@@ -171,11 +210,38 @@ } julong os::Bsd::available_memory() { +#ifdef _ALLBSD_SOURCE ++#ifdef __FreeBSD__ ++ static const char *vm_stats[] = { ++ "vm.stats.vm.v_free_count", ++ "vm.stats.vm.v_cache_count", ++ /* "vm.stats.vm.v_inactive_count", */ ++ NULL ++ }; ++ size_t size; ++ julong free_pages; ++ u_int i, npages; ++ ++ for (i = 0, free_pages = 0, size = sizeof(npages); vm_stats[i] != NULL; i++) { ++ if (sysctlbyname(vm_stats[i], &npages, &size, NULL, 0) == -1) { ++ free_pages = 0; ++ break; ++ } ++ free_pages += npages; ++ } ++ if (free_pages > 0) ++ free_pages *= os::vm_page_size(); ++ else ++#endif + // XXXBSD: this is just a stopgap implementation + return physical_memory() >> 2; +#else @@ -4245,7 +4273,7 @@ } julong os::physical_memory() { -@@ -223,6 +261,7 @@ +@@ -223,6 +289,7 @@ } @@ -4253,7 +4281,7 @@ #ifndef SYS_gettid // i386: 224, ia64: 1105, amd64: 186, sparc 143 #ifdef __ia64__ -@@ -237,6 +276,7 @@ +@@ -237,6 +304,7 @@ #error define gettid for the arch #endif #endif @@ -4261,7 +4289,7 @@ // Cpu architecture string #if defined(ZERO) -@@ -267,28 +307,58 @@ +@@ -267,28 +335,86 @@ // Returns the kernel thread id of the currently running thread. Kernel // thread id is used to access /proc. // @@ -4284,18 +4312,38 @@ + thr_self(&tid); + return (pid_t)tid; +#endif - } ++} +#endif - --// Most versions of bsd have a bug where the number of processors are --// determined by looking at the /proc file system. In a chroot environment, --// the system call returns 1. This causes the VM to act as if it is --// a single processor and elide locking (see is_MP() call). --static bool unsafe_chroot_detected = false; --static const char *unstable_chroot_error = "/proc file system not found.\n" -- "Java may be unstable running multithreaded in a chroot " -- "environment on Bsd when /proc filesystem is not mounted."; -+#ifdef _ALLBSD_SOURCE ++ ++#if defined(__FreeBSD__) ++void os::Bsd::initialize_system_info() { ++ int cpu_val = sysconf(_SC_NPROCESSORS_CONF); ++ if (cpu_val >= 1) ++ set_processor_count(cpu_val); ++ else ++ set_processor_count(1); // fallback ++ ++#ifdef _SC_PHYS_PAGES ++ long phys_pages = sysconf(_SC_PHYS_PAGES); ++ if (phys_pages > 0) ++ _physical_memory = (julong)phys_pages * _page_size; ++ else ++ _physical_memory = 256*1024*1024; // fallback (XXXBSD?) ++#else ++ int mib[2]; ++ size_t len; ++ u_long mem_val; ++ ++ mib[0] = CTL_HW; ++ mib[1] = HW_PHYSMEM; ++ len = sizeof(mem_val); ++ if (sysctl(mib, 2, &mem_val, &len, NULL, 0) != -1) ++ _physical_memory = mem_val; ++ else ++ _physical_memory = 256*1024*1024; // fallback (XXXBSD?) ++#endif + } ++#elif defined(_ALLBSD_SOURCE) +void os::Bsd::initialize_system_info() { + int mib[2]; + size_t len; @@ -4313,6 +4361,14 @@ + set_processor_count(1); // fallback + } +-// Most versions of bsd have a bug where the number of processors are +-// determined by looking at the /proc file system. In a chroot environment, +-// the system call returns 1. This causes the VM to act as if it is +-// a single processor and elide locking (see is_MP() call). +-static bool unsafe_chroot_detected = false; +-static const char *unstable_chroot_error = "/proc file system not found.\n" +- "Java may be unstable running multithreaded in a chroot " +- "environment on Bsd when /proc filesystem is not mounted."; + /* get physical memory via hw.usermem sysctl (hw.usermem is used + * instead of hw.physmem because we need size of allocatable memory + */ @@ -4323,7 +4379,7 @@ + _physical_memory = mem_val; + else + _physical_memory = 256*1024*1024; // fallback (XXXBSD?) -+ + +#ifdef __OpenBSD__ + { + // limit _physical_memory memory view on OpenBSD since @@ -4338,7 +4394,7 @@ void os::Bsd::initialize_system_info() { set_processor_count(sysconf(_SC_NPROCESSORS_CONF)); if (processor_count() == 1) { -@@ -305,6 +375,7 @@ +@@ -305,6 +431,7 @@ _physical_memory = (julong)sysconf(_SC_PHYS_PAGES) * (julong)sysconf(_SC_PAGESIZE); assert(processor_count() > 0, "bsd error"); } @@ -4346,7 +4402,7 @@ void os::init_system_properties_values() { // char arch[12]; -@@ -348,9 +419,7 @@ +@@ -348,9 +475,7 @@ * ... * 7: The default directories, normally /lib and /usr/lib. */ @@ -4357,7 +4413,7 @@ #define DEFAULT_LIBPATH "/lib:/usr/lib" #endif -@@ -429,7 +498,11 @@ +@@ -429,7 +554,11 @@ * should always exist (until the legacy problem cited above is * addressed). */ @@ -4369,7 +4425,7 @@ if (v != NULL) { char *t = ld_library_path; /* That's +1 for the colon and +1 for the trailing '\0' */ -@@ -588,6 +661,7 @@ +@@ -588,6 +717,7 @@ } } @@ -4377,7 +4433,7 @@ ////////////////////////////////////////////////////////////////////////////// // detecting pthread library -@@ -751,6 +825,7 @@ +@@ -751,6 +881,7 @@ } return false; } @@ -4385,7 +4441,7 @@ ////////////////////////////////////////////////////////////////////////////// // create new thread -@@ -759,6 +834,9 @@ +@@ -759,6 +890,9 @@ // check if it's safe to start a new thread static bool _thread_safety_check(Thread* thread) { @@ -4395,7 +4451,7 @@ if (os::Bsd::is_BsdThreads() && !os::Bsd::is_floating_stack()) { // Fixed stack BsdThreads (SuSE Bsd/x86, and some versions of Redhat) // Heap is mmap'ed at lower end of memory space. Thread stacks are -@@ -792,6 +870,7 @@ +@@ -792,6 +926,7 @@ // here, that means enough space has been reserved for stack. return true; } @@ -4403,7 +4459,7 @@ } // Thread start routine for all newly created threads -@@ -819,15 +898,22 @@ +@@ -819,15 +954,22 @@ return NULL; } @@ -4426,7 +4482,7 @@ // initialize signal mask for this thread os::Bsd::hotspot_sigmask(thread); -@@ -910,17 +996,22 @@ +@@ -910,17 +1052,22 @@ // let pthread_create() pick the default value. } @@ -4449,7 +4505,7 @@ pthread_t tid; int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread); -@@ -934,7 +1025,9 @@ +@@ -934,7 +1081,9 @@ // Need to clean up stuff we've allocated so far thread->set_osthread(NULL); delete osthread; @@ -4459,7 +4515,7 @@ return false; } -@@ -950,9 +1043,11 @@ +@@ -950,9 +1099,11 @@ } } @@ -4471,7 +4527,7 @@ } // Aborted due to thread limit being reached -@@ -990,7 +1085,11 @@ +@@ -990,7 +1141,11 @@ } // Store pthread info into the OSThread @@ -4483,7 +4539,7 @@ osthread->set_pthread_id(::pthread_self()); // initialize floating point control register -@@ -1001,6 +1100,7 @@ +@@ -1001,6 +1156,7 @@ thread->set_osthread(osthread); @@ -4491,7 +4547,7 @@ if (UseNUMA) { int lgrp_id = os::numa_get_group_id(); if (lgrp_id != -1) { -@@ -1027,6 +1127,7 @@ +@@ -1027,6 +1183,7 @@ os::Bsd::manually_expand_stack(jt, addr); osthread->clear_expanding_stack(); } @@ -4499,7 +4555,7 @@ // initialize signal mask for this thread // and save the caller's signal mask -@@ -1085,6 +1186,7 @@ +@@ -1085,6 +1242,7 @@ ////////////////////////////////////////////////////////////////////////////// // initial thread @@ -4507,7 +4563,7 @@ // Check if current thread is the initial thread, similar to Solaris thr_main. bool os::Bsd::is_initial_thread(void) { char dummy; -@@ -1321,6 +1423,7 @@ +@@ -1321,6 +1479,7 @@ _initial_thread_stack_size = align_size_down(_initial_thread_stack_size, page_size()); _initial_thread_stack_bottom = (address)stack_top - _initial_thread_stack_size; } @@ -4515,7 +4571,7 @@ //////////////////////////////////////////////////////////////////////////////// // time support -@@ -1342,9 +1445,7 @@ +@@ -1342,9 +1501,7 @@ return (1000 * 1000); } @@ -4526,7 +4582,7 @@ bool os::supports_vtime() { return false; } bool os::enable_vtime() { return false; } bool os::vtime_enabled() { return false; } -@@ -1364,6 +1465,21 @@ +@@ -1364,6 +1521,21 @@ #define CLOCK_MONOTONIC (1) #endif @@ -4548,7 +4604,7 @@ void os::Bsd::clock_init() { // we do dlopen's in this particular order due to bug in bsd // dynamical loader (see 6348968) leading to crash on exit -@@ -1399,7 +1515,9 @@ +@@ -1399,7 +1571,9 @@ } } } @@ -4558,7 +4614,7 @@ #ifndef SYS_clock_getres #if defined(IA32) || defined(AMD64) -@@ -1440,6 +1558,7 @@ +@@ -1440,6 +1614,7 @@ _pthread_getcpuclockid = pthread_getcpuclockid_func; } } @@ -4566,7 +4622,7 @@ jlong os::javaTimeNanos() { if (Bsd::supports_monotonic_clock()) { -@@ -1608,7 +1727,14 @@ +@@ -1608,7 +1783,14 @@ // DLL functions @@ -4582,7 +4638,7 @@ // This must be hard coded because it's the system's temporary // directory not the java application's temp directory, ala java.io.tmpdir. -@@ -1628,13 +1754,13 @@ +@@ -1628,13 +1810,13 @@ const size_t pnamelen = pname ? strlen(pname) : 0; // Quietly truncate on buffer overflow. Should be an error. @@ -4598,7 +4654,7 @@ } else if (strchr(pname, *os::path_separator()) != NULL) { int n; char** pelements = split_path(pname, &n); -@@ -1643,7 +1769,8 @@ +@@ -1643,7 +1825,8 @@ if (pelements[i] == NULL || strlen(pelements[i]) == 0) { continue; // skip the empty path values } @@ -4608,7 +4664,7 @@ if (file_exists(buffer)) { break; } -@@ -1658,7 +1785,7 @@ +@@ -1658,7 +1841,7 @@ FREE_C_HEAP_ARRAY(char*, pelements); } } else { @@ -4617,7 +4673,7 @@ } } -@@ -1708,6 +1835,23 @@ +@@ -1708,6 +1891,23 @@ return false; } @@ -4641,7 +4697,7 @@ struct _address_to_library_name { address addr; // input : memory address size_t buflen; // size of fname -@@ -1782,11 +1926,27 @@ +@@ -1782,11 +1982,27 @@ return false; } } @@ -4658,18 +4714,18 @@ + // Successful loading + return result; + } - ++ + // Read system error message into ebuf + ::strncpy(ebuf, ::dlerror(), ebuflen-1); + ebuf[ebuflen-1]='\0'; -+ + + return NULL; +} +#else void * os::dll_load(const char *filename, char *ebuf, int ebuflen) { void * result= ::dlopen(filename, RTLD_LAZY); -@@ -1839,6 +1999,26 @@ +@@ -1839,6 +2055,26 @@ #define EM_486 6 /* Intel 80486 */ #endif @@ -4696,7 +4752,7 @@ static const arch_t arch_array[]={ {EM_386, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"}, {EM_486, EM_386, ELFCLASS32, ELFDATA2LSB, (char*)"IA 32"}, -@@ -1942,17 +2122,11 @@ +@@ -1942,17 +2178,11 @@ return NULL; } @@ -4717,7 +4773,7 @@ } -@@ -1975,7 +2149,51 @@ +@@ -1975,7 +2205,51 @@ void os::print_dll_info(outputStream *st) { st->print_cr("Dynamic libraries:"); @@ -4770,7 +4826,7 @@ char fname[32]; pid_t pid = os::Bsd::gettid(); -@@ -1984,6 +2202,7 @@ +@@ -1984,6 +2258,7 @@ if (!_print_ascii_file(fname, st)) { st->print("Can not get library information for pid = %d\n", pid); } @@ -4778,7 +4834,7 @@ } -@@ -2018,6 +2237,7 @@ +@@ -2018,6 +2293,7 @@ st->print(name.machine); st->cr(); @@ -4786,7 +4842,7 @@ // Print warning if unsafe chroot environment detected if (unsafe_chroot_detected) { st->print("WARNING!! "); -@@ -2032,6 +2252,7 @@ +@@ -2032,6 +2308,7 @@ st->print("(%s stack)", os::Bsd::is_floating_stack() ? "floating" : "fixed"); } st->cr(); @@ -4794,7 +4850,7 @@ // rlimit st->print("rlimit:"); -@@ -2057,6 +2278,7 @@ +@@ -2057,6 +2334,7 @@ if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); else st->print("%d", rlim.rlim_cur); @@ -4802,7 +4858,7 @@ st->print(", AS "); getrlimit(RLIMIT_AS, &rlim); if (rlim.rlim_cur == RLIM_INFINITY) st->print("infinity"); -@@ -2069,11 +2291,7 @@ +@@ -2069,11 +2347,7 @@ os::loadavg(loadavg, 3); st->print("%0.02f %0.02f %0.02f", loadavg[0], loadavg[1], loadavg[2]); st->cr(); @@ -4815,11 +4871,29 @@ } void os::print_memory_info(outputStream* st) { -@@ -2081,18 +2299,27 @@ +@@ -2081,19 +2355,55 @@ st->print("Memory:"); st->print(" %dk page", os::vm_page_size()>>10); -+#ifndef _ALLBSD_SOURCE ++#ifdef _ALLBSD_SOURCE ++#ifdef __FreeBSD__ ++ struct xswdev xsw; ++ size_t mibsize, size; ++ int mib[16], n, total = 0, used = 0; ++ ++ mibsize = sizeof(mib) / sizeof(mib[0]); ++ if (sysctlnametomib("vm.swap_info", mib, &mibsize) != -1) { ++ for (n = 0; ; n++) { ++ mib[mibsize] = n; ++ size = sizeof(xsw); ++ if (sysctl(mib, mibsize + 1, &xsw, &size, NULL, 0) == -1) ++ break; ++ total += xsw.xsw_nblks; ++ used += xsw.xsw_used; ++ } ++ } ++#endif ++#else // values in struct sysinfo are "unsigned long" struct sysinfo si; sysinfo(&si); @@ -4829,7 +4903,14 @@ os::physical_memory() >> 10); st->print("(" UINT64_FORMAT "k free)", os::available_memory() >> 10); -+#ifndef _ALLBSD_SOURCE ++#ifdef _ALLBSD_SOURCE ++#ifdef __FreeBSD__ ++ st->print(", swap " UINT64_FORMAT "k", ++ ((jlong)total * os::vm_page_size()) >> 10); ++ st->print("(" UINT64_FORMAT "k free)", ++ ((jlong)(total - used) * os::vm_page_size()) >> 10); ++#endif ++#else st->print(", swap " UINT64_FORMAT "k", ((jlong)si.totalswap * si.mem_unit) >> 10); st->print("(" UINT64_FORMAT "k free)", @@ -4837,13 +4918,16 @@ +#endif + st->cr(); + ++#ifndef _ALLBSD_SOURCE + // meminfo + st->print("\n/proc/meminfo:\n"); + _print_ascii_file("/proc/meminfo", st); st->cr(); ++#endif } -@@ -2333,19 +2560,29 @@ + // Taken from /usr/include/bits/siginfo.h Supposed to be architecture specific +@@ -2333,19 +2643,29 @@ static volatile jint pending_signals[NSIG+1] = { 0 }; // Bsd(POSIX) specific hand shaking semaphore. @@ -4875,7 +4959,7 @@ } static int check_pending_signals(bool wait) { -@@ -2367,7 +2604,7 @@ +@@ -2367,7 +2687,7 @@ do { thread->set_suspend_equivalent(); // cleared by handle_special_suspend_equivalent_condition() or java_suspend_self() @@ -4884,7 +4968,7 @@ // were we externally suspended while we were waiting? threadIsSuspended = thread->handle_special_suspend_equivalent_condition(); -@@ -2378,7 +2615,7 @@ +@@ -2378,7 +2698,7 @@ // while suspended because that would surprise the thread that // suspended us. // @@ -4893,7 +4977,7 @@ thread->java_suspend_self(); } -@@ -2422,10 +2659,10 @@ +@@ -2422,10 +2742,10 @@ return; } @@ -4906,7 +4990,7 @@ os::get_temp_directory(), os::current_process_id(), num); unlink(buf); -@@ -2451,9 +2688,14 @@ +@@ -2451,9 +2771,14 @@ // problem. bool os::commit_memory(char* addr, size_t size, bool exec) { int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE; @@ -4921,7 +5005,7 @@ } bool os::commit_memory(char* addr, size_t size, size_t alignment_hint, -@@ -2469,36 +2711,27 @@ +@@ -2469,36 +2794,27 @@ } void os::numa_make_global(char *addr, size_t bytes) { @@ -4963,7 +5047,7 @@ } bool os::get_page_info(char *start, page_info* info) { -@@ -2509,6 +2742,7 @@ +@@ -2509,6 +2825,7 @@ return end; } @@ -4971,7 +5055,7 @@ extern "C" void numa_warn(int number, char *where, ...) { } extern "C" void numa_error(char *where) { } -@@ -2610,104 +2844,26 @@ +@@ -2610,104 +2927,26 @@ os::Bsd::numa_tonode_memory_func_t os::Bsd::_numa_tonode_memory; os::Bsd::numa_interleave_memory_func_t os::Bsd::_numa_interleave_memory; unsigned long* os::Bsd::_numa_all_nodes; @@ -5083,7 +5167,7 @@ return os::uncommit_memory(addr, size); } -@@ -2812,6 +2968,9 @@ +@@ -2812,6 +3051,9 @@ static size_t _large_page_size = 0; bool os::large_page_init() { @@ -5093,7 +5177,7 @@ if (!UseLargePages) return false; if (LargePageSizeInBytes) { -@@ -2869,6 +3028,7 @@ +@@ -2869,6 +3111,7 @@ // We optimistically assume the support is available. If later it turns out // not true, VM will automatically switch to use regular page size. return true; @@ -5101,7 +5185,7 @@ } #ifndef SHM_HUGETLB -@@ -3045,7 +3205,7 @@ +@@ -3045,7 +3288,7 @@ } size_t os::read(int fd, void *buf, unsigned int nBytes) { @@ -5110,7 +5194,7 @@ } // TODO-FIXME: reconcile Solaris' os::sleep with the bsd variation. -@@ -3181,6 +3341,44 @@ +@@ -3181,6 +3424,44 @@ // this reason, the code should not be used as default (ThreadPriorityPolicy=0). // It is only used when ThreadPriorityPolicy=1 and requires root privilege. @@ -5155,7 +5239,7 @@ int os::java_to_os_priority[MaxPriority + 1] = { 19, // 0 Entry should never be used -@@ -3198,6 +3396,7 @@ +@@ -3198,6 +3479,7 @@ -5 // 10 MaxPriority }; @@ -5163,7 +5247,7 @@ static int prio_init() { if (ThreadPriorityPolicy == 1) { -@@ -3217,8 +3416,28 @@ +@@ -3217,8 +3499,28 @@ OSReturn os::set_native_priority(Thread* thread, int newpri) { if ( !UseThreadPriorities || ThreadPriorityPolicy == 0 ) return OS_OK; @@ -5192,7 +5276,7 @@ } OSReturn os::get_native_priority(const Thread* const thread, int *priority_ptr) { -@@ -3228,7 +3447,17 @@ +@@ -3228,7 +3530,17 @@ } errno = 0; @@ -5210,7 +5294,7 @@ return (*priority_ptr != -1 || errno == 0 ? OS_OK : OS_ERR); } -@@ -3338,7 +3567,7 @@ +@@ -3338,7 +3650,7 @@ /* Get signal number to use for suspend/resume */ if ((s = ::getenv("_JAVA_SR_SIGNUM")) != 0) { int sig = ::strtol(s, 0, 10); @@ -5219,7 +5303,7 @@ SR_signum = sig; } } -@@ -3682,6 +3911,28 @@ +@@ -3682,6 +3994,28 @@ set_signal_handler(SIGFPE, true); set_signal_handler(SIGXFSZ, true); @@ -5248,7 +5332,7 @@ if (libjsig_is_loaded) { // Tell libjsig jvm finishes setting signal handlers (*end_signal_setting)(); -@@ -3702,6 +3953,7 @@ +@@ -3702,6 +4036,7 @@ } } @@ -5256,7 +5340,7 @@ // This is the fastest way to get thread cpu time on Bsd. // Returns cpu time (user+sys) for any thread, not only for current. // POSIX compliant clocks are implemented in the kernels 2.6.16+. -@@ -3716,6 +3968,7 @@ +@@ -3716,6 +4051,7 @@ return (tp.tv_sec * SEC_IN_NANOSECS) + tp.tv_nsec; } @@ -5264,7 +5348,7 @@ ///// // glibc on Bsd platform uses non-documented flag -@@ -3937,13 +4190,13 @@ +@@ -3937,13 +4273,13 @@ _initial_pid = (java_launcher_pid > 0) ? java_launcher_pid : getpid(); @@ -5280,7 +5364,7 @@ if (Bsd::page_size() == -1) { fatal(err_msg("os_bsd.cpp: os::init: sysconf failed (%s)", strerror(errno))); -@@ -3957,7 +4210,16 @@ +@@ -3957,7 +4293,16 @@ Bsd::clock_init(); initial_time_count = os::elapsed_counter(); @@ -5298,7 +5382,7 @@ } // To install functions for atexit system call -@@ -3970,7 +4232,9 @@ +@@ -3970,7 +4315,9 @@ // this is called _after_ the global arguments have been parsed jint os::init_2(void) { @@ -5308,7 +5392,7 @@ // Allocate a single page and mark it as readable for safepoint polling address polling_page = (address) ::mmap(NULL, Bsd::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); -@@ -4028,6 +4292,7 @@ +@@ -4028,6 +4375,7 @@ JavaThread::set_stack_size_at_create(round_to(threadStackSizeInBytes, vm_page_size())); @@ -5316,7 +5400,7 @@ Bsd::capture_initial_stack(JavaThread::stack_size_at_create()); Bsd::libpthread_init(); -@@ -4050,6 +4315,7 @@ +@@ -4050,6 +4398,7 @@ UseNUMA = true; } } @@ -5324,7 +5408,7 @@ if (MaxFDLimit) { // set the number of file descriptors to max. print out error -@@ -4061,6 +4327,14 @@ +@@ -4061,6 +4410,14 @@ perror("os::init_2 getrlimit failed"); } else { nbr_files.rlim_cur = nbr_files.rlim_max; @@ -5339,7 +5423,7 @@ status = setrlimit(RLIMIT_NOFILE, &nbr_files); if (status != 0) { if (PrintMiscellaneous && (Verbose || WizardMode)) -@@ -4069,8 +4343,10 @@ +@@ -4069,8 +4426,10 @@ } } @@ -5350,11 +5434,25 @@ // at-exit methods are called in the reverse order of their registration. // atexit functions are called on return from main or as a result of a -@@ -4114,11 +4390,15 @@ +@@ -4114,11 +4473,29 @@ }; int os::active_processor_count() { +#ifdef _ALLBSD_SOURCE ++#ifdef __FreeBSD__ ++ int online_cpus = 0; ++#if __FreeBSD_version > 700109 ++ std::bitset<CPU_SETSIZE> mask; ++ assert(sizeof(mask) == sizeof(cpuset_t), "Invalid bitset for cpuset_t"); ++ if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1, sizeof(mask), ++ reinterpret_cast<cpuset_t*>(&mask)) == 0) ++ online_cpus = mask.count(); ++#else ++ online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN); ++#endif ++ if (online_cpus > 0 && online_cpus <= _processor_count) ++ return online_cpus; ++#endif + return _processor_count; +#else // Bsd doesn't yet have a (official) notion of processor sets, @@ -5366,7 +5464,7 @@ } bool os::distribute_processes(uint length, uint* distribution) { -@@ -4160,6 +4440,9 @@ +@@ -4160,6 +4537,9 @@ int os::Bsd::safe_cond_timedwait(pthread_cond_t *_cond, pthread_mutex_t *_mutex, const struct timespec *_abstime) { @@ -5376,7 +5474,7 @@ if (is_NPTL()) { return pthread_cond_timedwait(_cond, _mutex, _abstime); } else { -@@ -4175,6 +4458,7 @@ +@@ -4175,6 +4555,7 @@ #endif // IA64 return status; } @@ -5384,7 +5482,7 @@ } //////////////////////////////////////////////////////////////////////////////// -@@ -4322,14 +4606,14 @@ +@@ -4322,14 +4703,14 @@ int o_delete = (oflag & O_DELETE); oflag = oflag & ~O_DELETE; @@ -5403,7 +5501,7 @@ if (ret != -1) { if ((st_mode & S_IFMT) == S_IFDIR) { -@@ -4386,17 +4670,17 @@ +@@ -4386,17 +4767,17 @@ if (!rewrite_existing) { oflags |= O_EXCL; } @@ -5424,7 +5522,7 @@ } // This code originates from JDK's sysAvailable -@@ -4405,10 +4689,10 @@ +@@ -4405,10 +4786,10 @@ int os::available(int fd, jlong *bytes) { jlong cur, end; int mode; @@ -5438,7 +5536,7 @@ if (S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode)) { /* * XXX: is the following call interruptible? If so, this might -@@ -4422,11 +4706,11 @@ +@@ -4422,11 +4803,11 @@ } } } @@ -5453,7 +5551,7 @@ return 0; } *bytes = end - cur; -@@ -4489,6 +4773,7 @@ +@@ -4489,6 +4870,7 @@ return munmap(addr, bytes) == 0; } @@ -5461,7 +5559,7 @@ static jlong slow_thread_cpu_time(Thread *thread, bool user_sys_cpu_time); static clockid_t thread_cpu_clockid(Thread* thread) { -@@ -4500,6 +4785,7 @@ +@@ -4500,6 +4882,7 @@ assert(rc == 0, "pthread_getcpuclockid is expected to return 0 code"); return clockid; } @@ -5469,7 +5567,7 @@ // current_thread_cpu_time(bool) and thread_cpu_time(Thread*, bool) // are used by JVM M&M and JVMTI to get user+sys or user CPU time -@@ -4509,39 +4795,71 @@ +@@ -4509,39 +4892,71 @@ // the fast estimate available on the platform. jlong os::current_thread_cpu_time() { @@ -5541,7 +5639,7 @@ // // -1 on error. // -@@ -4631,6 +4949,7 @@ +@@ -4631,6 +5046,7 @@ return (jlong)user_time * (1000000000 / clock_tics_per_sec); } } @@ -5549,21 +5647,21 @@ void os::current_thread_cpu_time_info(jvmtiTimerInfo *info_ptr) { info_ptr->max_value = ALL_64_BITS; // will not wrap in less than 64 bits -@@ -4647,7 +4966,13 @@ +@@ -4647,7 +5063,13 @@ } bool os::is_thread_cpu_time_supported() { +#ifdef __APPLE__ -+ return true; + return true; +#elif defined(_ALLBSD_SOURCE) + return false; +#else - return true; ++ return true; +#endif } // System loadavg support. Returns -1 if load average cannot be obtained. -@@ -4780,7 +5105,7 @@ +@@ -4780,7 +5202,7 @@ // abstime will be the absolute timeout time // TODO: replace compute_abstime() with unpackTime() @@ -5572,7 +5670,7 @@ if (millis < 0) millis = 0; struct timeval now; int status = gettimeofday(&now, NULL); -@@ -4832,7 +5157,7 @@ +@@ -4832,7 +5254,7 @@ status = pthread_cond_wait(_cond, _mutex); // for some reason, under 2.7 lwp_cond_wait() may return ETIME ... // Treat this the same as if the wait was interrupted @@ -5581,7 +5679,7 @@ assert_status(status == 0 || status == EINTR, status, "cond_wait"); } -- _nParked ; -@@ -4890,10 +5215,10 @@ +@@ -4890,10 +5312,10 @@ pthread_cond_init (_cond, NULL) ; } assert_status(status == 0 || status == EINTR || @@ -5594,7 +5692,7 @@ // We consume and ignore EINTR and spurious wakeups. } --_nParked ; -@@ -4985,7 +5310,7 @@ +@@ -4985,7 +5407,7 @@ * years from "now". */ @@ -5603,7 +5701,7 @@ assert (time > 0, "convertTime"); struct timeval now; -@@ -5045,7 +5370,7 @@ +@@ -5045,7 +5467,7 @@ } // Next, demultiplex/decode time arguments @@ -5612,7 +5710,7 @@ if (time < 0 || (isAbsolute && time == 0) ) { // don't wait at all return; } -@@ -5099,7 +5424,7 @@ +@@ -5099,7 +5521,7 @@ } } assert_status(status == 0 || status == EINTR || @@ -5621,7 +5719,7 @@ status, "cond_timedwait"); #ifdef ASSERT -@@ -5142,14 +5467,12 @@ +@@ -5142,14 +5564,12 @@ } @@ -5641,7 +5739,7 @@ #endif // Run the specified command in a separate process. Return its exit value, -@@ -5164,8 +5487,7 @@ +@@ -5164,8 +5584,7 @@ // separate process to execve. Make a direct syscall to fork process. // On IA64 there's no fork syscall, we have to use fork() and hope for // the best... @@ -5651,7 +5749,7 @@ if (pid < 0) { // fork failed -@@ -5181,8 +5503,7 @@ +@@ -5181,8 +5600,7 @@ // in the new process, so make a system call directly. // IA64 should use normal execve() from glibc to match the glibc fork() // above. @@ -5872,7 +5970,16 @@ os::fork_and_exec(buf); --- hotspot/src/os/posix/launcher/java_md.c +++ hotspot/src/os/posix/launcher/java_md.c -@@ -41,14 +41,21 @@ +@@ -35,20 +35,30 @@ + #include <sys/stat.h> + #include <unistd.h> + #include <sys/types.h> ++#ifndef _SC_PHYS_PAGES ++#include <sys/sysctl.h> ++#endif + + #ifndef GAMMA + #include "manifest_info.h" #include "version_comp.h" #endif @@ -5895,7 +6002,7 @@ #ifndef GAMMA /* launcher.make defines ARCH */ /* -@@ -89,7 +96,7 @@ +@@ -89,7 +99,7 @@ * A collection of useful strings. One should think of these as #define * entries, but actual strings can be more efficient (with many compilers). */ @@ -5904,7 +6011,7 @@ static const char *system_dir = "/usr/java"; static const char *user_dir = "/java"; #else /* Solaris */ -@@ -423,10 +430,10 @@ +@@ -423,10 +433,10 @@ * If not on Solaris, assume only a single LD_LIBRARY_PATH * variable. */ @@ -5917,7 +6024,7 @@ /* * On linux, if a binary is running as sgid or suid, glibc sets * LD_LIBRARY_PATH to the empty string for security purposes. (In -@@ -442,6 +449,22 @@ +@@ -442,6 +452,22 @@ if((getgid() != getegid()) || (getuid() != geteuid()) ) { return; } @@ -5940,7 +6047,7 @@ #endif /* runpath contains current effective LD_LIBRARY_PATH setting */ -@@ -450,7 +473,7 @@ +@@ -450,7 +476,7 @@ new_runpath = JLI_MemAlloc( ((runpath!=NULL)?strlen(runpath):0) + 2*strlen(jrepath) + 2*strlen(arch) + strlen(jvmpath) + 52); @@ -5949,7 +6056,7 @@ /* -@@ -465,7 +488,7 @@ +@@ -465,7 +491,7 @@ /* jvmpath, ((running != wanted)?((wanted==64)?"/"LIBARCH64NAME:"/.."):""), */ @@ -5958,7 +6065,16 @@ "%s:" "%s/lib/%s:" "%s/../lib/%s", -@@ -792,7 +815,7 @@ +@@ -503,7 +529,7 @@ + * LD_LIBRARY_PATH. Note that this prevents any possible infinite + * loop of execv() because we test for the prefix, above. + */ +- if (runpath != 0) { ++ if (runpath != 0 && runpath[0] != '\0') { + strcat(new_runpath, ":"); + strcat(new_runpath, runpath); + } +@@ -792,7 +818,7 @@ jboolean GetApplicationHome(char *buf, jint bufsize) { @@ -5967,7 +6083,7 @@ char *execname = GetExecname(); if (execname) { strncpy(buf, execname, bufsize-1); -@@ -961,9 +984,13 @@ +@@ -961,9 +987,13 @@ } } } @@ -5982,7 +6098,7 @@ char buf[PATH_MAX+1]; int len = readlink(self, buf, PATH_MAX); if (len >= 0) { -@@ -971,7 +998,7 @@ +@@ -971,7 +1001,7 @@ exec_path = JLI_StringDup(buf); } } @@ -5991,7 +6107,44 @@ { /* Not implemented */ } -@@ -1175,7 +1202,7 @@ +@@ -1069,6 +1099,7 @@ + /* Compute physical memory by asking the OS */ + uint64_t + physical_memory(void) { ++#ifdef _SC_PHYS_PAGES + const uint64_t pages = (uint64_t) sysconf(_SC_PHYS_PAGES); + const uint64_t page_size = (uint64_t) sysconf(_SC_PAGESIZE); + const uint64_t result = pages * page_size; +@@ -1080,6 +1111,28 @@ + " physical memory: " UINT64_FORMAT " (%.3fGB)\n", + pages, page_size, result, result / (double) GB); + } ++#else ++#ifdef HW_PHYSMEM64 ++ int64_t physmem; ++ int name[2] = { CTL_HW, HW_PHYSMEM64 }; ++#else ++ unsigned long physmem; ++ int name[2] = { CTL_HW, HW_PHYSMEM }; ++#endif ++ size_t physmem_len = sizeof(physmem); ++ uint64_t result; ++# define UINT64_FORMAT "%" PRIu64 ++ ++ if (sysctl(name, 2, &physmem, &physmem_len, NULL, 0) == -1) ++ physmem = 256 * MB; ++ ++ result = (uint64_t)physmem; ++ ++ if (_launcher_debug) { ++ printf("physical memory: " UINT64_FORMAT " (%.3fGB)\n", ++ result, result / (double) GB); ++ } ++#endif + return result; + } + +@@ -1175,7 +1228,7 @@ #endif /* __sun && i586 */ @@ -6000,7 +6153,7 @@ /* * A utility method for asking the CPU about itself. -@@ -1240,7 +1267,7 @@ +@@ -1240,7 +1293,7 @@ #endif } @@ -6009,7 +6162,7 @@ #ifdef i586 /* -@@ -1452,6 +1479,39 @@ +@@ -1452,6 +1505,39 @@ #endif /* __linux__ && i586 */ @@ -6038,7 +6191,7 @@ + } + } + if (_launcher_debug) { -+ printf("linux_" LIBARCHNAME "_ServerClassMachine: %s\n", ++ printf("bsd_" LIBARCHNAME "_ServerClassMachine: %s\n", + (result == JNI_TRUE ? "true" : "false")); + } + return result; @@ -6049,7 +6202,7 @@ /* Dispatch to the platform-specific definition of "server-class" */ jboolean ServerClassMachine(void) { -@@ -1466,6 +1526,8 @@ +@@ -1466,6 +1552,8 @@ result = solaris_i586_ServerClassMachine(); #elif defined(__linux__) && defined(i586) result = linux_i586_ServerClassMachine(); @@ -6058,7 +6211,16 @@ #else if (_launcher_debug) { printf("ServerClassMachine: returns default value of %s\n", -@@ -1821,7 +1883,7 @@ +@@ -1606,7 +1694,7 @@ + while (dp != NULL) { + cp = strchr(dp, (int)':'); + if (cp != NULL) +- *cp = (char)NULL; ++ *cp = '\0'; + if ((target = ProcessDir(info, dp)) != NULL) + break; + dp = cp; +@@ -1821,7 +1909,7 @@ int ContinueInNewThread(int (JNICALL *continuation)(void *), jlong stack_size, void * args) { int rslt; @@ -6067,6 +6229,17 @@ pthread_t tid; pthread_attr_t attr; pthread_attr_init(&attr); +@@ -1865,8 +1953,8 @@ + #define MAX_PID_STR_SZ 20 + + void SetJavaLauncherPlatformProps() { +- /* Linux only */ +-#ifdef __linux__ ++ /* Linux and BSDs only */ ++#if defined(__linux__) || defined(_ALLBSD_SOURCE) + const char *substr = "-Dsun.java.launcher.pid="; + char *pid_prop_str = (char *)JLI_MemAlloc(strlen(substr) + MAX_PID_STR_SZ + 1); + sprintf(pid_prop_str, "%s%d", substr, getpid()); --- hotspot/src/os/posix/launcher/launcher.script +++ hotspot/src/os/posix/launcher/launcher.script @@ -1,4 +1,4 @@ @@ -14099,11 +14272,34 @@ #endif /* __sun */ -#ifdef __linux -+#if defined(__linux__) || defined(_ALLBSD_SOURCE) ++#if defined(__linux__) /* * On linux, if a binary is running as sgid or suid, glibc sets * LD_LIBRARY_PATH to the empty string for security purposes. (In -@@ -431,7 +465,7 @@ +@@ -423,6 +457,22 @@ + if((getgid() != getegid()) || (getuid() != geteuid()) ) { + return; + } ++#elif defined(_ALLBSD_SOURCE) ++ /* ++ * On BSD, if a binary is running as sgid or suid, libc sets ++ * LD_LIBRARY_PATH to the empty string for security purposes. (In ++ * contrast, on Solaris the LD_LIBRARY_PATH variable for a ++ * privileged binary does not lose its settings; but the dynamic ++ * linker does apply more scrutiny to the path.) The launcher uses ++ * the value of LD_LIBRARY_PATH to prevent an exec loop. ++ * Therefore, if we are running sgid or suid, this function's ++ * setting of LD_LIBRARY_PATH will be ineffective and we should ++ * return from the function now. Getting the right libraries to ++ * be found must be handled through other mechanisms. ++ */ ++ if(issetugid()) { ++ return; ++ } + #endif + + /* runpath contains current effective LD_LIBRARY_PATH setting */ +@@ -431,7 +481,7 @@ new_runpath = JLI_MemAlloc( ((runpath!=NULL)?strlen(runpath):0) + 2*strlen(jrepath) + 2*strlen(arch) + strlen(jvmpath) + 52); @@ -14112,7 +14308,7 @@ /* -@@ -446,7 +480,7 @@ +@@ -446,7 +496,7 @@ /* jvmpath, ((running != wanted)?((wanted==64)?"/"LIBARCH64NAME:"/.."):""), */ @@ -14121,7 +14317,16 @@ "%s:" "%s/lib/%s:" "%s/../lib/%s", -@@ -878,9 +912,13 @@ +@@ -721,7 +771,7 @@ + jboolean + GetApplicationHome(char *buf, jint bufsize) + { +-#ifdef __linux__ ++#if defined(__linux__) || defined(_ALLBSD_SOURCE) + char *execname = GetExecname(); + if (execname) { + strncpy(buf, execname, bufsize-1); +@@ -878,9 +928,13 @@ } } } @@ -14136,7 +14341,7 @@ char buf[PATH_MAX+1]; int len = readlink(self, buf, PATH_MAX); if (len >= 0) { -@@ -888,7 +926,7 @@ +@@ -888,7 +942,7 @@ exec_path = JLI_StringDup(buf); } } @@ -14145,7 +14350,7 @@ { /* Not implemented */ } -@@ -977,6 +1015,7 @@ +@@ -977,6 +1031,7 @@ /* Compute physical memory by asking the OS */ uint64_t physical_memory(void) { @@ -14153,7 +14358,7 @@ const uint64_t pages = (uint64_t) sysconf(_SC_PHYS_PAGES); const uint64_t page_size = (uint64_t) sysconf(_SC_PAGESIZE); const uint64_t result = pages * page_size; -@@ -988,6 +1027,28 @@ +@@ -988,6 +1043,28 @@ " physical memory: " UINT64_FORMAT " (%.3fGB)\n", pages, page_size, result, result / (double) GB); } @@ -14182,7 +14387,7 @@ return result; } -@@ -1083,7 +1144,7 @@ +@@ -1083,7 +1160,7 @@ #endif /* __sun && i586 */ @@ -14191,7 +14396,74 @@ /* * A utility method for asking the CPU about itself. -@@ -1692,9 +1753,23 @@ +@@ -1148,7 +1225,7 @@ + #endif + } + +-#endif /* __linux__ && i586 */ ++#endif /* (__linux__ || _ALLBSD_SOURCE) && i586 */ + + #ifdef i586 + /* +@@ -1360,6 +1437,39 @@ + + #endif /* __linux__ && i586 */ + ++#if defined(_ALLBSD_SOURCE) && defined(i586) ++ ++/* The definition of a server-class machine for bsd-i586 */ ++jboolean ++bsd_i586_ServerClassMachine(void) { ++ jboolean result = JNI_FALSE; ++ /* How big is a server class machine? */ ++ const unsigned long server_processors = 2UL; ++ const uint64_t server_memory = 2UL * GB; ++ /* ++ * We seem not to get our full complement of memory. ++ * We allow some part (1/8?) of the memory to be "missing", ++ * based on the sizes of DIMMs, and maybe graphics cards. ++ */ ++ const uint64_t missing_memory = 256UL * MB; ++ const uint64_t actual_memory = physical_memory(); ++ ++ /* Is this a server class machine? */ ++ if (actual_memory >= (server_memory - missing_memory)) { ++ const unsigned long actual_processors = physical_processors(); ++ if (actual_processors >= server_processors) { ++ result = JNI_TRUE; ++ } ++ } ++ if (_launcher_debug) { ++ printf("bsd_" LIBARCHNAME "_ServerClassMachine: %s\n", ++ (result == JNI_TRUE ? "true" : "false")); ++ } ++ return result; ++} ++ ++#endif /* _ALLBSD_SOURCE && i586 */ ++ + /* Dispatch to the platform-specific definition of "server-class" */ + jboolean + ServerClassMachine(void) { +@@ -1374,6 +1484,8 @@ + result = solaris_i586_ServerClassMachine(); + #elif defined(__linux__) && defined(i586) + result = linux_i586_ServerClassMachine(); ++#elif defined(_ALLBSD_SOURCE) && defined(i586) ++ result = bsd_i586_ServerClassMachine(); + #else + if (_launcher_debug) { + printf("ServerClassMachine: returns default value of %s\n", +@@ -1514,7 +1626,7 @@ + while (dp != NULL) { + cp = strchr(dp, (int)':'); + if (cp != NULL) +- *cp = (char)NULL; ++ *cp = '\0'; + if ((target = ProcessDir(info, dp)) != NULL) + break; + dp = cp; +@@ -1692,9 +1804,29 @@ return(borrowed_unsetenv(name)); } @@ -14202,9 +14474,15 @@ +int64_t +CounterGet() +{ ++#ifdef __FreeBSD__ ++ struct timespec tp; ++ clock_gettime(CLOCK_MONOTONIC, &tp); ++ return (uint64_t)tp.tv_sec * 1000000 + tp.tv_nsec / 1000; ++#else + struct timeval tv; + gettimeofday(&tv, NULL); -+ return (tv.tv_sec * 1000) + tv.tv_usec; ++ return (uint64_t)tv.tv_sec * 1000000 + tv.tv_usec; ++#endif +} +#endif + @@ -14216,7 +14494,7 @@ static void* hSplashLib = NULL; -@@ -1722,13 +1797,15 @@ +@@ -1722,13 +1854,15 @@ return "%lld"; } @@ -14234,7 +14512,23 @@ pthread_t tid; pthread_attr_t attr; pthread_attr_init(&attr); -@@ -1765,13 +1842,11 @@ +@@ -1741,7 +1875,7 @@ + if (pthread_create(&tid, &attr, (void *(*)(void*))continuation, (void*)args) == 0) { + void * tmp; + pthread_join(tid, &tmp); +- rslt = (int)tmp; ++ rslt = (int)(intptr_t)tmp; + } else { + /* + * Continue execution in current thread if for some reason (e.g. out of +@@ -1759,25 +1893,23 @@ + if (thr_create(NULL, stack_size, (void *(*)(void *))continuation, args, flags, &tid) == 0) { + void * tmp; + thr_join(tid, NULL, &tmp); +- rslt = (int)tmp; ++ rslt = (int)(intptr_t)tmp; + } else { + /* See above. Continue in current thread if thr_create() failed */ rslt = continuation(args); } #endif @@ -14251,6 +14545,14 @@ /* Coarse estimation of number of digits assuming the worst case is a 64-bit pid. */ #define MAX_PID_STR_SZ 20 + void SetJavaLauncherPlatformProps() { +- /* Linux only */ +-#ifdef __linux__ ++ /* Linux and BSDs only */ ++#if defined(__linux__) || defined(_ALLBSD_SOURCE) + const char *substr = "-Dsun.java.launcher.pid="; + char *pid_prop_str = (char *)JLI_MemAlloc(strlen(substr) + MAX_PID_STR_SZ + 1); + sprintf(pid_prop_str, "%s%d", substr, getpid()); --- jdk/src/solaris/bin/java_md.h +++ jdk/src/solaris/bin/java_md.h @@ -58,10 +58,14 @@ @@ -16453,17 +16755,26 @@ clk_tck = 100; #endif if (clk_tck == -1) { -@@ -244,32 +310,70 @@ +@@ -244,32 +310,79 @@ Java_com_sun_management_UnixOperatingSystem_getFreePhysicalMemorySize (JNIEnv *env, jobject mbean) { +#if defined (__FreeBSD__) -+ int npages; ++ static const char *vm_stats[] = { ++ "vm.stats.vm.v_free_count", ++ "vm.stats.vm.v_cache_count", ++ /* "vm.stats.vm.v_inactive_count", */ ++ NULL ++ }; + size_t size; -+ size = sizeof(npages); -+ if (sysctlbyname("vm.stats.vm.v_free_count", &npages, &size, NULL, 0) == - 1) -+ return (0); -+ return ((jlong)npages * page_size); ++ jlong free_pages; ++ u_int i, npages; ++ for (i = 0, free_pages = 0, size = sizeof(npages); vm_stats[i] != NULL; i++) { ++ if (sysctlbyname(vm_stats[i], &npages, &size, NULL, 0) == -1) ++ return 0; ++ free_pages += npages; ++ } ++ return (free_pages * page_size); +#elif defined(_ALLBSD_SOURCE) + // throw_internal_error(env, "Unimplemented in BSD"); + return (128 * MB); @@ -16524,7 +16835,7 @@ // iterate through directory entries, skipping '.' and '..' // each entry represents an open file descriptor. -@@ -282,6 +386,7 @@ +@@ -282,6 +395,7 @@ closedir(dirp); // subtract by 1 which was the fd open for this implementation return (fds - 1); |