mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-18 10:04:42 +02:00
8301478: Replace NULL with nullptr in os/bsd
Reviewed-by: coleenp, stuefe
This commit is contained in:
parent
ab528ce3cd
commit
716f1df609
6 changed files with 163 additions and 164 deletions
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -82,7 +82,7 @@ class BsdAttachListener: AllStatic {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void set_path(char* path) {
|
static void set_path(char* path) {
|
||||||
if (path == NULL) {
|
if (path == nullptr) {
|
||||||
_path[0] = '\0';
|
_path[0] = '\0';
|
||||||
_has_path = false;
|
_has_path = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -145,7 +145,7 @@ class ArgumentIterator : public StackObj {
|
||||||
if (_pos < _end) {
|
if (_pos < _end) {
|
||||||
_pos += 1;
|
_pos += 1;
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
char* res = _pos;
|
char* res = _pos;
|
||||||
char* next_pos = strchr(_pos, '\0');
|
char* next_pos = strchr(_pos, '\0');
|
||||||
|
@ -170,7 +170,7 @@ extern "C" {
|
||||||
}
|
}
|
||||||
if (BsdAttachListener::has_path()) {
|
if (BsdAttachListener::has_path()) {
|
||||||
::unlink(BsdAttachListener::path());
|
::unlink(BsdAttachListener::path());
|
||||||
BsdAttachListener::set_path(NULL);
|
BsdAttachListener::set_path(nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ BsdAttachOperation* BsdAttachListener::read_request(int s) {
|
||||||
assert(n <= left, "buffer was too small, impossible!");
|
assert(n <= left, "buffer was too small, impossible!");
|
||||||
buf[max_len - 1] = '\0';
|
buf[max_len - 1] = '\0';
|
||||||
if (n == -1) {
|
if (n == -1) {
|
||||||
return NULL; // reset by peer or other error
|
return nullptr; // reset by peer or other error
|
||||||
}
|
}
|
||||||
if (n == 0) {
|
if (n == 0) {
|
||||||
break;
|
break;
|
||||||
|
@ -293,7 +293,7 @@ BsdAttachOperation* BsdAttachListener::read_request(int s) {
|
||||||
char msg[32];
|
char msg[32];
|
||||||
int msg_len = os::snprintf_checked(msg, sizeof(msg), "%d\n", ATTACH_ERROR_BADVERSION);
|
int msg_len = os::snprintf_checked(msg, sizeof(msg), "%d\n", ATTACH_ERROR_BADVERSION);
|
||||||
write_fully(s, msg, msg_len);
|
write_fully(s, msg, msg_len);
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -303,7 +303,7 @@ BsdAttachOperation* BsdAttachListener::read_request(int s) {
|
||||||
} while (left > 0 && str_count < expected_str_count);
|
} while (left > 0 && str_count < expected_str_count);
|
||||||
|
|
||||||
if (str_count != expected_str_count) {
|
if (str_count != expected_str_count) {
|
||||||
return NULL; // incomplete request
|
return nullptr; // incomplete request
|
||||||
}
|
}
|
||||||
|
|
||||||
// parse request
|
// parse request
|
||||||
|
@ -314,20 +314,20 @@ BsdAttachOperation* BsdAttachListener::read_request(int s) {
|
||||||
char* v = args.next();
|
char* v = args.next();
|
||||||
|
|
||||||
char* name = args.next();
|
char* name = args.next();
|
||||||
if (name == NULL || strlen(name) > AttachOperation::name_length_max) {
|
if (name == nullptr || strlen(name) > AttachOperation::name_length_max) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
BsdAttachOperation* op = new BsdAttachOperation(name);
|
BsdAttachOperation* op = new BsdAttachOperation(name);
|
||||||
|
|
||||||
for (int i=0; i<AttachOperation::arg_count_max; i++) {
|
for (int i=0; i<AttachOperation::arg_count_max; i++) {
|
||||||
char* arg = args.next();
|
char* arg = args.next();
|
||||||
if (arg == NULL) {
|
if (arg == nullptr) {
|
||||||
op->set_arg(i, NULL);
|
op->set_arg(i, nullptr);
|
||||||
} else {
|
} else {
|
||||||
if (strlen(arg) > AttachOperation::arg_length_max) {
|
if (strlen(arg) > AttachOperation::arg_length_max) {
|
||||||
delete op;
|
delete op;
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
op->set_arg(i, arg);
|
op->set_arg(i, arg);
|
||||||
}
|
}
|
||||||
|
@ -352,7 +352,7 @@ BsdAttachOperation* BsdAttachListener::dequeue() {
|
||||||
socklen_t len = sizeof(addr);
|
socklen_t len = sizeof(addr);
|
||||||
RESTARTABLE(::accept(listener(), &addr, &len), s);
|
RESTARTABLE(::accept(listener(), &addr, &len), s);
|
||||||
if (s == -1) {
|
if (s == -1) {
|
||||||
return NULL; // log a warning?
|
return nullptr; // log a warning?
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the credentials of the peer and check the effective uid/guid
|
// get the credentials of the peer and check the effective uid/guid
|
||||||
|
@ -373,7 +373,7 @@ BsdAttachOperation* BsdAttachListener::dequeue() {
|
||||||
|
|
||||||
// peer credential look okay so we read the request
|
// peer credential look okay so we read the request
|
||||||
BsdAttachOperation* op = read_request(s);
|
BsdAttachOperation* op = read_request(s);
|
||||||
if (op == NULL) {
|
if (op == nullptr) {
|
||||||
::close(s);
|
::close(s);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@ -543,7 +543,7 @@ void AttachListener::pd_data_dump() {
|
||||||
}
|
}
|
||||||
|
|
||||||
AttachOperationFunctionInfo* AttachListener::pd_find_operation(const char* n) {
|
AttachOperationFunctionInfo* AttachListener::pd_find_operation(const char* n) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
jint AttachListener::pd_set_flag(AttachOperation* op, outputStream* out) {
|
jint AttachListener::pd_set_flag(AttachOperation* op, outputStream* out) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -41,7 +41,7 @@ bool MachODecoder::demangle(const char* symbol, char *buf, int buflen) {
|
||||||
// Don't pass buf to __cxa_demangle. In case of the 'buf' is too small,
|
// Don't pass buf to __cxa_demangle. In case of the 'buf' is too small,
|
||||||
// __cxa_demangle will call system "realloc" for additional memory, which
|
// __cxa_demangle will call system "realloc" for additional memory, which
|
||||||
// may use different malloc/realloc mechanism that allocates 'buf'.
|
// may use different malloc/realloc mechanism that allocates 'buf'.
|
||||||
if ((result = abi::__cxa_demangle(symbol, NULL, NULL, &status)) != NULL) {
|
if ((result = abi::__cxa_demangle(symbol, nullptr, nullptr, &status)) != nullptr) {
|
||||||
jio_snprintf(buf, buflen, "%s", result);
|
jio_snprintf(buf, buflen, "%s", result);
|
||||||
// call c library's free
|
// call c library's free
|
||||||
::free(result);
|
::free(result);
|
||||||
|
@ -60,7 +60,7 @@ bool MachODecoder::decode(address addr, char *buf,
|
||||||
}
|
}
|
||||||
struct symtab_command * symt = (struct symtab_command *)
|
struct symtab_command * symt = (struct symtab_command *)
|
||||||
mach_find_command((struct mach_header_64 *)mach_base, LC_SYMTAB);
|
mach_find_command((struct mach_header_64 *)mach_base, LC_SYMTAB);
|
||||||
if (symt == NULL) {
|
if (symt == nullptr) {
|
||||||
DEBUG_ONLY(tty->print_cr("no symtab in mach file at 0x%lx", p2i(mach_base)));
|
DEBUG_ONLY(tty->print_cr("no symtab in mach file at 0x%lx", p2i(mach_base)));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -124,13 +124,13 @@ void* MachODecoder::mach_find_command(struct mach_header_64 * mach_base, uint32_
|
||||||
int cmdsize = this_cmd->cmdsize;
|
int cmdsize = this_cmd->cmdsize;
|
||||||
pos += cmdsize;
|
pos += cmdsize;
|
||||||
}
|
}
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* MachODecoder::mach_find_in_stringtable(char *strtab, uint32_t tablesize, int strx_wanted) {
|
char* MachODecoder::mach_find_in_stringtable(char *strtab, uint32_t tablesize, int strx_wanted) {
|
||||||
|
|
||||||
if (strx_wanted == 0) {
|
if (strx_wanted == 0) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
char *strtab_end = strtab + tablesize;
|
char *strtab_end = strtab + tablesize;
|
||||||
|
|
||||||
|
@ -140,13 +140,13 @@ char* MachODecoder::mach_find_in_stringtable(char *strtab, uint32_t tablesize, i
|
||||||
strtab++;
|
strtab++;
|
||||||
if (*strtab != 0) {
|
if (*strtab != 0) {
|
||||||
DEBUG_ONLY(tty->print_cr("string table has leading space but no following zero."));
|
DEBUG_ONLY(tty->print_cr("string table has leading space but no following zero."));
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
strtab++;
|
strtab++;
|
||||||
} else {
|
} else {
|
||||||
if ((uint32_t) *strtab != 0) {
|
if ((uint32_t) *strtab != 0) {
|
||||||
DEBUG_ONLY(tty->print_cr("string table without leading space or leading int of zero."));
|
DEBUG_ONLY(tty->print_cr("string table without leading space or leading int of zero."));
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
strtab+=4;
|
strtab+=4;
|
||||||
}
|
}
|
||||||
|
@ -164,7 +164,7 @@ char* MachODecoder::mach_find_in_stringtable(char *strtab, uint32_t tablesize, i
|
||||||
cur_strx++;
|
cur_strx++;
|
||||||
}
|
}
|
||||||
DEBUG_ONLY(tty->print_cr("string number %d not found.", strx_wanted));
|
DEBUG_ONLY(tty->print_cr("string number %d not found.", strx_wanted));
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -30,23 +30,22 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
void OSThread::pd_initialize() {
|
void OSThread::pd_initialize() {
|
||||||
assert(this != NULL, "check");
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
_thread_id = 0;
|
_thread_id = 0;
|
||||||
#else
|
#else
|
||||||
_thread_id = NULL;
|
_thread_id = nullptr;
|
||||||
#endif
|
#endif
|
||||||
_unique_thread_id = 0;
|
_unique_thread_id = 0;
|
||||||
_pthread_id = NULL;
|
_pthread_id = nullptr;
|
||||||
_siginfo = NULL;
|
_siginfo = nullptr;
|
||||||
_ucontext = NULL;
|
_ucontext = nullptr;
|
||||||
_expanding_stack = 0;
|
_expanding_stack = 0;
|
||||||
_alt_sig_stack = NULL;
|
_alt_sig_stack = nullptr;
|
||||||
|
|
||||||
sigemptyset(&_caller_sigmask);
|
sigemptyset(&_caller_sigmask);
|
||||||
|
|
||||||
_startThread_lock = new Monitor(Mutex::event, "startThread_lock");
|
_startThread_lock = new Monitor(Mutex::event, "startThread_lock");
|
||||||
assert(_startThread_lock !=NULL, "check");
|
assert(_startThread_lock !=nullptr, "check");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Additional thread_id used to correlate threads in SA
|
// Additional thread_id used to correlate threads in SA
|
||||||
|
|
|
@ -164,9 +164,9 @@ void os::Bsd::print_uptime_info(outputStream* st) {
|
||||||
mib[0] = CTL_KERN;
|
mib[0] = CTL_KERN;
|
||||||
mib[1] = KERN_BOOTTIME;
|
mib[1] = KERN_BOOTTIME;
|
||||||
|
|
||||||
if (sysctl(mib, 2, &boottime, &len, NULL, 0) >= 0) {
|
if (sysctl(mib, 2, &boottime, &len, nullptr, 0) >= 0) {
|
||||||
time_t bootsec = boottime.tv_sec;
|
time_t bootsec = boottime.tv_sec;
|
||||||
time_t currsec = time(NULL);
|
time_t currsec = time(nullptr);
|
||||||
os::print_dhm(st, "OS uptime:", (long) difftime(currsec, bootsec));
|
os::print_dhm(st, "OS uptime:", (long) difftime(currsec, bootsec));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -212,7 +212,7 @@ void os::Bsd::initialize_system_info() {
|
||||||
mib[0] = CTL_HW;
|
mib[0] = CTL_HW;
|
||||||
mib[1] = HW_NCPU;
|
mib[1] = HW_NCPU;
|
||||||
len = sizeof(cpu_val);
|
len = sizeof(cpu_val);
|
||||||
if (sysctl(mib, 2, &cpu_val, &len, NULL, 0) != -1 && cpu_val >= 1) {
|
if (sysctl(mib, 2, &cpu_val, &len, nullptr, 0) != -1 && cpu_val >= 1) {
|
||||||
assert(len == sizeof(cpu_val), "unexpected data size");
|
assert(len == sizeof(cpu_val), "unexpected data size");
|
||||||
set_processor_count(cpu_val);
|
set_processor_count(cpu_val);
|
||||||
} else {
|
} else {
|
||||||
|
@ -241,7 +241,7 @@ void os::Bsd::initialize_system_info() {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
len = sizeof(mem_val);
|
len = sizeof(mem_val);
|
||||||
if (sysctl(mib, 2, &mem_val, &len, NULL, 0) != -1) {
|
if (sysctl(mib, 2, &mem_val, &len, nullptr, 0) != -1) {
|
||||||
assert(len == sizeof(mem_val), "unexpected data size");
|
assert(len == sizeof(mem_val), "unexpected data size");
|
||||||
_physical_memory = mem_val;
|
_physical_memory = mem_val;
|
||||||
} else {
|
} else {
|
||||||
|
@ -262,9 +262,9 @@ void os::Bsd::initialize_system_info() {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
static const char *get_home() {
|
static const char *get_home() {
|
||||||
const char *home_dir = ::getenv("HOME");
|
const char *home_dir = ::getenv("HOME");
|
||||||
if ((home_dir == NULL) || (*home_dir == '\0')) {
|
if ((home_dir == nullptr) || (*home_dir == '\0')) {
|
||||||
struct passwd *passwd_info = getpwuid(geteuid());
|
struct passwd *passwd_info = getpwuid(geteuid());
|
||||||
if (passwd_info != NULL) {
|
if (passwd_info != nullptr) {
|
||||||
home_dir = passwd_info->pw_dir;
|
home_dir = passwd_info->pw_dir;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,24 +337,24 @@ void os::init_system_properties_values() {
|
||||||
// Now cut the path to <java_home>/jre if we can.
|
// Now cut the path to <java_home>/jre if we can.
|
||||||
*(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
|
*(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
|
||||||
pslash = strrchr(buf, '/');
|
pslash = strrchr(buf, '/');
|
||||||
if (pslash != NULL) {
|
if (pslash != nullptr) {
|
||||||
*pslash = '\0'; // Get rid of /{client|server|hotspot}.
|
*pslash = '\0'; // Get rid of /{client|server|hotspot}.
|
||||||
}
|
}
|
||||||
Arguments::set_dll_dir(buf);
|
Arguments::set_dll_dir(buf);
|
||||||
|
|
||||||
if (pslash != NULL) {
|
if (pslash != nullptr) {
|
||||||
pslash = strrchr(buf, '/');
|
pslash = strrchr(buf, '/');
|
||||||
if (pslash != NULL) {
|
if (pslash != nullptr) {
|
||||||
*pslash = '\0'; // Get rid of /<arch>.
|
*pslash = '\0'; // Get rid of /<arch>.
|
||||||
pslash = strrchr(buf, '/');
|
pslash = strrchr(buf, '/');
|
||||||
if (pslash != NULL) {
|
if (pslash != nullptr) {
|
||||||
*pslash = '\0'; // Get rid of /lib.
|
*pslash = '\0'; // Get rid of /lib.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Arguments::set_java_home(buf);
|
Arguments::set_java_home(buf);
|
||||||
if (!set_boot_path('/', ':')) {
|
if (!set_boot_path('/', ':')) {
|
||||||
vm_exit_during_initialization("Failed setting boot class path.", NULL);
|
vm_exit_during_initialization("Failed setting boot class path.", nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ void os::init_system_properties_values() {
|
||||||
// addressed).
|
// addressed).
|
||||||
const char *v = ::getenv("LD_LIBRARY_PATH");
|
const char *v = ::getenv("LD_LIBRARY_PATH");
|
||||||
const char *v_colon = ":";
|
const char *v_colon = ":";
|
||||||
if (v == NULL) { v = ""; v_colon = ""; }
|
if (v == nullptr) { v = ""; v_colon = ""; }
|
||||||
// That's +1 for the colon and +1 for the trailing '\0'.
|
// That's +1 for the colon and +1 for the trailing '\0'.
|
||||||
const size_t ld_library_path_size = strlen(v) + 1 + sizeof(SYS_EXT_DIR) +
|
const size_t ld_library_path_size = strlen(v) + 1 + sizeof(SYS_EXT_DIR) +
|
||||||
sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1;
|
sizeof("/lib/") + strlen(cpu_arch) + sizeof(DEFAULT_LIBPATH) + 1;
|
||||||
|
@ -417,7 +417,7 @@ void os::init_system_properties_values() {
|
||||||
// Now cut the path to <java_home>/jre if we can.
|
// Now cut the path to <java_home>/jre if we can.
|
||||||
*(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
|
*(strrchr(buf, '/')) = '\0'; // Get rid of /libjvm.so.
|
||||||
pslash = strrchr(buf, '/');
|
pslash = strrchr(buf, '/');
|
||||||
if (pslash != NULL) {
|
if (pslash != nullptr) {
|
||||||
*pslash = '\0'; // Get rid of /{client|server|hotspot}.
|
*pslash = '\0'; // Get rid of /{client|server|hotspot}.
|
||||||
}
|
}
|
||||||
#ifdef STATIC_BUILD
|
#ifdef STATIC_BUILD
|
||||||
|
@ -426,15 +426,15 @@ void os::init_system_properties_values() {
|
||||||
|
|
||||||
Arguments::set_dll_dir(buf);
|
Arguments::set_dll_dir(buf);
|
||||||
|
|
||||||
if (pslash != NULL) {
|
if (pslash != nullptr) {
|
||||||
pslash = strrchr(buf, '/');
|
pslash = strrchr(buf, '/');
|
||||||
if (pslash != NULL) {
|
if (pslash != nullptr) {
|
||||||
*pslash = '\0'; // Get rid of /lib.
|
*pslash = '\0'; // Get rid of /lib.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Arguments::set_java_home(buf);
|
Arguments::set_java_home(buf);
|
||||||
if (!set_boot_path('/', ':')) {
|
if (!set_boot_path('/', ':')) {
|
||||||
vm_exit_during_initialization("Failed setting boot class path.", NULL);
|
vm_exit_during_initialization("Failed setting boot class path.", nullptr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,11 +456,11 @@ void os::init_system_properties_values() {
|
||||||
// can specify a directory inside an app wrapper
|
// can specify a directory inside an app wrapper
|
||||||
const char *l = ::getenv("JAVA_LIBRARY_PATH");
|
const char *l = ::getenv("JAVA_LIBRARY_PATH");
|
||||||
const char *l_colon = ":";
|
const char *l_colon = ":";
|
||||||
if (l == NULL) { l = ""; l_colon = ""; }
|
if (l == nullptr) { l = ""; l_colon = ""; }
|
||||||
|
|
||||||
const char *v = ::getenv("DYLD_LIBRARY_PATH");
|
const char *v = ::getenv("DYLD_LIBRARY_PATH");
|
||||||
const char *v_colon = ":";
|
const char *v_colon = ":";
|
||||||
if (v == NULL) { v = ""; v_colon = ""; }
|
if (v == nullptr) { v = ""; v_colon = ""; }
|
||||||
|
|
||||||
// Apple's Java6 has "." at the beginning of java.library.path.
|
// Apple's Java6 has "." at the beginning of java.library.path.
|
||||||
// OpenJDK on Windows has "." at the end of java.library.path.
|
// OpenJDK on Windows has "." at the end of java.library.path.
|
||||||
|
@ -519,7 +519,7 @@ extern "C" void breakpoint() {
|
||||||
#define OBJC_GCREGISTER "objc_registerThreadWithCollector"
|
#define OBJC_GCREGISTER "objc_registerThreadWithCollector"
|
||||||
typedef void (*objc_registerThreadWithCollector_t)();
|
typedef void (*objc_registerThreadWithCollector_t)();
|
||||||
extern "C" objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction;
|
extern "C" objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction;
|
||||||
objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = NULL;
|
objc_registerThreadWithCollector_t objc_registerThreadWithCollectorFunction = nullptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Thread start routine for all newly created threads
|
// Thread start routine for all newly created threads
|
||||||
|
@ -546,7 +546,7 @@ static void *thread_native_entry(Thread *thread) {
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// register thread with objc gc
|
// register thread with objc gc
|
||||||
if (objc_registerThreadWithCollectorFunction != NULL) {
|
if (objc_registerThreadWithCollectorFunction != nullptr) {
|
||||||
objc_registerThreadWithCollectorFunction();
|
objc_registerThreadWithCollectorFunction();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -573,7 +573,7 @@ static void *thread_native_entry(Thread *thread) {
|
||||||
|
|
||||||
// Note: at this point the thread object may already have deleted itself.
|
// Note: at this point the thread object may already have deleted itself.
|
||||||
// Prevent dereferencing it from here on out.
|
// Prevent dereferencing it from here on out.
|
||||||
thread = NULL;
|
thread = nullptr;
|
||||||
|
|
||||||
log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").",
|
log_info(os, thread)("Thread finished (tid: " UINTX_FORMAT ", pthread id: " UINTX_FORMAT ").",
|
||||||
os::current_thread_id(), (uintx) pthread_self());
|
os::current_thread_id(), (uintx) pthread_self());
|
||||||
|
@ -583,11 +583,11 @@ static void *thread_native_entry(Thread *thread) {
|
||||||
|
|
||||||
bool os::create_thread(Thread* thread, ThreadType thr_type,
|
bool os::create_thread(Thread* thread, ThreadType thr_type,
|
||||||
size_t req_stack_size) {
|
size_t req_stack_size) {
|
||||||
assert(thread->osthread() == NULL, "caller responsible");
|
assert(thread->osthread() == nullptr, "caller responsible");
|
||||||
|
|
||||||
// Allocate the OSThread object
|
// Allocate the OSThread object
|
||||||
OSThread* osthread = new OSThread();
|
OSThread* osthread = new OSThread();
|
||||||
if (osthread == NULL) {
|
if (osthread == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -639,7 +639,7 @@ bool os::create_thread(Thread* thread, ThreadType thr_type,
|
||||||
|
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
// Need to clean up stuff we've allocated so far
|
// Need to clean up stuff we've allocated so far
|
||||||
thread->set_osthread(NULL);
|
thread->set_osthread(nullptr);
|
||||||
delete osthread;
|
delete osthread;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -681,7 +681,7 @@ bool os::create_attached_thread(JavaThread* thread) {
|
||||||
// Allocate the OSThread object
|
// Allocate the OSThread object
|
||||||
OSThread* osthread = new OSThread();
|
OSThread* osthread = new OSThread();
|
||||||
|
|
||||||
if (osthread == NULL) {
|
if (osthread == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,7 +724,7 @@ void os::pd_start_thread(Thread* thread) {
|
||||||
|
|
||||||
// Free Bsd resources related to the OSThread
|
// Free Bsd resources related to the OSThread
|
||||||
void os::free_thread(OSThread* osthread) {
|
void os::free_thread(OSThread* osthread) {
|
||||||
assert(osthread != NULL, "osthread not set");
|
assert(osthread != nullptr, "osthread not set");
|
||||||
|
|
||||||
// We are told to free resources of the argument thread,
|
// We are told to free resources of the argument thread,
|
||||||
// but we can only really operate on the current thread.
|
// but we can only really operate on the current thread.
|
||||||
|
@ -733,7 +733,7 @@ void os::free_thread(OSThread* osthread) {
|
||||||
|
|
||||||
// Restore caller's signal mask
|
// Restore caller's signal mask
|
||||||
sigset_t sigmask = osthread->caller_sigmask();
|
sigset_t sigmask = osthread->caller_sigmask();
|
||||||
pthread_sigmask(SIG_SETMASK, &sigmask, NULL);
|
pthread_sigmask(SIG_SETMASK, &sigmask, nullptr);
|
||||||
|
|
||||||
delete osthread;
|
delete osthread;
|
||||||
}
|
}
|
||||||
|
@ -850,8 +850,8 @@ static int local_dladdr(const void* addr, Dl_info* info) {
|
||||||
// macosx has a secure per-user temporary directory
|
// macosx has a secure per-user temporary directory
|
||||||
char temp_path_storage[PATH_MAX];
|
char temp_path_storage[PATH_MAX];
|
||||||
const char* os::get_temp_directory() {
|
const char* os::get_temp_directory() {
|
||||||
static char *temp_path = NULL;
|
static char *temp_path = nullptr;
|
||||||
if (temp_path == NULL) {
|
if (temp_path == nullptr) {
|
||||||
int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, temp_path_storage, PATH_MAX);
|
int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, temp_path_storage, PATH_MAX);
|
||||||
if (pathSize == 0 || pathSize > PATH_MAX) {
|
if (pathSize == 0 || pathSize > PATH_MAX) {
|
||||||
strlcpy(temp_path_storage, "/tmp/", sizeof(temp_path_storage));
|
strlcpy(temp_path_storage, "/tmp/", sizeof(temp_path_storage));
|
||||||
|
@ -869,11 +869,11 @@ bool os::address_is_in_vm(address addr) {
|
||||||
static address libjvm_base_addr;
|
static address libjvm_base_addr;
|
||||||
Dl_info dlinfo;
|
Dl_info dlinfo;
|
||||||
|
|
||||||
if (libjvm_base_addr == NULL) {
|
if (libjvm_base_addr == nullptr) {
|
||||||
if (dladdr(CAST_FROM_FN_PTR(void *, os::address_is_in_vm), &dlinfo) != 0) {
|
if (dladdr(CAST_FROM_FN_PTR(void *, os::address_is_in_vm), &dlinfo) != 0) {
|
||||||
libjvm_base_addr = (address)dlinfo.dli_fbase;
|
libjvm_base_addr = (address)dlinfo.dli_fbase;
|
||||||
}
|
}
|
||||||
assert(libjvm_base_addr !=NULL, "Cannot obtain base address for libjvm");
|
assert(libjvm_base_addr !=nullptr, "Cannot obtain base address for libjvm");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dladdr((void *)addr, &dlinfo) != 0) {
|
if (dladdr((void *)addr, &dlinfo) != 0) {
|
||||||
|
@ -887,17 +887,17 @@ bool os::dll_address_to_function_name(address addr, char *buf,
|
||||||
int buflen, int *offset,
|
int buflen, int *offset,
|
||||||
bool demangle) {
|
bool demangle) {
|
||||||
// buf is not optional, but offset is optional
|
// buf is not optional, but offset is optional
|
||||||
assert(buf != NULL, "sanity check");
|
assert(buf != nullptr, "sanity check");
|
||||||
|
|
||||||
Dl_info dlinfo;
|
Dl_info dlinfo;
|
||||||
|
|
||||||
if (local_dladdr((void*)addr, &dlinfo) != 0) {
|
if (local_dladdr((void*)addr, &dlinfo) != 0) {
|
||||||
// see if we have a matching symbol
|
// see if we have a matching symbol
|
||||||
if (dlinfo.dli_saddr != NULL && dlinfo.dli_sname != NULL) {
|
if (dlinfo.dli_saddr != nullptr && dlinfo.dli_sname != nullptr) {
|
||||||
if (!(demangle && Decoder::demangle(dlinfo.dli_sname, buf, buflen))) {
|
if (!(demangle && Decoder::demangle(dlinfo.dli_sname, buf, buflen))) {
|
||||||
jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname);
|
jio_snprintf(buf, buflen, "%s", dlinfo.dli_sname);
|
||||||
}
|
}
|
||||||
if (offset != NULL) *offset = addr - (address)dlinfo.dli_saddr;
|
if (offset != nullptr) *offset = addr - (address)dlinfo.dli_saddr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -909,7 +909,7 @@ bool os::dll_address_to_function_name(address addr, char *buf,
|
||||||
// each "file".
|
// each "file".
|
||||||
|
|
||||||
// no matching symbol so try for just file info
|
// no matching symbol so try for just file info
|
||||||
if (dlinfo.dli_fname != NULL && dlinfo.dli_fbase != NULL) {
|
if (dlinfo.dli_fname != nullptr && dlinfo.dli_fbase != nullptr) {
|
||||||
if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase),
|
if (Decoder::decode((address)(addr - (address)dlinfo.dli_fbase),
|
||||||
buf, buflen, offset, dlinfo.dli_fname, demangle)) {
|
buf, buflen, offset, dlinfo.dli_fname, demangle)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -921,7 +921,7 @@ bool os::dll_address_to_function_name(address addr, char *buf,
|
||||||
|
|
||||||
char localbuf[MACH_MAXSYMLEN];
|
char localbuf[MACH_MAXSYMLEN];
|
||||||
// Handle non-dynamic manually:
|
// Handle non-dynamic manually:
|
||||||
if (dlinfo.dli_fbase != NULL &&
|
if (dlinfo.dli_fbase != nullptr &&
|
||||||
Decoder::decode(addr, localbuf, MACH_MAXSYMLEN, offset,
|
Decoder::decode(addr, localbuf, MACH_MAXSYMLEN, offset,
|
||||||
dlinfo.dli_fbase)) {
|
dlinfo.dli_fbase)) {
|
||||||
if (!(demangle && Decoder::demangle(localbuf, buf, buflen))) {
|
if (!(demangle && Decoder::demangle(localbuf, buf, buflen))) {
|
||||||
|
@ -934,22 +934,22 @@ bool os::dll_address_to_function_name(address addr, char *buf,
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
}
|
}
|
||||||
buf[0] = '\0';
|
buf[0] = '\0';
|
||||||
if (offset != NULL) *offset = -1;
|
if (offset != nullptr) *offset = -1;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::dll_address_to_library_name(address addr, char* buf,
|
bool os::dll_address_to_library_name(address addr, char* buf,
|
||||||
int buflen, int* offset) {
|
int buflen, int* offset) {
|
||||||
// buf is not optional, but offset is optional
|
// buf is not optional, but offset is optional
|
||||||
assert(buf != NULL, "sanity check");
|
assert(buf != nullptr, "sanity check");
|
||||||
|
|
||||||
Dl_info dlinfo;
|
Dl_info dlinfo;
|
||||||
|
|
||||||
if (local_dladdr((void*)addr, &dlinfo) != 0) {
|
if (local_dladdr((void*)addr, &dlinfo) != 0) {
|
||||||
if (dlinfo.dli_fname != NULL) {
|
if (dlinfo.dli_fname != nullptr) {
|
||||||
jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname);
|
jio_snprintf(buf, buflen, "%s", dlinfo.dli_fname);
|
||||||
}
|
}
|
||||||
if (dlinfo.dli_fbase != NULL && offset != NULL) {
|
if (dlinfo.dli_fbase != nullptr && offset != nullptr) {
|
||||||
*offset = addr - (address)dlinfo.dli_fbase;
|
*offset = addr - (address)dlinfo.dli_fbase;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -972,26 +972,26 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||||
log_info(os)("attempting shared library load of %s", filename);
|
log_info(os)("attempting shared library load of %s", filename);
|
||||||
|
|
||||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||||
if (result != NULL) {
|
if (result != nullptr) {
|
||||||
Events::log_dll_message(NULL, "Loaded shared library %s", filename);
|
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
|
||||||
// Successful loading
|
// Successful loading
|
||||||
log_info(os)("shared library load of %s was successful", filename);
|
log_info(os)("shared library load of %s was successful", filename);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* error_report = ::dlerror();
|
const char* error_report = ::dlerror();
|
||||||
if (error_report == NULL) {
|
if (error_report == nullptr) {
|
||||||
error_report = "dlerror returned no error description";
|
error_report = "dlerror returned no error description";
|
||||||
}
|
}
|
||||||
if (ebuf != NULL && ebuflen > 0) {
|
if (ebuf != nullptr && ebuflen > 0) {
|
||||||
// Read system error message into ebuf
|
// Read system error message into ebuf
|
||||||
::strncpy(ebuf, error_report, ebuflen-1);
|
::strncpy(ebuf, error_report, ebuflen-1);
|
||||||
ebuf[ebuflen-1]='\0';
|
ebuf[ebuflen-1]='\0';
|
||||||
}
|
}
|
||||||
Events::log_dll_message(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
Events::log_dll_message(nullptr, "Loading shared library %s failed, %s", filename, error_report);
|
||||||
log_info(os)("shared library load of %s failed, %s", filename, error_report);
|
log_info(os)("shared library load of %s failed, %s", filename, error_report);
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
#endif // STATIC_BUILD
|
#endif // STATIC_BUILD
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -1001,8 +1001,8 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||||
#else
|
#else
|
||||||
log_info(os)("attempting shared library load of %s", filename);
|
log_info(os)("attempting shared library load of %s", filename);
|
||||||
void * result= ::dlopen(filename, RTLD_LAZY);
|
void * result= ::dlopen(filename, RTLD_LAZY);
|
||||||
if (result != NULL) {
|
if (result != nullptr) {
|
||||||
Events::log_dll_message(NULL, "Loaded shared library %s", filename);
|
Events::log_dll_message(nullptr, "Loaded shared library %s", filename);
|
||||||
// Successful loading
|
// Successful loading
|
||||||
log_info(os)("shared library load of %s was successful", filename);
|
log_info(os)("shared library load of %s was successful", filename);
|
||||||
return result;
|
return result;
|
||||||
|
@ -1011,15 +1011,15 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||||
Elf32_Ehdr elf_head;
|
Elf32_Ehdr elf_head;
|
||||||
|
|
||||||
const char* const error_report = ::dlerror();
|
const char* const error_report = ::dlerror();
|
||||||
if (error_report == NULL) {
|
if (error_report == nullptr) {
|
||||||
error_report = "dlerror returned no error description";
|
error_report = "dlerror returned no error description";
|
||||||
}
|
}
|
||||||
if (ebuf != NULL && ebuflen > 0) {
|
if (ebuf != nullptr && ebuflen > 0) {
|
||||||
// Read system error message into ebuf
|
// Read system error message into ebuf
|
||||||
::strncpy(ebuf, error_report, ebuflen-1);
|
::strncpy(ebuf, error_report, ebuflen-1);
|
||||||
ebuf[ebuflen-1]='\0';
|
ebuf[ebuflen-1]='\0';
|
||||||
}
|
}
|
||||||
Events::log_dll_message(NULL, "Loading shared library %s failed, %s", filename, error_report);
|
Events::log_dll_message(nullptr, "Loading shared library %s failed, %s", filename, error_report);
|
||||||
log_info(os)("shared library load of %s failed, %s", filename, error_report);
|
log_info(os)("shared library load of %s failed, %s", filename, error_report);
|
||||||
|
|
||||||
int diag_msg_max_length=ebuflen-strlen(ebuf);
|
int diag_msg_max_length=ebuflen-strlen(ebuf);
|
||||||
|
@ -1027,7 +1027,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||||
|
|
||||||
if (diag_msg_max_length==0) {
|
if (diag_msg_max_length==0) {
|
||||||
// No more space in ebuf for additional diagnostics message
|
// No more space in ebuf for additional diagnostics message
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1035,7 +1035,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||||
|
|
||||||
if (file_descriptor < 0) {
|
if (file_descriptor < 0) {
|
||||||
// Can't open library, report dlerror() message
|
// Can't open library, report dlerror() message
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool failed_to_read_elf_head=
|
bool failed_to_read_elf_head=
|
||||||
|
@ -1045,7 +1045,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||||
::close(file_descriptor);
|
::close(file_descriptor);
|
||||||
if (failed_to_read_elf_head) {
|
if (failed_to_read_elf_head) {
|
||||||
// file i/o error - report dlerror() msg
|
// file i/o error - report dlerror() msg
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -1128,7 +1128,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||||
// Identify compatibility class for VM's architecture and library's architecture
|
// Identify compatibility class for VM's architecture and library's architecture
|
||||||
// Obtain string descriptions for architectures
|
// Obtain string descriptions for architectures
|
||||||
|
|
||||||
arch_t lib_arch={elf_head.e_machine,0,elf_head.e_ident[EI_CLASS], elf_head.e_ident[EI_DATA], NULL};
|
arch_t lib_arch={elf_head.e_machine,0,elf_head.e_ident[EI_CLASS], elf_head.e_ident[EI_DATA], nullptr};
|
||||||
int running_arch_index=-1;
|
int running_arch_index=-1;
|
||||||
|
|
||||||
for (unsigned int i=0; i < ARRAY_SIZE(arch_array); i++) {
|
for (unsigned int i=0; i < ARRAY_SIZE(arch_array); i++) {
|
||||||
|
@ -1146,23 +1146,23 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||||
if (running_arch_index == -1) {
|
if (running_arch_index == -1) {
|
||||||
// Even though running architecture detection failed
|
// Even though running architecture detection failed
|
||||||
// we may still continue with reporting dlerror() message
|
// we may still continue with reporting dlerror() message
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lib_arch.endianess != arch_array[running_arch_index].endianess) {
|
if (lib_arch.endianess != arch_array[running_arch_index].endianess) {
|
||||||
::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: endianness mismatch)");
|
::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: endianness mismatch)");
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef S390
|
#ifndef S390
|
||||||
if (lib_arch.elf_class != arch_array[running_arch_index].elf_class) {
|
if (lib_arch.elf_class != arch_array[running_arch_index].elf_class) {
|
||||||
::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: architecture word width mismatch)");
|
::snprintf(diag_msg_buf, diag_msg_max_length-1," (Possible cause: architecture word width mismatch)");
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
#endif // !S390
|
#endif // !S390
|
||||||
|
|
||||||
if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) {
|
if (lib_arch.compat_class != arch_array[running_arch_index].compat_class) {
|
||||||
if (lib_arch.name!=NULL) {
|
if (lib_arch.name!=nullptr) {
|
||||||
::snprintf(diag_msg_buf, diag_msg_max_length-1,
|
::snprintf(diag_msg_buf, diag_msg_max_length-1,
|
||||||
" (Possible cause: can't load %s-bit .so on a %s-bit platform)",
|
" (Possible cause: can't load %s-bit .so on a %s-bit platform)",
|
||||||
lib_arch.name, arch_array[running_arch_index].name);
|
lib_arch.name, arch_array[running_arch_index].name);
|
||||||
|
@ -1174,7 +1174,7 @@ void * os::dll_load(const char *filename, char *ebuf, int ebuflen) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
#endif // STATIC_BUILD
|
#endif // STATIC_BUILD
|
||||||
}
|
}
|
||||||
#endif // !__APPLE__
|
#endif // !__APPLE__
|
||||||
|
@ -1200,23 +1200,23 @@ int os::get_loaded_modules_info(os::LoadedModulesCallbackFunc callback, void *pa
|
||||||
Link_map *p;
|
Link_map *p;
|
||||||
|
|
||||||
if (dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli) == 0 ||
|
if (dladdr(CAST_FROM_FN_PTR(void *, os::print_dll_info), &dli) == 0 ||
|
||||||
dli.dli_fname == NULL) {
|
dli.dli_fname == nullptr) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
handle = dlopen(dli.dli_fname, RTLD_LAZY);
|
handle = dlopen(dli.dli_fname, RTLD_LAZY);
|
||||||
if (handle == NULL) {
|
if (handle == nullptr) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
dlinfo(handle, RTLD_DI_LINKMAP, &map);
|
dlinfo(handle, RTLD_DI_LINKMAP, &map);
|
||||||
if (map == NULL) {
|
if (map == nullptr) {
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (map->l_prev != NULL)
|
while (map->l_prev != nullptr)
|
||||||
map = map->l_prev;
|
map = map->l_prev;
|
||||||
|
|
||||||
while (map != NULL) {
|
while (map != nullptr) {
|
||||||
// Value for top_address is returned as 0 since we don't have any information about module size
|
// Value for top_address is returned as 0 since we don't have any information about module size
|
||||||
if (callback(map->l_name, (address)map->l_addr, (address)0, param)) {
|
if (callback(map->l_name, (address)map->l_addr, (address)0, param)) {
|
||||||
dlclose(handle);
|
dlclose(handle);
|
||||||
|
@ -1245,7 +1245,7 @@ void os::get_summary_os_info(char* buf, size_t buflen) {
|
||||||
char os[100];
|
char os[100];
|
||||||
size_t size = sizeof(os);
|
size_t size = sizeof(os);
|
||||||
int mib_kern[] = { CTL_KERN, KERN_OSTYPE };
|
int mib_kern[] = { CTL_KERN, KERN_OSTYPE };
|
||||||
if (sysctl(mib_kern, 2, os, &size, NULL, 0) < 0) {
|
if (sysctl(mib_kern, 2, os, &size, nullptr, 0) < 0) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
strncpy(os, "Darwin", sizeof(os));
|
strncpy(os, "Darwin", sizeof(os));
|
||||||
#elif __OpenBSD__
|
#elif __OpenBSD__
|
||||||
|
@ -1258,7 +1258,7 @@ void os::get_summary_os_info(char* buf, size_t buflen) {
|
||||||
char release[100];
|
char release[100];
|
||||||
size = sizeof(release);
|
size = sizeof(release);
|
||||||
int mib_release[] = { CTL_KERN, KERN_OSRELEASE };
|
int mib_release[] = { CTL_KERN, KERN_OSRELEASE };
|
||||||
if (sysctl(mib_release, 2, release, &size, NULL, 0) < 0) {
|
if (sysctl(mib_release, 2, release, &size, nullptr, 0) < 0) {
|
||||||
// if error, leave blank
|
// if error, leave blank
|
||||||
strncpy(release, "", sizeof(release));
|
strncpy(release, "", sizeof(release));
|
||||||
}
|
}
|
||||||
|
@ -1266,12 +1266,12 @@ void os::get_summary_os_info(char* buf, size_t buflen) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
char osproductversion[100];
|
char osproductversion[100];
|
||||||
size_t sz = sizeof(osproductversion);
|
size_t sz = sizeof(osproductversion);
|
||||||
int ret = sysctlbyname("kern.osproductversion", osproductversion, &sz, NULL, 0);
|
int ret = sysctlbyname("kern.osproductversion", osproductversion, &sz, nullptr, 0);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
char build[100];
|
char build[100];
|
||||||
size = sizeof(build);
|
size = sizeof(build);
|
||||||
int mib_build[] = { CTL_KERN, KERN_OSVERSION };
|
int mib_build[] = { CTL_KERN, KERN_OSVERSION };
|
||||||
if (sysctl(mib_build, 2, build, &size, NULL, 0) < 0) {
|
if (sysctl(mib_build, 2, build, &size, nullptr, 0) < 0) {
|
||||||
snprintf(buf, buflen, "%s %s, macOS %s", os, release, osproductversion);
|
snprintf(buf, buflen, "%s %s, macOS %s", os, release, osproductversion);
|
||||||
} else {
|
} else {
|
||||||
snprintf(buf, buflen, "%s %s, macOS %s (%s)", os, release, osproductversion, build);
|
snprintf(buf, buflen, "%s %s, macOS %s (%s)", os, release, osproductversion, build);
|
||||||
|
@ -1307,7 +1307,7 @@ void os::get_summary_cpu_info(char* buf, size_t buflen) {
|
||||||
unsigned int mhz;
|
unsigned int mhz;
|
||||||
size_t size = sizeof(mhz);
|
size_t size = sizeof(mhz);
|
||||||
int mib[] = { CTL_HW, HW_CPU_FREQ };
|
int mib[] = { CTL_HW, HW_CPU_FREQ };
|
||||||
if (sysctl(mib, 2, &mhz, &size, NULL, 0) < 0) {
|
if (sysctl(mib, 2, &mhz, &size, nullptr, 0) < 0) {
|
||||||
mhz = 1; // looks like an error but can be divided by
|
mhz = 1; // looks like an error but can be divided by
|
||||||
} else {
|
} else {
|
||||||
mhz /= 1000000; // reported in millions
|
mhz /= 1000000; // reported in millions
|
||||||
|
@ -1316,14 +1316,14 @@ void os::get_summary_cpu_info(char* buf, size_t buflen) {
|
||||||
char model[100];
|
char model[100];
|
||||||
size = sizeof(model);
|
size = sizeof(model);
|
||||||
int mib_model[] = { CTL_HW, HW_MODEL };
|
int mib_model[] = { CTL_HW, HW_MODEL };
|
||||||
if (sysctl(mib_model, 2, model, &size, NULL, 0) < 0) {
|
if (sysctl(mib_model, 2, model, &size, nullptr, 0) < 0) {
|
||||||
strncpy(model, cpu_arch, sizeof(model));
|
strncpy(model, cpu_arch, sizeof(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
char machine[100];
|
char machine[100];
|
||||||
size = sizeof(machine);
|
size = sizeof(machine);
|
||||||
int mib_machine[] = { CTL_HW, HW_MACHINE };
|
int mib_machine[] = { CTL_HW, HW_MACHINE };
|
||||||
if (sysctl(mib_machine, 2, machine, &size, NULL, 0) < 0) {
|
if (sysctl(mib_machine, 2, machine, &size, nullptr, 0) < 0) {
|
||||||
strncpy(machine, "", sizeof(machine));
|
strncpy(machine, "", sizeof(machine));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1352,7 +1352,7 @@ void os::print_memory_info(outputStream* st) {
|
||||||
st->print("(" UINT64_FORMAT "k free)",
|
st->print("(" UINT64_FORMAT "k free)",
|
||||||
os::available_memory() >> 10);
|
os::available_memory() >> 10);
|
||||||
|
|
||||||
if((sysctlbyname("vm.swapusage", &swap_usage, &size, NULL, 0) == 0) || (errno == ENOMEM)) {
|
if((sysctlbyname("vm.swapusage", &swap_usage, &size, nullptr, 0) == 0) || (errno == ENOMEM)) {
|
||||||
if (size >= offset_of(xsw_usage, xsu_used)) {
|
if (size >= offset_of(xsw_usage, xsu_used)) {
|
||||||
st->print(", swap " UINT64_FORMAT "k",
|
st->print(", swap " UINT64_FORMAT "k",
|
||||||
((julong) swap_usage.xsu_total) >> 10);
|
((julong) swap_usage.xsu_total) >> 10);
|
||||||
|
@ -1384,13 +1384,13 @@ void os::jvm_path(char *buf, jint buflen) {
|
||||||
dli_fname[0] = '\0';
|
dli_fname[0] = '\0';
|
||||||
bool ret = dll_address_to_library_name(
|
bool ret = dll_address_to_library_name(
|
||||||
CAST_FROM_FN_PTR(address, os::jvm_path),
|
CAST_FROM_FN_PTR(address, os::jvm_path),
|
||||||
dli_fname, sizeof(dli_fname), NULL);
|
dli_fname, sizeof(dli_fname), nullptr);
|
||||||
assert(ret, "cannot locate libjvm");
|
assert(ret, "cannot locate libjvm");
|
||||||
char *rp = NULL;
|
char *rp = nullptr;
|
||||||
if (ret && dli_fname[0] != '\0') {
|
if (ret && dli_fname[0] != '\0') {
|
||||||
rp = os::Posix::realpath(dli_fname, buf, buflen);
|
rp = os::Posix::realpath(dli_fname, buf, buflen);
|
||||||
}
|
}
|
||||||
if (rp == NULL) {
|
if (rp == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1412,7 +1412,7 @@ void os::jvm_path(char *buf, jint buflen) {
|
||||||
if (strncmp(p, "/jre/lib/", 9) != 0) {
|
if (strncmp(p, "/jre/lib/", 9) != 0) {
|
||||||
// Look for JAVA_HOME in the environment.
|
// Look for JAVA_HOME in the environment.
|
||||||
char* java_home_var = ::getenv("JAVA_HOME");
|
char* java_home_var = ::getenv("JAVA_HOME");
|
||||||
if (java_home_var != NULL && java_home_var[0] != 0) {
|
if (java_home_var != nullptr && java_home_var[0] != 0) {
|
||||||
char* jrelib_p;
|
char* jrelib_p;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
@ -1421,7 +1421,7 @@ void os::jvm_path(char *buf, jint buflen) {
|
||||||
assert(strstr(p, "/libjvm") == p, "invalid library name");
|
assert(strstr(p, "/libjvm") == p, "invalid library name");
|
||||||
|
|
||||||
rp = os::Posix::realpath(java_home_var, buf, buflen);
|
rp = os::Posix::realpath(java_home_var, buf, buflen);
|
||||||
if (rp == NULL) {
|
if (rp == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1455,7 +1455,7 @@ void os::jvm_path(char *buf, jint buflen) {
|
||||||
} else {
|
} else {
|
||||||
// Fall back to path of current library
|
// Fall back to path of current library
|
||||||
rp = os::Posix::realpath(dli_fname, buf, buflen);
|
rp = os::Posix::realpath(dli_fname, buf, buflen);
|
||||||
if (rp == NULL) {
|
if (rp == nullptr) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1485,7 +1485,7 @@ bool os::pd_commit_memory(char* addr, size_t size, bool exec) {
|
||||||
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
|
int prot = exec ? PROT_READ|PROT_WRITE|PROT_EXEC : PROT_READ|PROT_WRITE;
|
||||||
#if defined(__OpenBSD__)
|
#if defined(__OpenBSD__)
|
||||||
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
|
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
|
||||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
|
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(addr), p2i(addr+size), prot);
|
||||||
if (::mprotect(addr, size, prot) == 0) {
|
if (::mprotect(addr, size, prot) == 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1525,7 +1525,7 @@ bool os::pd_commit_memory(char* addr, size_t size, size_t alignment_hint,
|
||||||
|
|
||||||
void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec,
|
void os::pd_commit_memory_or_exit(char* addr, size_t size, bool exec,
|
||||||
const char* mesg) {
|
const char* mesg) {
|
||||||
assert(mesg != NULL, "mesg must be specified");
|
assert(mesg != nullptr, "mesg must be specified");
|
||||||
if (!pd_commit_memory(addr, size, exec)) {
|
if (!pd_commit_memory(addr, size, exec)) {
|
||||||
// add extra info in product mode for vm_exit_out_of_memory():
|
// add extra info in product mode for vm_exit_out_of_memory():
|
||||||
PRODUCT_ONLY(warn_fail_commit_memory(addr, size, exec, errno);)
|
PRODUCT_ONLY(warn_fail_commit_memory(addr, size, exec, errno);)
|
||||||
|
@ -1587,7 +1587,7 @@ char *os::scan_pages(char *start, char* end, page_info* page_expected, page_info
|
||||||
bool os::pd_uncommit_memory(char* addr, size_t size, bool exec) {
|
bool os::pd_uncommit_memory(char* addr, size_t size, bool exec) {
|
||||||
#if defined(__OpenBSD__)
|
#if defined(__OpenBSD__)
|
||||||
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
|
// XXX: Work-around mmap/MAP_FIXED bug temporarily on OpenBSD
|
||||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size));
|
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with PROT_NONE", p2i(addr), p2i(addr+size));
|
||||||
return ::mprotect(addr, size, PROT_NONE) == 0;
|
return ::mprotect(addr, size, PROT_NONE) == 0;
|
||||||
#elif defined(__APPLE__)
|
#elif defined(__APPLE__)
|
||||||
if (exec) {
|
if (exec) {
|
||||||
|
@ -1619,7 +1619,7 @@ bool os::remove_stack_guard_pages(char* addr, size_t size) {
|
||||||
|
|
||||||
// 'requested_addr' is only treated as a hint, the return value may or
|
// 'requested_addr' is only treated as a hint, the return value may or
|
||||||
// may not start from the requested address. Unlike Bsd mmap(), this
|
// may not start from the requested address. Unlike Bsd mmap(), this
|
||||||
// function returns NULL to indicate failure.
|
// function returns null to indicate failure.
|
||||||
static char* anon_mmap(char* requested_addr, size_t bytes, bool exec) {
|
static char* anon_mmap(char* requested_addr, size_t bytes, bool exec) {
|
||||||
// MAP_FIXED is intentionally left out, to leave existing mappings intact.
|
// MAP_FIXED is intentionally left out, to leave existing mappings intact.
|
||||||
const int flags = MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS
|
const int flags = MAP_PRIVATE | MAP_NORESERVE | MAP_ANONYMOUS
|
||||||
|
@ -1630,7 +1630,7 @@ static char* anon_mmap(char* requested_addr, size_t bytes, bool exec) {
|
||||||
// succeed if we have enough swap space to back the physical page.
|
// succeed if we have enough swap space to back the physical page.
|
||||||
char* addr = (char*)::mmap(requested_addr, bytes, PROT_NONE, flags, -1, 0);
|
char* addr = (char*)::mmap(requested_addr, bytes, PROT_NONE, flags, -1, 0);
|
||||||
|
|
||||||
return addr == MAP_FAILED ? NULL : addr;
|
return addr == MAP_FAILED ? nullptr : addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int anon_munmap(char * addr, size_t size) {
|
static int anon_munmap(char * addr, size_t size) {
|
||||||
|
@ -1638,7 +1638,7 @@ static int anon_munmap(char * addr, size_t size) {
|
||||||
}
|
}
|
||||||
|
|
||||||
char* os::pd_reserve_memory(size_t bytes, bool exec) {
|
char* os::pd_reserve_memory(size_t bytes, bool exec) {
|
||||||
return anon_mmap(NULL /* addr */, bytes, exec);
|
return anon_mmap(nullptr /* addr */, bytes, exec);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::pd_release_memory(char* addr, size_t size) {
|
bool os::pd_release_memory(char* addr, size_t size) {
|
||||||
|
@ -1657,7 +1657,7 @@ static bool bsd_mprotect(char* addr, size_t size, int prot) {
|
||||||
assert(addr == bottom, "sanity check");
|
assert(addr == bottom, "sanity check");
|
||||||
|
|
||||||
size = align_up(pointer_delta(addr, bottom, 1) + size, os::vm_page_size());
|
size = align_up(pointer_delta(addr, bottom, 1) + size, os::vm_page_size());
|
||||||
Events::log(NULL, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
|
Events::log(nullptr, "Protecting memory [" INTPTR_FORMAT "," INTPTR_FORMAT "] with protection modes %x", p2i(bottom), p2i(bottom+size), prot);
|
||||||
return ::mprotect(bottom, size, prot) == 0;
|
return ::mprotect(bottom, size, prot) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1699,7 +1699,7 @@ void os::large_page_init() {
|
||||||
|
|
||||||
char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, size_t page_size, char* req_addr, bool exec) {
|
char* os::pd_reserve_memory_special(size_t bytes, size_t alignment, size_t page_size, char* req_addr, bool exec) {
|
||||||
fatal("os::reserve_memory_special should not be called on BSD.");
|
fatal("os::reserve_memory_special should not be called on BSD.");
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool os::pd_release_memory_special(char* base, size_t bytes) {
|
bool os::pd_release_memory_special(char* base, size_t bytes) {
|
||||||
|
@ -1724,8 +1724,8 @@ bool os::can_execute_large_page_memory() {
|
||||||
char* os::pd_attempt_map_memory_to_file_at(char* requested_addr, size_t bytes, int file_desc) {
|
char* os::pd_attempt_map_memory_to_file_at(char* requested_addr, size_t bytes, int file_desc) {
|
||||||
assert(file_desc >= 0, "file_desc is not valid");
|
assert(file_desc >= 0, "file_desc is not valid");
|
||||||
char* result = pd_attempt_reserve_memory_at(requested_addr, bytes, !ExecMem);
|
char* result = pd_attempt_reserve_memory_at(requested_addr, bytes, !ExecMem);
|
||||||
if (result != NULL) {
|
if (result != nullptr) {
|
||||||
if (replace_existing_mapping_with_file_mapping(result, bytes, file_desc) == NULL) {
|
if (replace_existing_mapping_with_file_mapping(result, bytes, file_desc) == nullptr) {
|
||||||
vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory"));
|
vm_exit_during_initialization(err_msg("Error in mapping Java heap at the given filesystem directory"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1753,12 +1753,12 @@ char* os::pd_attempt_reserve_memory_at(char* requested_addr, size_t bytes, bool
|
||||||
return requested_addr;
|
return requested_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr != NULL) {
|
if (addr != nullptr) {
|
||||||
// mmap() is successful but it fails to reserve at the requested address
|
// mmap() is successful but it fails to reserve at the requested address
|
||||||
anon_munmap(addr, bytes);
|
anon_munmap(addr, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used to convert frequent JVM_Yield() to nops
|
// Used to convert frequent JVM_Yield() to nops
|
||||||
|
@ -2006,7 +2006,7 @@ jint os::init_2(void) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
// dynamically link to objective c gc registration
|
// dynamically link to objective c gc registration
|
||||||
void *handleLibObjc = dlopen(OBJC_LIB, RTLD_LAZY);
|
void *handleLibObjc = dlopen(OBJC_LIB, RTLD_LAZY);
|
||||||
if (handleLibObjc != NULL) {
|
if (handleLibObjc != nullptr) {
|
||||||
objc_registerThreadWithCollectorFunction = (objc_registerThreadWithCollector_t) dlsym(handleLibObjc, OBJC_GCREGISTER);
|
objc_registerThreadWithCollectorFunction = (objc_registerThreadWithCollector_t) dlsym(handleLibObjc, OBJC_GCREGISTER);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2069,7 +2069,7 @@ uint os::processor_id() {
|
||||||
void os::set_native_thread_name(const char *name) {
|
void os::set_native_thread_name(const char *name) {
|
||||||
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
|
#if defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5
|
||||||
// This is only supported in Snow Leopard and beyond
|
// This is only supported in Snow Leopard and beyond
|
||||||
if (name != NULL) {
|
if (name != nullptr) {
|
||||||
// Add a "Java: " prefix to the name
|
// Add a "Java: " prefix to the name
|
||||||
char buf[MAXTHREADNAMESIZE];
|
char buf[MAXTHREADNAMESIZE];
|
||||||
snprintf(buf, sizeof(buf), "Java: %s", name);
|
snprintf(buf, sizeof(buf), "Java: %s", name);
|
||||||
|
@ -2086,18 +2086,18 @@ bool os::find(address addr, outputStream* st) {
|
||||||
memset(&dlinfo, 0, sizeof(dlinfo));
|
memset(&dlinfo, 0, sizeof(dlinfo));
|
||||||
if (dladdr(addr, &dlinfo) != 0) {
|
if (dladdr(addr, &dlinfo) != 0) {
|
||||||
st->print(INTPTR_FORMAT ": ", (intptr_t)addr);
|
st->print(INTPTR_FORMAT ": ", (intptr_t)addr);
|
||||||
if (dlinfo.dli_sname != NULL && dlinfo.dli_saddr != NULL) {
|
if (dlinfo.dli_sname != nullptr && dlinfo.dli_saddr != nullptr) {
|
||||||
st->print("%s+%#x", dlinfo.dli_sname,
|
st->print("%s+%#x", dlinfo.dli_sname,
|
||||||
(uint)((uintptr_t)addr - (uintptr_t)dlinfo.dli_saddr));
|
(uint)((uintptr_t)addr - (uintptr_t)dlinfo.dli_saddr));
|
||||||
} else if (dlinfo.dli_fbase != NULL) {
|
} else if (dlinfo.dli_fbase != nullptr) {
|
||||||
st->print("<offset %#x>", (uint)((uintptr_t)addr - (uintptr_t)dlinfo.dli_fbase));
|
st->print("<offset %#x>", (uint)((uintptr_t)addr - (uintptr_t)dlinfo.dli_fbase));
|
||||||
} else {
|
} else {
|
||||||
st->print("<absolute address>");
|
st->print("<absolute address>");
|
||||||
}
|
}
|
||||||
if (dlinfo.dli_fname != NULL) {
|
if (dlinfo.dli_fname != nullptr) {
|
||||||
st->print(" in %s", dlinfo.dli_fname);
|
st->print(" in %s", dlinfo.dli_fname);
|
||||||
}
|
}
|
||||||
if (dlinfo.dli_fbase != NULL) {
|
if (dlinfo.dli_fbase != nullptr) {
|
||||||
st->print(" at " INTPTR_FORMAT, (intptr_t)dlinfo.dli_fbase);
|
st->print(" at " INTPTR_FORMAT, (intptr_t)dlinfo.dli_fbase);
|
||||||
}
|
}
|
||||||
st->cr();
|
st->cr();
|
||||||
|
@ -2246,14 +2246,14 @@ char* os::pd_map_memory(int fd, const char* file_name, size_t file_offset,
|
||||||
prot |= PROT_EXEC;
|
prot |= PROT_EXEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr != NULL) {
|
if (addr != nullptr) {
|
||||||
flags |= MAP_FIXED;
|
flags |= MAP_FIXED;
|
||||||
}
|
}
|
||||||
|
|
||||||
char* mapped_address = (char*)mmap(addr, (size_t)bytes, prot, flags,
|
char* mapped_address = (char*)mmap(addr, (size_t)bytes, prot, flags,
|
||||||
fd, file_offset);
|
fd, file_offset);
|
||||||
if (mapped_address == MAP_FAILED) {
|
if (mapped_address == MAP_FAILED) {
|
||||||
return NULL;
|
return nullptr;
|
||||||
}
|
}
|
||||||
return mapped_address;
|
return mapped_address;
|
||||||
}
|
}
|
||||||
|
@ -2372,13 +2372,13 @@ int os::get_core_path(char* buffer, size_t bufferSize) {
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
char coreinfo[MAX_PATH];
|
char coreinfo[MAX_PATH];
|
||||||
size_t sz = sizeof(coreinfo);
|
size_t sz = sizeof(coreinfo);
|
||||||
int ret = sysctlbyname("kern.corefile", coreinfo, &sz, NULL, 0);
|
int ret = sysctlbyname("kern.corefile", coreinfo, &sz, nullptr, 0);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
char *pid_pos = strstr(coreinfo, "%P");
|
char *pid_pos = strstr(coreinfo, "%P");
|
||||||
// skip over the "%P" to preserve any optional custom user pattern
|
// skip over the "%P" to preserve any optional custom user pattern
|
||||||
const char* tail = (pid_pos != NULL) ? (pid_pos + 2) : "";
|
const char* tail = (pid_pos != nullptr) ? (pid_pos + 2) : "";
|
||||||
|
|
||||||
if (pid_pos != NULL) {
|
if (pid_pos != nullptr) {
|
||||||
*pid_pos = '\0';
|
*pid_pos = '\0';
|
||||||
n = jio_snprintf(buffer, bufferSize, "%s%d%s", coreinfo, os::current_process_id(), tail);
|
n = jio_snprintf(buffer, bufferSize, "%s%d%s", coreinfo, os::current_process_id(), tail);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1999, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -97,17 +97,17 @@ class os::Bsd {
|
||||||
static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
|
static void set_numa_interleave_memory(numa_interleave_memory_func_t func) { _numa_interleave_memory = func; }
|
||||||
static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
|
static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
|
||||||
public:
|
public:
|
||||||
static int sched_getcpu() { return _sched_getcpu != NULL ? _sched_getcpu() : -1; }
|
static int sched_getcpu() { return _sched_getcpu != nullptr ? _sched_getcpu() : -1; }
|
||||||
static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
|
static int numa_node_to_cpus(int node, unsigned long *buffer, int bufferlen) {
|
||||||
return _numa_node_to_cpus != NULL ? _numa_node_to_cpus(node, buffer, bufferlen) : -1;
|
return _numa_node_to_cpus != nullptr ? _numa_node_to_cpus(node, buffer, bufferlen) : -1;
|
||||||
}
|
}
|
||||||
static int numa_max_node() { return _numa_max_node != NULL ? _numa_max_node() : -1; }
|
static int numa_max_node() { return _numa_max_node != nullptr ? _numa_max_node() : -1; }
|
||||||
static int numa_available() { return _numa_available != NULL ? _numa_available() : -1; }
|
static int numa_available() { return _numa_available != nullptr ? _numa_available() : -1; }
|
||||||
static int numa_tonode_memory(void *start, size_t size, int node) {
|
static int numa_tonode_memory(void *start, size_t size, int node) {
|
||||||
return _numa_tonode_memory != NULL ? _numa_tonode_memory(start, size, node) : -1;
|
return _numa_tonode_memory != nullptr ? _numa_tonode_memory(start, size, node) : -1;
|
||||||
}
|
}
|
||||||
static void numa_interleave_memory(void *start, size_t size) {
|
static void numa_interleave_memory(void *start, size_t size) {
|
||||||
if (_numa_interleave_memory != NULL && _numa_all_nodes != NULL) {
|
if (_numa_interleave_memory != nullptr && _numa_all_nodes != nullptr) {
|
||||||
_numa_interleave_memory(start, size, _numa_all_nodes);
|
_numa_interleave_memory(start, size, _numa_all_nodes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
|
@ -231,7 +231,7 @@ int CPUPerformanceInterface::CPUPerformance::context_switch_rate(double* rate) {
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUPerformanceInterface::CPUPerformanceInterface() {
|
CPUPerformanceInterface::CPUPerformanceInterface() {
|
||||||
_impl = NULL;
|
_impl = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPUPerformanceInterface::initialize() {
|
bool CPUPerformanceInterface::initialize() {
|
||||||
|
@ -240,7 +240,7 @@ bool CPUPerformanceInterface::initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
||||||
if (_impl != NULL) {
|
if (_impl != nullptr) {
|
||||||
delete _impl;
|
delete _impl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -283,17 +283,17 @@ bool SystemProcessInterface::SystemProcesses::initialize() {
|
||||||
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
||||||
}
|
}
|
||||||
int SystemProcessInterface::SystemProcesses::system_processes(SystemProcess** system_processes, int* no_of_sys_processes) const {
|
int SystemProcessInterface::SystemProcesses::system_processes(SystemProcess** system_processes, int* no_of_sys_processes) const {
|
||||||
assert(system_processes != NULL, "system_processes pointer is NULL!");
|
assert(system_processes != nullptr, "system_processes pointer is null!");
|
||||||
assert(no_of_sys_processes != NULL, "system_processes counter pointer is NULL!");
|
assert(no_of_sys_processes != nullptr, "system_processes counter pointer is null!");
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
pid_t* pids = NULL;
|
pid_t* pids = nullptr;
|
||||||
int pid_count = 0;
|
int pid_count = 0;
|
||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
|
|
||||||
int try_count = 0;
|
int try_count = 0;
|
||||||
while (pids == NULL) {
|
while (pids == nullptr) {
|
||||||
// Find out buffer size
|
// Find out buffer size
|
||||||
size_t pids_bytes = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0);
|
size_t pids_bytes = proc_listpids(PROC_ALL_PIDS, 0, nullptr, 0);
|
||||||
if (pids_bytes <= 0) {
|
if (pids_bytes <= 0) {
|
||||||
return OS_ERR;
|
return OS_ERR;
|
||||||
}
|
}
|
||||||
|
@ -305,7 +305,7 @@ int SystemProcessInterface::SystemProcesses::system_processes(SystemProcess** sy
|
||||||
if (pids_bytes <= 0) {
|
if (pids_bytes <= 0) {
|
||||||
// couldn't fit buffer, retry.
|
// couldn't fit buffer, retry.
|
||||||
FREE_RESOURCE_ARRAY(pid_t, pids, pid_count);
|
FREE_RESOURCE_ARRAY(pid_t, pids, pid_count);
|
||||||
pids = NULL;
|
pids = nullptr;
|
||||||
try_count++;
|
try_count++;
|
||||||
if (try_count > 3) {
|
if (try_count > 3) {
|
||||||
return OS_ERR;
|
return OS_ERR;
|
||||||
|
@ -316,7 +316,7 @@ int SystemProcessInterface::SystemProcesses::system_processes(SystemProcess** sy
|
||||||
}
|
}
|
||||||
|
|
||||||
int process_count = 0;
|
int process_count = 0;
|
||||||
SystemProcess* next = NULL;
|
SystemProcess* next = nullptr;
|
||||||
for (int i = 0; i < pid_count; i++) {
|
for (int i = 0; i < pid_count; i++) {
|
||||||
pid_t pid = pids[i];
|
pid_t pid = pids[i];
|
||||||
if (pid != 0) {
|
if (pid != 0) {
|
||||||
|
@ -351,7 +351,7 @@ int SystemProcessInterface::system_processes(SystemProcess** system_procs, int*
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::SystemProcessInterface() {
|
SystemProcessInterface::SystemProcessInterface() {
|
||||||
_impl = NULL;
|
_impl = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SystemProcessInterface::initialize() {
|
bool SystemProcessInterface::initialize() {
|
||||||
|
@ -360,13 +360,13 @@ bool SystemProcessInterface::initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
SystemProcessInterface::~SystemProcessInterface() {
|
SystemProcessInterface::~SystemProcessInterface() {
|
||||||
if (_impl != NULL) {
|
if (_impl != nullptr) {
|
||||||
delete _impl;
|
delete _impl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUInformationInterface::CPUInformationInterface() {
|
CPUInformationInterface::CPUInformationInterface() {
|
||||||
_cpu_info = NULL;
|
_cpu_info = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPUInformationInterface::initialize() {
|
bool CPUInformationInterface::initialize() {
|
||||||
|
@ -381,23 +381,23 @@ bool CPUInformationInterface::initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUInformationInterface::~CPUInformationInterface() {
|
CPUInformationInterface::~CPUInformationInterface() {
|
||||||
if (_cpu_info != NULL) {
|
if (_cpu_info != nullptr) {
|
||||||
if (_cpu_info->cpu_name() != NULL) {
|
if (_cpu_info->cpu_name() != nullptr) {
|
||||||
const char* cpu_name = _cpu_info->cpu_name();
|
const char* cpu_name = _cpu_info->cpu_name();
|
||||||
FREE_C_HEAP_ARRAY(char, cpu_name);
|
FREE_C_HEAP_ARRAY(char, cpu_name);
|
||||||
_cpu_info->set_cpu_name(NULL);
|
_cpu_info->set_cpu_name(nullptr);
|
||||||
}
|
}
|
||||||
if (_cpu_info->cpu_description() != NULL) {
|
if (_cpu_info->cpu_description() != nullptr) {
|
||||||
const char* cpu_desc = _cpu_info->cpu_description();
|
const char* cpu_desc = _cpu_info->cpu_description();
|
||||||
FREE_C_HEAP_ARRAY(char, cpu_desc);
|
FREE_C_HEAP_ARRAY(char, cpu_desc);
|
||||||
_cpu_info->set_cpu_description(NULL);
|
_cpu_info->set_cpu_description(nullptr);
|
||||||
}
|
}
|
||||||
delete _cpu_info;
|
delete _cpu_info;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int CPUInformationInterface::cpu_information(CPUInformation& cpu_info) {
|
int CPUInformationInterface::cpu_information(CPUInformation& cpu_info) {
|
||||||
if (NULL == _cpu_info) {
|
if (nullptr == _cpu_info) {
|
||||||
return OS_ERR;
|
return OS_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -428,16 +428,16 @@ NetworkPerformanceInterface::NetworkPerformance::~NetworkPerformance() {
|
||||||
int NetworkPerformanceInterface::NetworkPerformance::network_utilization(NetworkInterface** network_interfaces) const {
|
int NetworkPerformanceInterface::NetworkPerformance::network_utilization(NetworkInterface** network_interfaces) const {
|
||||||
size_t len;
|
size_t len;
|
||||||
int mib[] = {CTL_NET, PF_ROUTE, /* protocol number */ 0, /* address family */ 0, NET_RT_IFLIST2, /* NET_RT_FLAGS mask*/ 0};
|
int mib[] = {CTL_NET, PF_ROUTE, /* protocol number */ 0, /* address family */ 0, NET_RT_IFLIST2, /* NET_RT_FLAGS mask*/ 0};
|
||||||
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), NULL, &len, NULL, 0) != 0) {
|
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), nullptr, &len, nullptr, 0) != 0) {
|
||||||
return OS_ERR;
|
return OS_ERR;
|
||||||
}
|
}
|
||||||
uint8_t* buf = NEW_RESOURCE_ARRAY(uint8_t, len);
|
uint8_t* buf = NEW_RESOURCE_ARRAY(uint8_t, len);
|
||||||
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &len, NULL, 0) != 0) {
|
if (sysctl(mib, sizeof(mib) / sizeof(mib[0]), buf, &len, nullptr, 0) != 0) {
|
||||||
return OS_ERR;
|
return OS_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t index = 0;
|
size_t index = 0;
|
||||||
NetworkInterface* ret = NULL;
|
NetworkInterface* ret = nullptr;
|
||||||
while (index < len) {
|
while (index < len) {
|
||||||
if_msghdr* msghdr = reinterpret_cast<if_msghdr*>(buf + index);
|
if_msghdr* msghdr = reinterpret_cast<if_msghdr*>(buf + index);
|
||||||
index += msghdr->ifm_msglen;
|
index += msghdr->ifm_msglen;
|
||||||
|
@ -468,11 +468,11 @@ int NetworkPerformanceInterface::NetworkPerformance::network_utilization(Network
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkPerformanceInterface::NetworkPerformanceInterface() {
|
NetworkPerformanceInterface::NetworkPerformanceInterface() {
|
||||||
_impl = NULL;
|
_impl = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkPerformanceInterface::~NetworkPerformanceInterface() {
|
NetworkPerformanceInterface::~NetworkPerformanceInterface() {
|
||||||
if (_impl != NULL) {
|
if (_impl != nullptr) {
|
||||||
delete _impl;
|
delete _impl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue