8301479: Replace NULL with nullptr in os/linux
Reviewed-by: coleenp, sgehwolf
This commit is contained in:
parent
cf68d9fb8e
commit
ac9e046748
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -83,7 +83,7 @@ class LinuxAttachListener: AllStatic {
|
||||
};
|
||||
|
||||
static void set_path(char* path) {
|
||||
if (path == NULL) {
|
||||
if (path == nullptr) {
|
||||
_path[0] = '\0';
|
||||
_has_path = false;
|
||||
} else {
|
||||
@ -146,7 +146,7 @@ class ArgumentIterator : public StackObj {
|
||||
if (_pos < _end) {
|
||||
_pos += 1;
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
char* res = _pos;
|
||||
char* next_pos = strchr(_pos, '\0');
|
||||
@ -171,7 +171,7 @@ extern "C" {
|
||||
}
|
||||
if (LinuxAttachListener::has_path()) {
|
||||
::unlink(LinuxAttachListener::path());
|
||||
LinuxAttachListener::set_path(NULL);
|
||||
LinuxAttachListener::set_path(nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ LinuxAttachOperation* LinuxAttachListener::read_request(int s) {
|
||||
assert(n <= left, "buffer was too small, impossible!");
|
||||
buf[max_len - 1] = '\0';
|
||||
if (n == -1) {
|
||||
return NULL; // reset by peer or other error
|
||||
return nullptr; // reset by peer or other error
|
||||
}
|
||||
if (n == 0) {
|
||||
break;
|
||||
@ -293,7 +293,7 @@ LinuxAttachOperation* LinuxAttachListener::read_request(int s) {
|
||||
char msg[32];
|
||||
os::snprintf_checked(msg, sizeof(msg), "%d\n", ATTACH_ERROR_BADVERSION);
|
||||
write_fully(s, msg, strlen(msg));
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -303,7 +303,7 @@ LinuxAttachOperation* LinuxAttachListener::read_request(int s) {
|
||||
} while (left > 0 && str_count < expected_str_count);
|
||||
|
||||
if (str_count != expected_str_count) {
|
||||
return NULL; // incomplete request
|
||||
return nullptr; // incomplete request
|
||||
}
|
||||
|
||||
// parse request
|
||||
@ -314,20 +314,20 @@ LinuxAttachOperation* LinuxAttachListener::read_request(int s) {
|
||||
char* v = args.next();
|
||||
|
||||
char* name = args.next();
|
||||
if (name == NULL || strlen(name) > AttachOperation::name_length_max) {
|
||||
return NULL;
|
||||
if (name == nullptr || strlen(name) > AttachOperation::name_length_max) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LinuxAttachOperation* op = new LinuxAttachOperation(name);
|
||||
|
||||
for (int i=0; i<AttachOperation::arg_count_max; i++) {
|
||||
char* arg = args.next();
|
||||
if (arg == NULL) {
|
||||
op->set_arg(i, NULL);
|
||||
if (arg == nullptr) {
|
||||
op->set_arg(i, nullptr);
|
||||
} else {
|
||||
if (strlen(arg) > AttachOperation::arg_length_max) {
|
||||
delete op;
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
op->set_arg(i, arg);
|
||||
}
|
||||
@ -352,7 +352,7 @@ LinuxAttachOperation* LinuxAttachListener::dequeue() {
|
||||
socklen_t len = sizeof(addr);
|
||||
RESTARTABLE(::accept(listener(), &addr, &len), s);
|
||||
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
|
||||
@ -373,7 +373,7 @@ LinuxAttachOperation* LinuxAttachListener::dequeue() {
|
||||
|
||||
// peer credential look okay so we read the request
|
||||
LinuxAttachOperation* op = read_request(s);
|
||||
if (op == NULL) {
|
||||
if (op == nullptr) {
|
||||
::close(s);
|
||||
continue;
|
||||
} else {
|
||||
@ -548,7 +548,7 @@ void AttachListener::pd_data_dump() {
|
||||
}
|
||||
|
||||
AttachOperationFunctionInfo* AttachListener::pd_find_operation(const char* n) {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
jint AttachListener::pd_set_flag(AttachOperation* op, outputStream* out) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,11 +39,11 @@
|
||||
static const char* cg_controller_name[] = { "cpu", "cpuset", "cpuacct", "memory", "pids" };
|
||||
|
||||
CgroupSubsystem* CgroupSubsystemFactory::create() {
|
||||
CgroupV1MemoryController* memory = NULL;
|
||||
CgroupV1Controller* cpuset = NULL;
|
||||
CgroupV1Controller* cpu = NULL;
|
||||
CgroupV1Controller* cpuacct = NULL;
|
||||
CgroupV1Controller* pids = NULL;
|
||||
CgroupV1MemoryController* memory = nullptr;
|
||||
CgroupV1Controller* cpuset = nullptr;
|
||||
CgroupV1Controller* cpu = nullptr;
|
||||
CgroupV1Controller* cpuacct = nullptr;
|
||||
CgroupV1Controller* pids = nullptr;
|
||||
CgroupInfo cg_infos[CG_INFO_LENGTH];
|
||||
u1 cg_type_flags = INVALID_CGROUPS_GENERIC;
|
||||
const char* proc_cgroups = "/proc/cgroups";
|
||||
@ -54,7 +54,7 @@ CgroupSubsystem* CgroupSubsystemFactory::create() {
|
||||
|
||||
if (!valid_cgroup) {
|
||||
// Could not detect cgroup type
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
assert(is_valid_cgroup(&cg_type_flags), "Expected valid cgroup type");
|
||||
|
||||
@ -128,7 +128,7 @@ void CgroupSubsystemFactory::set_controller_paths(CgroupInfo* cg_infos,
|
||||
const char* name,
|
||||
char* mount_path,
|
||||
char* root_path) {
|
||||
if (cg_infos[controller]._mount_path != NULL) {
|
||||
if (cg_infos[controller]._mount_path != nullptr) {
|
||||
// On some systems duplicate controllers get mounted in addition to
|
||||
// the main cgroup controllers most likely under /sys/fs/cgroup. In that
|
||||
// case pick the one under /sys/fs/cgroup and discard others.
|
||||
@ -154,9 +154,9 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
const char* proc_self_cgroup,
|
||||
const char* proc_self_mountinfo,
|
||||
u1* flags) {
|
||||
FILE *mntinfo = NULL;
|
||||
FILE *cgroups = NULL;
|
||||
FILE *cgroup = NULL;
|
||||
FILE *mntinfo = nullptr;
|
||||
FILE *cgroups = nullptr;
|
||||
FILE *cgroup = nullptr;
|
||||
char buf[MAXPATHLEN+1];
|
||||
char *p;
|
||||
bool is_cgroupsV2;
|
||||
@ -174,13 +174,13 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
* controllers must have hierarchy ID 0 and the unified controller mounted.
|
||||
*/
|
||||
cgroups = os::fopen(proc_cgroups, "r");
|
||||
if (cgroups == NULL) {
|
||||
if (cgroups == nullptr) {
|
||||
log_debug(os, container)("Can't open %s, %s", proc_cgroups, os::strerror(errno));
|
||||
*flags = INVALID_CGROUPS_GENERIC;
|
||||
return false;
|
||||
}
|
||||
|
||||
while ((p = fgets(buf, MAXPATHLEN, cgroups)) != NULL) {
|
||||
while ((p = fgets(buf, MAXPATHLEN, cgroups)) != nullptr) {
|
||||
char name[MAXPATHLEN+1];
|
||||
int hierarchy_id;
|
||||
int enabled;
|
||||
@ -242,7 +242,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
* the host mount point to the local one via /proc/self/mountinfo below.
|
||||
*/
|
||||
cgroup = os::fopen(proc_self_cgroup, "r");
|
||||
if (cgroup == NULL) {
|
||||
if (cgroup == nullptr) {
|
||||
log_debug(os, container)("Can't open %s, %s",
|
||||
proc_self_cgroup, os::strerror(errno));
|
||||
cleanup(cg_infos);
|
||||
@ -250,7 +250,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
return false;
|
||||
}
|
||||
|
||||
while ((p = fgets(buf, MAXPATHLEN, cgroup)) != NULL) {
|
||||
while ((p = fgets(buf, MAXPATHLEN, cgroup)) != nullptr) {
|
||||
char *controllers;
|
||||
char *token;
|
||||
char *hierarchy_id_str;
|
||||
@ -263,11 +263,11 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
controllers = strsep(&p, ":");
|
||||
cgroup_path = strsep(&p, "\n");
|
||||
|
||||
if (controllers == NULL) {
|
||||
if (controllers == nullptr) {
|
||||
continue;
|
||||
}
|
||||
|
||||
while (!is_cgroupsV2 && (token = strsep(&controllers, ",")) != NULL) {
|
||||
while (!is_cgroupsV2 && (token = strsep(&controllers, ",")) != nullptr) {
|
||||
if (strcmp(token, "memory") == 0) {
|
||||
assert(hierarchy_id == cg_infos[MEMORY_IDX]._hierarchy_id, "/proc/cgroups and /proc/self/cgroup hierarchy mismatch for memory");
|
||||
cg_infos[MEMORY_IDX]._cgroup_path = os::strdup(cgroup_path);
|
||||
@ -293,7 +293,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
continue;
|
||||
}
|
||||
for (int i = 0; i < CG_INFO_LENGTH; i++) {
|
||||
assert(cg_infos[i]._cgroup_path == NULL, "cgroup path must only be set once");
|
||||
assert(cg_infos[i]._cgroup_path == nullptr, "cgroup path must only be set once");
|
||||
cg_infos[i]._cgroup_path = os::strdup(cgroup_path);
|
||||
}
|
||||
}
|
||||
@ -303,7 +303,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
// Find various mount points by reading /proc/self/mountinfo
|
||||
// mountinfo format is documented at https://www.kernel.org/doc/Documentation/filesystems/proc.txt
|
||||
mntinfo = os::fopen(proc_self_mountinfo, "r");
|
||||
if (mntinfo == NULL) {
|
||||
if (mntinfo == nullptr) {
|
||||
log_debug(os, container)("Can't open %s, %s",
|
||||
proc_self_mountinfo, os::strerror(errno));
|
||||
cleanup(cg_infos);
|
||||
@ -313,7 +313,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
|
||||
bool cgroupv2_mount_point_found = false;
|
||||
bool any_cgroup_mounts_found = false;
|
||||
while ((p = fgets(buf, MAXPATHLEN, mntinfo)) != NULL) {
|
||||
while ((p = fgets(buf, MAXPATHLEN, mntinfo)) != nullptr) {
|
||||
char tmp_fs_type[MAXPATHLEN+1];
|
||||
char tmproot[MAXPATHLEN+1];
|
||||
char tmpmount[MAXPATHLEN+1];
|
||||
@ -352,7 +352,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
// Skip cgroup2 fs lines on hybrid or unified hierarchy.
|
||||
continue;
|
||||
}
|
||||
while ((token = strsep(&cptr, ",")) != NULL) {
|
||||
while ((token = strsep(&cptr, ",")) != nullptr) {
|
||||
if (strcmp(token, "memory") == 0) {
|
||||
any_cgroup_mounts_found = true;
|
||||
set_controller_paths(cg_infos, MEMORY_IDX, token, tmpmount, tmproot);
|
||||
@ -437,7 +437,7 @@ bool CgroupSubsystemFactory::determine_type(CgroupInfo* cg_infos,
|
||||
};
|
||||
|
||||
void CgroupSubsystemFactory::cleanup(CgroupInfo* cg_infos) {
|
||||
assert(cg_infos != NULL, "Invariant");
|
||||
assert(cg_infos != nullptr, "Invariant");
|
||||
for (int i = 0; i < CG_INFO_LENGTH; i++) {
|
||||
os::free(cg_infos[i]._name);
|
||||
os::free(cg_infos[i]._cgroup_path);
|
||||
@ -557,7 +557,7 @@ jlong CgroupSubsystem::memory_limit_in_bytes() {
|
||||
}
|
||||
|
||||
jlong CgroupSubsystem::limit_from_str(char* limit_str) {
|
||||
if (limit_str == NULL) {
|
||||
if (limit_str == nullptr) {
|
||||
return OSCONTAINER_ERROR;
|
||||
}
|
||||
// Unlimited memory in cgroups is the literal string 'max' for
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -90,11 +90,11 @@ template <typename T> int subsystem_file_line_contents(CgroupController* c,
|
||||
const char *scan_fmt,
|
||||
T returnval) {
|
||||
if (c == nullptr) {
|
||||
log_debug(os, container)("subsystem_file_line_contents: CgroupController* is nullptr");
|
||||
log_debug(os, container)("subsystem_file_line_contents: CgroupController* is null");
|
||||
return OSCONTAINER_ERROR;
|
||||
}
|
||||
if (c->subsystem_path() == nullptr) {
|
||||
log_debug(os, container)("subsystem_file_line_contents: subsystem path is nullptr");
|
||||
log_debug(os, container)("subsystem_file_line_contents: subsystem path is null");
|
||||
return OSCONTAINER_ERROR;
|
||||
}
|
||||
|
||||
@ -166,7 +166,7 @@ PRAGMA_DIAG_POP
|
||||
int err; \
|
||||
err = subsystem_file_line_contents(subsystem, \
|
||||
filename, \
|
||||
NULL, \
|
||||
nullptr, \
|
||||
scan_fmt, \
|
||||
&variable); \
|
||||
if (err != 0) { \
|
||||
@ -184,11 +184,11 @@ PRAGMA_DIAG_POP
|
||||
int err; \
|
||||
err = subsystem_file_line_contents(subsystem, \
|
||||
filename, \
|
||||
NULL, \
|
||||
nullptr, \
|
||||
scan_fmt, \
|
||||
variable); \
|
||||
if (err != 0) \
|
||||
return (return_type) NULL; \
|
||||
return (return_type) nullptr; \
|
||||
\
|
||||
log_trace(os, container)(logstring, variable); \
|
||||
}
|
||||
@ -293,13 +293,13 @@ class CgroupInfo : public StackObj {
|
||||
|
||||
public:
|
||||
CgroupInfo() {
|
||||
_name = NULL;
|
||||
_name = nullptr;
|
||||
_hierarchy_id = -1;
|
||||
_enabled = false;
|
||||
_data_complete = false;
|
||||
_cgroup_path = NULL;
|
||||
_root_mount_path = NULL;
|
||||
_mount_path = NULL;
|
||||
_cgroup_path = nullptr;
|
||||
_root_mount_path = nullptr;
|
||||
_mount_path = nullptr;
|
||||
}
|
||||
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -39,7 +39,7 @@
|
||||
*/
|
||||
void CgroupV1Controller::set_subsystem_path(char *cgroup_path) {
|
||||
stringStream ss;
|
||||
if (_root != NULL && cgroup_path != NULL) {
|
||||
if (_root != nullptr && cgroup_path != nullptr) {
|
||||
if (strcmp(_root, "/") == 0) {
|
||||
ss.print_raw(_mount_point);
|
||||
if (strcmp(cgroup_path,"/") != 0) {
|
||||
@ -52,7 +52,7 @@ void CgroupV1Controller::set_subsystem_path(char *cgroup_path) {
|
||||
_path = os::strdup(ss.base());
|
||||
} else {
|
||||
char *p = strstr(cgroup_path, _root);
|
||||
if (p != NULL && p == _root) {
|
||||
if (p != nullptr && p == _root) {
|
||||
if (strlen(cgroup_path) > strlen(_root)) {
|
||||
ss.print_raw(_mount_point);
|
||||
const char* cg_path_sub = cgroup_path + strlen(_root);
|
||||
@ -297,7 +297,7 @@ char* CgroupV1Subsystem::pids_max_val() {
|
||||
* OSCONTAINER_ERROR for not supported
|
||||
*/
|
||||
jlong CgroupV1Subsystem::pids_max() {
|
||||
if (_pids == NULL) return OSCONTAINER_ERROR;
|
||||
if (_pids == nullptr) return OSCONTAINER_ERROR;
|
||||
char * pidsmax_str = pids_max_val();
|
||||
return limit_from_str(pidsmax_str);
|
||||
}
|
||||
@ -311,7 +311,7 @@ jlong CgroupV1Subsystem::pids_max() {
|
||||
* OSCONTAINER_ERROR for not supported
|
||||
*/
|
||||
jlong CgroupV1Subsystem::pids_current() {
|
||||
if (_pids == NULL) return OSCONTAINER_ERROR;
|
||||
if (_pids == nullptr) return OSCONTAINER_ERROR;
|
||||
GET_CONTAINER_INFO(jlong, _pids, "/pids.current",
|
||||
"Current number of tasks is: " JLONG_FORMAT, JLONG_FORMAT, pids_current);
|
||||
return pids_current;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,7 +44,7 @@ class CgroupV1Controller: public CgroupController {
|
||||
CgroupV1Controller(char *root, char *mountpoint) {
|
||||
_root = os::strdup(root);
|
||||
_mount_point = os::strdup(mountpoint);
|
||||
_path = NULL;
|
||||
_path = nullptr;
|
||||
}
|
||||
|
||||
virtual void set_subsystem_path(char *cgroup_path);
|
||||
@ -105,11 +105,11 @@ class CgroupV1Subsystem: public CgroupSubsystem {
|
||||
|
||||
private:
|
||||
/* controllers */
|
||||
CachingCgroupController* _memory = NULL;
|
||||
CgroupV1Controller* _cpuset = NULL;
|
||||
CachingCgroupController* _cpu = NULL;
|
||||
CgroupV1Controller* _cpuacct = NULL;
|
||||
CgroupV1Controller* _pids = NULL;
|
||||
CachingCgroupController* _memory = nullptr;
|
||||
CgroupV1Controller* _cpuset = nullptr;
|
||||
CachingCgroupController* _cpu = nullptr;
|
||||
CgroupV1Controller* _cpuacct = nullptr;
|
||||
CgroupV1Controller* _pids = nullptr;
|
||||
|
||||
char * pids_max_val();
|
||||
|
||||
|
@ -51,10 +51,10 @@ class CgroupV2Controller: public CgroupController {
|
||||
class CgroupV2Subsystem: public CgroupSubsystem {
|
||||
private:
|
||||
/* One unified controller */
|
||||
CgroupController* _unified = NULL;
|
||||
CgroupController* _unified = nullptr;
|
||||
/* Caching wrappers for cpu/memory metrics */
|
||||
CachingCgroupController* _memory = NULL;
|
||||
CachingCgroupController* _cpu = NULL;
|
||||
CachingCgroupController* _memory = nullptr;
|
||||
CachingCgroupController* _cpu = nullptr;
|
||||
|
||||
char *mem_limit_val();
|
||||
char *mem_swp_limit_val();
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -44,7 +44,7 @@ bool ElfDecoder::demangle(const char* symbol, char *buf, int buflen) {
|
||||
// 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
|
||||
// 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);
|
||||
// call c library's free
|
||||
ALLOW_C_FUNCTION(::free, ::free(result);)
|
||||
@ -58,10 +58,10 @@ bool ElfDecoder::demangle(const char* symbol, char *buf, int buflen) {
|
||||
// Returns false if the elf file requires an executable stack, the stack flag
|
||||
// is not set at all, or if the file can not be read.
|
||||
bool ElfFile::specifies_noexecstack(const char* filepath) {
|
||||
if (filepath == NULL) return true;
|
||||
if (filepath == nullptr) return true;
|
||||
|
||||
FILE* file = os::fopen(filepath, "r");
|
||||
if (file == NULL) return true;
|
||||
if (file == nullptr) return true;
|
||||
|
||||
// AARCH64 defaults to noexecstack. All others default to execstack.
|
||||
bool result = AARCH64_ONLY(true) NOT_AARCH64(false);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -37,7 +37,7 @@
|
||||
#define PROC_SELF_MOUNTINFO "/proc/self/mountinfo"
|
||||
|
||||
ZMountPoint::ZMountPoint(const char* filesystem, const char** preferred_mountpoints) {
|
||||
if (AllocateHeapAt != NULL) {
|
||||
if (AllocateHeapAt != nullptr) {
|
||||
// Use specified path
|
||||
_path = os::strdup(AllocateHeapAt, mtGC);
|
||||
} else {
|
||||
@ -48,12 +48,12 @@ ZMountPoint::ZMountPoint(const char* filesystem, const char** preferred_mountpoi
|
||||
|
||||
ZMountPoint::~ZMountPoint() {
|
||||
os::free(_path);
|
||||
_path = NULL;
|
||||
_path = nullptr;
|
||||
}
|
||||
|
||||
char* ZMountPoint::get_mountpoint(const char* line, const char* filesystem) const {
|
||||
char* line_mountpoint = NULL;
|
||||
char* line_filesystem = NULL;
|
||||
char* line_mountpoint = nullptr;
|
||||
char* line_filesystem = nullptr;
|
||||
|
||||
// Parse line and return a newly allocated string containing the mount point if
|
||||
// the line contains a matching filesystem and the mount point is accessible by
|
||||
@ -64,7 +64,7 @@ char* ZMountPoint::get_mountpoint(const char* line, const char* filesystem) cons
|
||||
access(line_mountpoint, R_OK|W_OK|X_OK) != 0) {
|
||||
// Not a matching or accessible filesystem
|
||||
ALLOW_C_FUNCTION(::free, ::free(line_mountpoint);)
|
||||
line_mountpoint = NULL;
|
||||
line_mountpoint = nullptr;
|
||||
}
|
||||
|
||||
ALLOW_C_FUNCTION(::free, ::free(line_filesystem);)
|
||||
@ -74,18 +74,18 @@ char* ZMountPoint::get_mountpoint(const char* line, const char* filesystem) cons
|
||||
|
||||
void ZMountPoint::get_mountpoints(const char* filesystem, ZArray<char*>* mountpoints) const {
|
||||
FILE* fd = os::fopen(PROC_SELF_MOUNTINFO, "r");
|
||||
if (fd == NULL) {
|
||||
if (fd == nullptr) {
|
||||
ZErrno err;
|
||||
log_error_p(gc)("Failed to open %s: %s", PROC_SELF_MOUNTINFO, err.to_string());
|
||||
return;
|
||||
}
|
||||
|
||||
char* line = NULL;
|
||||
char* line = nullptr;
|
||||
size_t length = 0;
|
||||
|
||||
while (getline(&line, &length, fd) != -1) {
|
||||
char* const mountpoint = get_mountpoint(line, filesystem);
|
||||
if (mountpoint != NULL) {
|
||||
if (mountpoint != nullptr) {
|
||||
mountpoints->append(mountpoint);
|
||||
}
|
||||
}
|
||||
@ -109,7 +109,7 @@ char* ZMountPoint::find_preferred_mountpoint(const char* filesystem,
|
||||
// Find preferred mount point
|
||||
ZArrayIterator<char*> iter1(mountpoints);
|
||||
for (char* mountpoint; iter1.next(&mountpoint);) {
|
||||
for (const char** preferred = preferred_mountpoints; *preferred != NULL; preferred++) {
|
||||
for (const char** preferred = preferred_mountpoints; *preferred != nullptr; preferred++) {
|
||||
if (!strcmp(mountpoint, *preferred)) {
|
||||
// Preferred mount point found
|
||||
return os::strdup(mountpoint, mtGC);
|
||||
@ -124,11 +124,11 @@ char* ZMountPoint::find_preferred_mountpoint(const char* filesystem,
|
||||
log_error_p(gc)(" %s", mountpoint);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
char* ZMountPoint::find_mountpoint(const char* filesystem, const char** preferred_mountpoints) const {
|
||||
char* path = NULL;
|
||||
char* path = nullptr;
|
||||
ZArray<char*> mountpoints;
|
||||
|
||||
get_mountpoints(filesystem, &mountpoints);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -60,7 +60,7 @@ uint32_t ZNUMA::memory_id(uintptr_t addr) {
|
||||
|
||||
uint32_t id = (uint32_t)-1;
|
||||
|
||||
if (ZSyscall::get_mempolicy((int*)&id, NULL, 0, (void*)addr, MPOL_F_NODE | MPOL_F_ADDR) == -1) {
|
||||
if (ZSyscall::get_mempolicy((int*)&id, nullptr, 0, (void*)addr, MPOL_F_NODE | MPOL_F_ADDR) == -1) {
|
||||
ZErrno err;
|
||||
fatal("Failed to get NUMA id for memory at " PTR_FORMAT " (%s)", addr, err.to_string());
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -104,14 +104,14 @@
|
||||
static const char* z_preferred_tmpfs_mountpoints[] = {
|
||||
"/dev/shm",
|
||||
"/run/shm",
|
||||
NULL
|
||||
nullptr
|
||||
};
|
||||
|
||||
// Preferred hugetlbfs mount points, ordered by priority
|
||||
static const char* z_preferred_hugetlbfs_mountpoints[] = {
|
||||
"/dev/hugepages",
|
||||
"/hugepages",
|
||||
NULL
|
||||
nullptr
|
||||
};
|
||||
|
||||
static int z_fallocate_hugetlbfs_attempts = 3;
|
||||
@ -229,7 +229,7 @@ int ZPhysicalMemoryBacking::create_file_fd(const char* name) const {
|
||||
|
||||
// Find mountpoint
|
||||
ZMountPoint mountpoint(filesystem, preferred_mountpoints);
|
||||
if (mountpoint.get() == NULL) {
|
||||
if (mountpoint.get() == nullptr) {
|
||||
log_error_p(gc)("Use -XX:AllocateHeapAt to specify the path to a %s filesystem", filesystem);
|
||||
return -1;
|
||||
}
|
||||
@ -282,7 +282,7 @@ int ZPhysicalMemoryBacking::create_file_fd(const char* name) const {
|
||||
}
|
||||
|
||||
int ZPhysicalMemoryBacking::create_fd(const char* name) const {
|
||||
if (AllocateHeapAt == NULL) {
|
||||
if (AllocateHeapAt == nullptr) {
|
||||
// If the path is not explicitly specified, then we first try to create a memfd file
|
||||
// instead of looking for a tmpfd/hugetlbfs mount point. Note that memfd_create() might
|
||||
// not be supported at all (requires kernel >= 3.17), or it might not support large
|
||||
@ -331,7 +331,7 @@ void ZPhysicalMemoryBacking::warn_available_space(size_t max_capacity) const {
|
||||
void ZPhysicalMemoryBacking::warn_max_map_count(size_t max_capacity) const {
|
||||
const char* const filename = ZFILENAME_PROC_MAX_MAP_COUNT;
|
||||
FILE* const file = os::fopen(filename, "r");
|
||||
if (file == NULL) {
|
||||
if (file == nullptr) {
|
||||
// Failed to open file, skip check
|
||||
log_debug_p(gc, init)("Failed to open %s", filename);
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -55,7 +55,7 @@ void OSContainer::init() {
|
||||
}
|
||||
|
||||
cgroup_subsystem = CgroupSubsystemFactory::create();
|
||||
if (cgroup_subsystem == NULL) {
|
||||
if (cgroup_subsystem == nullptr) {
|
||||
return; // Required subsystem files not found or other error
|
||||
}
|
||||
|
||||
@ -63,77 +63,77 @@ void OSContainer::init() {
|
||||
}
|
||||
|
||||
const char * OSContainer::container_type() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->container_type();
|
||||
}
|
||||
|
||||
jlong OSContainer::memory_limit_in_bytes() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->memory_limit_in_bytes();
|
||||
}
|
||||
|
||||
jlong OSContainer::memory_and_swap_limit_in_bytes() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->memory_and_swap_limit_in_bytes();
|
||||
}
|
||||
|
||||
jlong OSContainer::memory_soft_limit_in_bytes() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->memory_soft_limit_in_bytes();
|
||||
}
|
||||
|
||||
jlong OSContainer::memory_usage_in_bytes() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->memory_usage_in_bytes();
|
||||
}
|
||||
|
||||
jlong OSContainer::memory_max_usage_in_bytes() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->memory_max_usage_in_bytes();
|
||||
}
|
||||
|
||||
void OSContainer::print_version_specific_info(outputStream* st) {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
cgroup_subsystem->print_version_specific_info(st);
|
||||
}
|
||||
|
||||
char * OSContainer::cpu_cpuset_cpus() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->cpu_cpuset_cpus();
|
||||
}
|
||||
|
||||
char * OSContainer::cpu_cpuset_memory_nodes() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->cpu_cpuset_memory_nodes();
|
||||
}
|
||||
|
||||
int OSContainer::active_processor_count() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->active_processor_count();
|
||||
}
|
||||
|
||||
int OSContainer::cpu_quota() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->cpu_quota();
|
||||
}
|
||||
|
||||
int OSContainer::cpu_period() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->cpu_period();
|
||||
}
|
||||
|
||||
int OSContainer::cpu_shares() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->cpu_shares();
|
||||
}
|
||||
|
||||
jlong OSContainer::pids_max() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->pids_max();
|
||||
}
|
||||
|
||||
jlong OSContainer::pids_current() {
|
||||
assert(cgroup_subsystem != NULL, "cgroup subsystem not available");
|
||||
assert(cgroup_subsystem != nullptr, "cgroup subsystem not available");
|
||||
return cgroup_subsystem->pids_current();
|
||||
}
|
||||
|
||||
|
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,18 +30,18 @@
|
||||
#include <signal.h>
|
||||
|
||||
void OSThread::pd_initialize() {
|
||||
assert(this != NULL, "check");
|
||||
assert(this != nullptr, "check");
|
||||
_thread_id = 0;
|
||||
_pthread_id = 0;
|
||||
_siginfo = NULL;
|
||||
_ucontext = NULL;
|
||||
_siginfo = nullptr;
|
||||
_ucontext = nullptr;
|
||||
_expanding_stack = 0;
|
||||
_alt_sig_stack = NULL;
|
||||
_alt_sig_stack = nullptr;
|
||||
|
||||
sigemptyset(&_caller_sigmask);
|
||||
|
||||
_startThread_lock = new Monitor(Mutex::event, "startThread_lock");
|
||||
assert(_startThread_lock !=NULL, "check");
|
||||
assert(_startThread_lock !=nullptr, "check");
|
||||
}
|
||||
|
||||
void OSThread::pd_destroy() {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -252,8 +252,8 @@ class os::Linux {
|
||||
static void set_numa_move_pages(numa_move_pages_func_t func) { _numa_move_pages = func; }
|
||||
static void set_numa_set_preferred(numa_set_preferred_func_t func) { _numa_set_preferred = func; }
|
||||
static void set_numa_all_nodes(unsigned long* ptr) { _numa_all_nodes = ptr; }
|
||||
static void set_numa_all_nodes_ptr(struct bitmask **ptr) { _numa_all_nodes_ptr = (ptr == NULL ? NULL : *ptr); }
|
||||
static void set_numa_nodes_ptr(struct bitmask **ptr) { _numa_nodes_ptr = (ptr == NULL ? NULL : *ptr); }
|
||||
static void set_numa_all_nodes_ptr(struct bitmask **ptr) { _numa_all_nodes_ptr = (ptr == nullptr ? nullptr : *ptr); }
|
||||
static void set_numa_nodes_ptr(struct bitmask **ptr) { _numa_nodes_ptr = (ptr == nullptr ? nullptr : *ptr); }
|
||||
static void set_numa_interleave_bitmask(struct bitmask* ptr) { _numa_interleave_bitmask = ptr ; }
|
||||
static void set_numa_membind_bitmask(struct bitmask* ptr) { _numa_membind_bitmask = ptr ; }
|
||||
static int sched_getcpu_syscall(void);
|
||||
@ -266,15 +266,15 @@ class os::Linux {
|
||||
static NumaAllocationPolicy _current_numa_policy;
|
||||
|
||||
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_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_num_configured_nodes() {
|
||||
return _numa_num_configured_nodes != NULL ? _numa_num_configured_nodes() : -1;
|
||||
return _numa_num_configured_nodes != nullptr ? _numa_num_configured_nodes() : -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) {
|
||||
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 bool is_running_in_interleave_mode() {
|
||||
@ -296,46 +296,46 @@ class os::Linux {
|
||||
|
||||
static void numa_interleave_memory(void *start, size_t size) {
|
||||
// Prefer v2 API
|
||||
if (_numa_interleave_memory_v2 != NULL) {
|
||||
if (_numa_interleave_memory_v2 != nullptr) {
|
||||
if (is_running_in_interleave_mode()) {
|
||||
_numa_interleave_memory_v2(start, size, _numa_interleave_bitmask);
|
||||
} else if (_numa_membind_bitmask != NULL) {
|
||||
} else if (_numa_membind_bitmask != nullptr) {
|
||||
_numa_interleave_memory_v2(start, size, _numa_membind_bitmask);
|
||||
}
|
||||
} else if (_numa_interleave_memory != NULL) {
|
||||
} else if (_numa_interleave_memory != nullptr) {
|
||||
_numa_interleave_memory(start, size, _numa_all_nodes);
|
||||
}
|
||||
}
|
||||
static void numa_set_preferred(int node) {
|
||||
if (_numa_set_preferred != NULL) {
|
||||
if (_numa_set_preferred != nullptr) {
|
||||
_numa_set_preferred(node);
|
||||
}
|
||||
}
|
||||
static void numa_set_bind_policy(int policy) {
|
||||
if (_numa_set_bind_policy != NULL) {
|
||||
if (_numa_set_bind_policy != nullptr) {
|
||||
_numa_set_bind_policy(policy);
|
||||
}
|
||||
}
|
||||
static int numa_distance(int node1, int node2) {
|
||||
return _numa_distance != NULL ? _numa_distance(node1, node2) : -1;
|
||||
return _numa_distance != nullptr ? _numa_distance(node1, node2) : -1;
|
||||
}
|
||||
static long numa_move_pages(int pid, unsigned long count, void **pages, const int *nodes, int *status, int flags) {
|
||||
return _numa_move_pages != NULL ? _numa_move_pages(pid, count, pages, nodes, status, flags) : -1;
|
||||
return _numa_move_pages != nullptr ? _numa_move_pages(pid, count, pages, nodes, status, flags) : -1;
|
||||
}
|
||||
static int get_node_by_cpu(int cpu_id);
|
||||
static int get_existing_num_nodes();
|
||||
// Check if numa node is configured (non-zero memory node).
|
||||
static bool is_node_in_configured_nodes(unsigned int n) {
|
||||
if (_numa_bitmask_isbitset != NULL && _numa_all_nodes_ptr != NULL) {
|
||||
if (_numa_bitmask_isbitset != nullptr && _numa_all_nodes_ptr != nullptr) {
|
||||
return _numa_bitmask_isbitset(_numa_all_nodes_ptr, n);
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
// Check if numa node exists in the system (including zero memory nodes).
|
||||
static bool is_node_in_existing_nodes(unsigned int n) {
|
||||
if (_numa_bitmask_isbitset != NULL && _numa_nodes_ptr != NULL) {
|
||||
if (_numa_bitmask_isbitset != nullptr && _numa_nodes_ptr != nullptr) {
|
||||
return _numa_bitmask_isbitset(_numa_nodes_ptr, n);
|
||||
} else if (_numa_bitmask_isbitset != NULL && _numa_all_nodes_ptr != NULL) {
|
||||
} else if (_numa_bitmask_isbitset != nullptr && _numa_all_nodes_ptr != nullptr) {
|
||||
// Not all libnuma API v2 implement numa_nodes_ptr, so it's not possible
|
||||
// to trust the API version for checking its absence. On the other hand,
|
||||
// numa_nodes_ptr found in libnuma 2.0.9 and above is the only way to get
|
||||
@ -352,11 +352,11 @@ class os::Linux {
|
||||
}
|
||||
// Check if node is in bound node set.
|
||||
static bool is_node_in_bound_nodes(int node) {
|
||||
if (_numa_bitmask_isbitset != NULL) {
|
||||
if (_numa_bitmask_isbitset != nullptr) {
|
||||
if (is_running_in_interleave_mode()) {
|
||||
return _numa_bitmask_isbitset(_numa_interleave_bitmask, node);
|
||||
} else {
|
||||
return _numa_membind_bitmask != NULL ? _numa_bitmask_isbitset(_numa_membind_bitmask, node) : false;
|
||||
return _numa_membind_bitmask != nullptr ? _numa_bitmask_isbitset(_numa_membind_bitmask, node) : false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -368,7 +368,7 @@ class os::Linux {
|
||||
unsigned int node = 0;
|
||||
unsigned int highest_node_number = 0;
|
||||
|
||||
if (_numa_membind_bitmask != NULL && _numa_max_node != NULL && _numa_bitmask_isbitset != NULL) {
|
||||
if (_numa_membind_bitmask != nullptr && _numa_max_node != nullptr && _numa_bitmask_isbitset != nullptr) {
|
||||
highest_node_number = _numa_max_node();
|
||||
} else {
|
||||
return false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2022, 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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -235,7 +235,7 @@ static int SCANF_ARGS(2, 0) vread_statdata(const char* procfile, _SCANFMT_ const
|
||||
int n;
|
||||
char buf[2048];
|
||||
|
||||
if ((f = os::fopen(procfile, "r")) == NULL) {
|
||||
if ((f = os::fopen(procfile, "r")) == nullptr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ static int SCANF_ARGS(2, 0) vread_statdata(const char* procfile, _SCANFMT_ const
|
||||
|
||||
buf[n-1] = '\0';
|
||||
/** skip through pid and exec name. */
|
||||
if ((tmp = strrchr(buf, ')')) != NULL) {
|
||||
if ((tmp = strrchr(buf, ')')) != nullptr) {
|
||||
// skip the ')' and the following space
|
||||
// but check that buffer is long enough
|
||||
tmp += 2;
|
||||
@ -272,7 +272,7 @@ static int SCANF_ARGS(2, 3) read_statdata(const char* procfile, _SCANFMT_ const
|
||||
static FILE* open_statfile(void) {
|
||||
FILE *f;
|
||||
|
||||
if ((f = os::fopen("/proc/stat", "r")) == NULL) {
|
||||
if ((f = os::fopen("/proc/stat", "r")) == nullptr) {
|
||||
static int haveWarned = 0;
|
||||
if (!haveWarned) {
|
||||
haveWarned = 1;
|
||||
@ -290,7 +290,7 @@ static int get_systemtype(void) {
|
||||
}
|
||||
|
||||
// Check whether we have a task subdirectory
|
||||
if ((taskDir = opendir("/proc/self/task")) == NULL) {
|
||||
if ((taskDir = opendir("/proc/self/task")) == nullptr) {
|
||||
procEntriesType = UNDETECTABLE;
|
||||
} else {
|
||||
// The task subdirectory exists; we're on a Linux >= 2.6 system
|
||||
@ -400,13 +400,13 @@ static int SCANF_ARGS(1, 2) parse_stat(_SCANFMT_ const char* fmt, ...) {
|
||||
|
||||
va_start(args, fmt);
|
||||
|
||||
if ((f = open_statfile()) == NULL) {
|
||||
if ((f = open_statfile()) == nullptr) {
|
||||
va_end(args);
|
||||
return OS_ERR;
|
||||
}
|
||||
for (;;) {
|
||||
char line[80];
|
||||
if (fgets(line, sizeof(line), f) != NULL) {
|
||||
if (fgets(line, sizeof(line), f) != nullptr) {
|
||||
if (vsscanf(line, fmt, args) == 1) {
|
||||
fclose(f);
|
||||
va_end(args);
|
||||
@ -515,7 +515,7 @@ class CPUPerformanceInterface::CPUPerformance : public CHeapObj<mtInternal> {
|
||||
|
||||
CPUPerformanceInterface::CPUPerformance::CPUPerformance() {
|
||||
_counters.nProcs = os::active_processor_count();
|
||||
_counters.cpus = NULL;
|
||||
_counters.cpus = nullptr;
|
||||
}
|
||||
|
||||
bool CPUPerformanceInterface::CPUPerformance::initialize() {
|
||||
@ -542,7 +542,7 @@ bool CPUPerformanceInterface::CPUPerformance::initialize() {
|
||||
}
|
||||
|
||||
CPUPerformanceInterface::CPUPerformance::~CPUPerformance() {
|
||||
if (_counters.cpus != NULL) {
|
||||
if (_counters.cpus != nullptr) {
|
||||
FREE_C_HEAP_ARRAY(char, _counters.cpus);
|
||||
}
|
||||
}
|
||||
@ -573,9 +573,9 @@ int CPUPerformanceInterface::CPUPerformance::cpu_load_total_process(double* cpu_
|
||||
int CPUPerformanceInterface::CPUPerformance::cpu_loads_process(double* pjvmUserLoad, double* pjvmKernelLoad, double* psystemTotalLoad) {
|
||||
double u, s, t;
|
||||
|
||||
assert(pjvmUserLoad != NULL, "pjvmUserLoad not inited");
|
||||
assert(pjvmKernelLoad != NULL, "pjvmKernelLoad not inited");
|
||||
assert(psystemTotalLoad != NULL, "psystemTotalLoad not inited");
|
||||
assert(pjvmUserLoad != nullptr, "pjvmUserLoad not inited");
|
||||
assert(pjvmKernelLoad != nullptr, "pjvmKernelLoad not inited");
|
||||
assert(psystemTotalLoad != nullptr, "psystemTotalLoad not inited");
|
||||
|
||||
u = get_cpu_load(-1, &_counters, &s, CPU_LOAD_VM_ONLY);
|
||||
if (u < 0) {
|
||||
@ -603,7 +603,7 @@ int CPUPerformanceInterface::CPUPerformance::context_switch_rate(double* rate) {
|
||||
}
|
||||
|
||||
CPUPerformanceInterface::CPUPerformanceInterface() {
|
||||
_impl = NULL;
|
||||
_impl = nullptr;
|
||||
}
|
||||
|
||||
bool CPUPerformanceInterface::initialize() {
|
||||
@ -612,7 +612,7 @@ bool CPUPerformanceInterface::initialize() {
|
||||
}
|
||||
|
||||
CPUPerformanceInterface::~CPUPerformanceInterface() {
|
||||
if (_impl != NULL) {
|
||||
if (_impl != nullptr) {
|
||||
delete _impl;
|
||||
}
|
||||
}
|
||||
@ -685,7 +685,7 @@ bool SystemProcessInterface::SystemProcesses::ProcessIterator::is_dir(const char
|
||||
}
|
||||
|
||||
int SystemProcessInterface::SystemProcesses::ProcessIterator::fsize(const char* name, uint64_t& size) const {
|
||||
assert(name != NULL, "name pointer is NULL!");
|
||||
assert(name != nullptr, "name pointer is null!");
|
||||
size = 0;
|
||||
struct stat fbuf;
|
||||
|
||||
@ -723,15 +723,15 @@ void SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_name() {
|
||||
|
||||
jio_snprintf(buffer, PATH_MAX, "/proc/%s/stat", _entry->d_name);
|
||||
buffer[PATH_MAX - 1] = '\0';
|
||||
if ((fp = os::fopen(buffer, "r")) != NULL) {
|
||||
if (fgets(buffer, PATH_MAX, fp) != NULL) {
|
||||
if ((fp = os::fopen(buffer, "r")) != nullptr) {
|
||||
if (fgets(buffer, PATH_MAX, fp) != nullptr) {
|
||||
char* start, *end;
|
||||
// exe-name is between the first pair of ( and )
|
||||
start = strchr(buffer, '(');
|
||||
if (start != NULL && start[1] != '\0') {
|
||||
if (start != nullptr && start[1] != '\0') {
|
||||
start++;
|
||||
end = strrchr(start, ')');
|
||||
if (end != NULL) {
|
||||
if (end != nullptr) {
|
||||
size_t len;
|
||||
len = MIN2<size_t>(end - start, sizeof(_exeName) - 1);
|
||||
memcpy(_exeName, start, len);
|
||||
@ -747,11 +747,11 @@ void SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_name() {
|
||||
char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_cmdline() {
|
||||
FILE* fp;
|
||||
char buffer[PATH_MAX];
|
||||
char* cmdline = NULL;
|
||||
char* cmdline = nullptr;
|
||||
|
||||
jio_snprintf(buffer, PATH_MAX, "/proc/%s/cmdline", _entry->d_name);
|
||||
buffer[PATH_MAX - 1] = '\0';
|
||||
if ((fp = os::fopen(buffer, "r")) != NULL) {
|
||||
if ((fp = os::fopen(buffer, "r")) != nullptr) {
|
||||
size_t size = 0;
|
||||
char dummy;
|
||||
|
||||
@ -790,10 +790,10 @@ char* SystemProcessInterface::SystemProcesses::ProcessIterator::get_exe_path() {
|
||||
}
|
||||
|
||||
char* SystemProcessInterface::SystemProcesses::ProcessIterator::allocate_string(const char* str) const {
|
||||
if (str != NULL) {
|
||||
if (str != nullptr) {
|
||||
return os::strdup_check_oom(str, mtInternal);
|
||||
}
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int SystemProcessInterface::SystemProcesses::ProcessIterator::current(SystemProcess* process_info) {
|
||||
@ -806,13 +806,13 @@ int SystemProcessInterface::SystemProcesses::ProcessIterator::current(SystemProc
|
||||
get_exe_name();
|
||||
process_info->set_name(allocate_string(_exeName));
|
||||
|
||||
if (get_exe_path() != NULL) {
|
||||
if (get_exe_path() != nullptr) {
|
||||
process_info->set_path(allocate_string(_exePath));
|
||||
}
|
||||
|
||||
char* cmdline = NULL;
|
||||
char* cmdline = nullptr;
|
||||
cmdline = get_cmdline();
|
||||
if (cmdline != NULL) {
|
||||
if (cmdline != nullptr) {
|
||||
process_info->set_command_line(allocate_string(cmdline));
|
||||
FREE_C_HEAP_ARRAY(char, cmdline);
|
||||
}
|
||||
@ -827,7 +827,7 @@ int SystemProcessInterface::SystemProcesses::ProcessIterator::next_process() {
|
||||
|
||||
do {
|
||||
_entry = os::readdir(_dir);
|
||||
if (_entry == NULL) {
|
||||
if (_entry == nullptr) {
|
||||
// Error or reached end. Could use errno to distinguish those cases.
|
||||
_valid = false;
|
||||
return OS_ERR;
|
||||
@ -839,14 +839,14 @@ int SystemProcessInterface::SystemProcesses::ProcessIterator::next_process() {
|
||||
}
|
||||
|
||||
SystemProcessInterface::SystemProcesses::ProcessIterator::ProcessIterator() {
|
||||
_dir = NULL;
|
||||
_entry = NULL;
|
||||
_dir = nullptr;
|
||||
_entry = nullptr;
|
||||
_valid = false;
|
||||
}
|
||||
|
||||
bool SystemProcessInterface::SystemProcesses::ProcessIterator::initialize() {
|
||||
_dir = os::opendir("/proc");
|
||||
_entry = NULL;
|
||||
_entry = nullptr;
|
||||
_valid = true;
|
||||
next_process();
|
||||
|
||||
@ -854,13 +854,13 @@ bool SystemProcessInterface::SystemProcesses::ProcessIterator::initialize() {
|
||||
}
|
||||
|
||||
SystemProcessInterface::SystemProcesses::ProcessIterator::~ProcessIterator() {
|
||||
if (_dir != NULL) {
|
||||
if (_dir != nullptr) {
|
||||
os::closedir(_dir);
|
||||
}
|
||||
}
|
||||
|
||||
SystemProcessInterface::SystemProcesses::SystemProcesses() {
|
||||
_iterator = NULL;
|
||||
_iterator = nullptr;
|
||||
}
|
||||
|
||||
bool SystemProcessInterface::SystemProcesses::initialize() {
|
||||
@ -869,26 +869,26 @@ bool SystemProcessInterface::SystemProcesses::initialize() {
|
||||
}
|
||||
|
||||
SystemProcessInterface::SystemProcesses::~SystemProcesses() {
|
||||
if (_iterator != NULL) {
|
||||
if (_iterator != nullptr) {
|
||||
delete _iterator;
|
||||
}
|
||||
}
|
||||
|
||||
int SystemProcessInterface::SystemProcesses::system_processes(SystemProcess** system_processes, int* no_of_sys_processes) const {
|
||||
assert(system_processes != NULL, "system_processes pointer is NULL!");
|
||||
assert(no_of_sys_processes != NULL, "system_processes counter pointers is NULL!");
|
||||
assert(_iterator != NULL, "iterator is NULL!");
|
||||
assert(system_processes != nullptr, "system_processes pointer is null!");
|
||||
assert(no_of_sys_processes != nullptr, "system_processes counter pointers is null!");
|
||||
assert(_iterator != nullptr, "iterator is null!");
|
||||
|
||||
// initialize pointers
|
||||
*no_of_sys_processes = 0;
|
||||
*system_processes = NULL;
|
||||
*system_processes = nullptr;
|
||||
|
||||
while (_iterator->is_valid()) {
|
||||
SystemProcess* tmp = new SystemProcess();
|
||||
_iterator->current(tmp);
|
||||
|
||||
//if already existing head
|
||||
if (*system_processes != NULL) {
|
||||
if (*system_processes != nullptr) {
|
||||
//move "first to second"
|
||||
tmp->set_next(*system_processes);
|
||||
}
|
||||
@ -907,7 +907,7 @@ int SystemProcessInterface::system_processes(SystemProcess** system_procs, int*
|
||||
}
|
||||
|
||||
SystemProcessInterface::SystemProcessInterface() {
|
||||
_impl = NULL;
|
||||
_impl = nullptr;
|
||||
}
|
||||
|
||||
bool SystemProcessInterface::initialize() {
|
||||
@ -916,13 +916,13 @@ bool SystemProcessInterface::initialize() {
|
||||
}
|
||||
|
||||
SystemProcessInterface::~SystemProcessInterface() {
|
||||
if (_impl != NULL) {
|
||||
if (_impl != nullptr) {
|
||||
delete _impl;
|
||||
}
|
||||
}
|
||||
|
||||
CPUInformationInterface::CPUInformationInterface() {
|
||||
_cpu_info = NULL;
|
||||
_cpu_info = nullptr;
|
||||
}
|
||||
|
||||
bool CPUInformationInterface::initialize() {
|
||||
@ -937,23 +937,23 @@ bool CPUInformationInterface::initialize() {
|
||||
}
|
||||
|
||||
CPUInformationInterface::~CPUInformationInterface() {
|
||||
if (_cpu_info != NULL) {
|
||||
if (_cpu_info->cpu_name() != NULL) {
|
||||
if (_cpu_info != nullptr) {
|
||||
if (_cpu_info->cpu_name() != nullptr) {
|
||||
const char* cpu_name = _cpu_info->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();
|
||||
FREE_C_HEAP_ARRAY(char, cpu_desc);
|
||||
_cpu_info->set_cpu_description(NULL);
|
||||
_cpu_info->set_cpu_description(nullptr);
|
||||
}
|
||||
delete _cpu_info;
|
||||
}
|
||||
}
|
||||
|
||||
int CPUInformationInterface::cpu_information(CPUInformation& cpu_info) {
|
||||
if (_cpu_info == NULL) {
|
||||
if (_cpu_info == nullptr) {
|
||||
return OS_ERR;
|
||||
}
|
||||
|
||||
@ -1000,7 +1000,7 @@ int64_t NetworkPerformanceInterface::NetworkPerformance::read_counter(const char
|
||||
}
|
||||
|
||||
buf[num_bytes] = '\0';
|
||||
int64_t value = strtoll(buf, NULL, 10);
|
||||
int64_t value = strtoll(buf, nullptr, 10);
|
||||
|
||||
return value;
|
||||
}
|
||||
@ -1014,9 +1014,9 @@ int NetworkPerformanceInterface::NetworkPerformance::network_utilization(Network
|
||||
return OS_ERR;
|
||||
}
|
||||
|
||||
NetworkInterface* ret = NULL;
|
||||
for (cur_address = addresses; cur_address != NULL; cur_address = cur_address->ifa_next) {
|
||||
if ((cur_address->ifa_addr == NULL) || (cur_address->ifa_addr->sa_family != AF_PACKET)) {
|
||||
NetworkInterface* ret = nullptr;
|
||||
for (cur_address = addresses; cur_address != nullptr; cur_address = cur_address->ifa_next) {
|
||||
if ((cur_address->ifa_addr == nullptr) || (cur_address->ifa_addr->sa_family != AF_PACKET)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -1034,11 +1034,11 @@ int NetworkPerformanceInterface::NetworkPerformance::network_utilization(Network
|
||||
}
|
||||
|
||||
NetworkPerformanceInterface::NetworkPerformanceInterface() {
|
||||
_impl = NULL;
|
||||
_impl = nullptr;
|
||||
}
|
||||
|
||||
NetworkPerformanceInterface::~NetworkPerformanceInterface() {
|
||||
if (_impl != NULL) {
|
||||
if (_impl != nullptr) {
|
||||
delete _impl;
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (c) 2021 SAP SE. All rights reserved.
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -43,7 +43,7 @@ public:
|
||||
return "Low";
|
||||
}
|
||||
static const JavaPermission permission() {
|
||||
JavaPermission p = { "java.lang.management.ManagementPermission", "control", NULL };
|
||||
JavaPermission p = { "java.lang.management.ManagementPermission", "control", nullptr };
|
||||
return p;
|
||||
}
|
||||
virtual void execute(DCmdSource source, TRAPS);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -46,7 +46,7 @@
|
||||
#endif
|
||||
|
||||
static int futex(volatile int *addr, int futex_op, int op_arg) {
|
||||
return syscall(SYS_futex, addr, futex_op, op_arg, NULL, NULL, 0);
|
||||
return syscall(SYS_futex, addr, futex_op, op_arg, nullptr, nullptr, 0);
|
||||
}
|
||||
|
||||
void LinuxWaitBarrier::arm(int barrier_tag) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user