1
1
/*
2
- * Copyright (c) 1999, 2024 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 1999, 2023 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
@@ -2008,15 +2008,15 @@ void os::init(void) {
2008
2008
2009
2009
Bsd::initialize_system_info ();
2010
2010
2011
- // _main_thread points to the thread that created/loaded the JVM
2011
+ // _main_thread points to the thread that created/loaded the JVM.
2012
2012
Bsd::_main_thread = pthread_self ();
2013
2013
2014
2014
Bsd::clock_init ();
2015
2015
2016
2016
os::Posix::init ();
2017
2017
}
2018
2018
2019
- // to install functions for atexit system call
2019
+ // To install functions for atexit system call
2020
2020
extern " C" {
2021
2021
static void perfMemory_exit_helper () {
2022
2022
perfMemory_exit ();
@@ -2036,60 +2036,51 @@ jint os::init_2(void) {
2036
2036
return JNI_ERR;
2037
2037
}
2038
2038
2039
- // check and sets minimum stack sizes against command line options
2039
+ // Check and sets minimum stack sizes against command line options
2040
2040
if (set_minimum_stack_sizes () == JNI_ERR) {
2041
2041
return JNI_ERR;
2042
2042
}
2043
2043
2044
- // not supported
2044
+ // Not supported.
2045
2045
FLAG_SET_ERGO (UseNUMA, false );
2046
2046
FLAG_SET_ERGO (UseNUMAInterleaving, false );
2047
2047
2048
2048
if (MaxFDLimit) {
2049
- // Set the number of file descriptors to max. Print out error
2049
+ // set the number of file descriptors to max. print out error
2050
2050
// if getrlimit/setrlimit fails but continue regardless.
2051
2051
struct rlimit nbr_files;
2052
2052
int status = getrlimit (RLIMIT_NOFILE, &nbr_files);
2053
2053
if (status != 0 ) {
2054
2054
log_info (os)(" os::init_2 getrlimit failed: %s" , os::strerror (errno));
2055
2055
} else {
2056
- rlim_t rlim_original = nbr_files.rlim_cur ;
2057
-
2058
- // On macOS according to setrlimit(2), OPEN_MAX must be used instead
2059
- // of RLIM_INFINITY, but testing on macOS >= 10.6, reveals that
2060
- // we can, in fact, use even RLIM_INFINITY, so try the max value
2061
- // that the system claims can be used first, same as other BSD OSes.
2062
- // However, some terminals (ksh) will internally use "int" type
2063
- // to store this value and since RLIM_INFINITY overflows an "int"
2064
- // we might end up with a negative value, so cap the system limit max
2065
- // at INT_MAX instead, just in case, for everyone.
2066
- nbr_files.rlim_cur = MIN (INT_MAX, nbr_files.rlim_max );
2056
+ nbr_files.rlim_cur = nbr_files.rlim_max ;
2057
+
2058
+ #ifdef __APPLE__
2059
+ // Darwin returns RLIM_INFINITY for rlim_max, but fails with EINVAL if
2060
+ // you attempt to use RLIM_INFINITY. As per setrlimit(2), OPEN_MAX must
2061
+ // be used instead
2062
+ nbr_files.rlim_cur = MIN (OPEN_MAX, nbr_files.rlim_cur );
2063
+ #endif
2067
2064
2068
2065
status = setrlimit (RLIMIT_NOFILE, &nbr_files);
2069
- if (status != 0 ) {
2070
- // If that fails then try lowering the limit to either OPEN_MAX
2071
- // (which is safe) or the original limit, whichever was greater.
2072
- nbr_files.rlim_cur = MAX (OPEN_MAX, rlim_original);
2073
- status = setrlimit (RLIMIT_NOFILE, &nbr_files);
2074
- }
2075
2066
if (status != 0 ) {
2076
2067
log_info (os)(" os::init_2 setrlimit failed: %s" , os::strerror (errno));
2077
2068
}
2078
2069
}
2079
2070
}
2080
2071
2081
- // At -exit methods are called in the reverse order of their registration.
2072
+ // at -exit methods are called in the reverse order of their registration.
2082
2073
// atexit functions are called on return from main or as a result of a
2083
2074
// call to exit(3C). There can be only 32 of these functions registered
2084
2075
// and atexit() does not set errno.
2085
2076
2086
2077
if (PerfAllowAtExitRegistration) {
2087
- // Only register atexit functions if PerfAllowAtExitRegistration is set.
2078
+ // only register atexit functions if PerfAllowAtExitRegistration is set.
2088
2079
// atexit functions can be delayed until process exit time, which
2089
2080
// can be problematic for embedded VM situations. Embedded VMs should
2090
2081
// call DestroyJavaVM() to assure that VM resources are released.
2091
2082
2092
- // Note : perfMemory_exit_helper atexit function may be removed in
2083
+ // note : perfMemory_exit_helper atexit function may be removed in
2093
2084
// the future if the appropriate cleanup code can be added to the
2094
2085
// VM_Exit VMOperation's doit method.
2095
2086
if (atexit (perfMemory_exit_helper) != 0 ) {
@@ -2112,7 +2103,7 @@ jint os::init_2(void) {
2112
2103
}
2113
2104
2114
2105
int os::active_processor_count () {
2115
- // user has overridden the number of active processors
2106
+ // User has overridden the number of active processors
2116
2107
if (ActiveProcessorCount > 0 ) {
2117
2108
log_trace (os)(" active_processor_count: "
2118
2109
" active processor count set by user : %d" ,
@@ -2165,9 +2156,9 @@ uint os::processor_id() {
2165
2156
2166
2157
void os::set_native_thread_name (const char *name) {
2167
2158
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
2168
- // this is only supported in Snow Leopard and beyond
2159
+ // This is only supported in Snow Leopard and beyond
2169
2160
if (name != nullptr ) {
2170
- // add a "Java: " prefix to the name
2161
+ // Add a "Java: " prefix to the name
2171
2162
char buf[MAXTHREADNAMESIZE];
2172
2163
snprintf (buf, sizeof (buf), " Java: %s" , name);
2173
2164
pthread_setname_np (buf);
0 commit comments