8301481: Replace NULL with nullptr in os/windows

Reviewed-by: coleenp, dholmes
This commit is contained in:
Johan Sjölen 2023-02-17 09:41:12 +00:00
parent 47ca5773a5
commit c91cd2814b
21 changed files with 652 additions and 652 deletions

View File

@ -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
@ -150,7 +150,7 @@ class Win32AttachOperation: public AttachOperation {
// noarg constructor as operation is preallocated
Win32AttachOperation() : AttachOperation("<noname>") {
set_pipe("<nopipe>");
set_next(NULL);
set_next(nullptr);
}
public:
@ -160,15 +160,15 @@ class Win32AttachOperation: public AttachOperation {
// Preallocate the maximum number of operations that can be enqueued.
int Win32AttachListener::init() {
_mutex = (void*)::CreateMutex(NULL, FALSE, NULL);
guarantee(_mutex != (HANDLE)NULL, "mutex creation failed");
_mutex = (void*)::CreateMutex(nullptr, FALSE, nullptr);
guarantee(_mutex != (HANDLE)nullptr, "mutex creation failed");
_enqueued_ops_semaphore = ::CreateSemaphore(NULL, 0, max_enqueued_operations, NULL);
guarantee(_enqueued_ops_semaphore != (HANDLE)NULL, "semaphore creation failed");
_enqueued_ops_semaphore = ::CreateSemaphore(nullptr, 0, max_enqueued_operations, nullptr);
guarantee(_enqueued_ops_semaphore != (HANDLE)nullptr, "semaphore creation failed");
set_head(NULL);
set_tail(NULL);
set_available(NULL);
set_head(nullptr);
set_tail(nullptr);
set_available(nullptr);
for (int i=0; i<max_enqueued_operations; i++) {
Win32AttachOperation* op = new Win32AttachOperation();
@ -211,12 +211,12 @@ int Win32AttachListener::enqueue(char* cmd, char* arg0, char* arg1, char* arg2,
// try to get an operation from the available list
Win32AttachOperation* op = available();
if (op != NULL) {
if (op != nullptr) {
set_available(op->next());
// add to end (tail) of list
op->set_next(NULL);
if (tail() == NULL) {
op->set_next(nullptr);
if (tail() == nullptr) {
set_head(op);
} else {
tail()->set_next(op);
@ -233,12 +233,12 @@ int Win32AttachListener::enqueue(char* cmd, char* arg0, char* arg1, char* arg2,
// Side effect: Semaphore will be signaled and will release
// any blocking waiters (i.e. the AttachListener thread).
BOOL not_exceeding_semaphore_maximum_count =
::ReleaseSemaphore(enqueued_ops_semaphore(), 1, NULL);
::ReleaseSemaphore(enqueued_ops_semaphore(), 1, nullptr);
guarantee(not_exceeding_semaphore_maximum_count, "invariant");
}
::ReleaseMutex(mutex());
return (op != NULL) ? 0 : ATTACH_ERROR_RESOURCE;
return (op != nullptr) ? 0 : ATTACH_ERROR_RESOURCE;
}
@ -254,15 +254,15 @@ Win32AttachOperation* Win32AttachListener::dequeue() {
guarantee(res == WAIT_OBJECT_0, "wait failed");
Win32AttachOperation* op = head();
if (op != NULL) {
if (op != nullptr) {
set_head(op->next());
if (head() == NULL) { // list is empty
set_tail(NULL);
if (head() == nullptr) { // list is empty
set_tail(nullptr);
}
}
::ReleaseMutex(mutex());
if (op != NULL) {
if (op != nullptr) {
return op;
}
}
@ -274,10 +274,10 @@ HANDLE Win32AttachOperation::open_pipe() {
HANDLE hPipe = ::CreateFile( pipe(), // pipe name
GENERIC_WRITE, // write only
0, // no sharing
NULL, // default security attributes
nullptr, // default security attributes
OPEN_EXISTING, // opens existing pipe
0, // default attributes
NULL); // no template file
nullptr); // no template file
return hPipe;
}
@ -290,7 +290,7 @@ BOOL Win32AttachOperation::write_pipe(HANDLE hPipe, char* buf, int len) {
(LPCVOID)buf, // message
(DWORD)len, // message length
&nwrote, // bytes written
NULL); // not overlapped
nullptr); // not overlapped
if (!fSuccess) {
return fSuccess;
}
@ -392,7 +392,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) {

View File

@ -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
@ -66,7 +66,7 @@ uintptr_t ZMapper::reserve(uintptr_t addr, size_t size) {
size, // Size
MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, // AllocationType
PAGE_NOACCESS, // PageProtection
NULL, // ExtendedParameters
nullptr, // ExtendedParameters
0 // ParameterCount
);
@ -101,11 +101,11 @@ HANDLE ZMapper::create_paging_file_mapping(size_t size) {
HANDLE const res = ZSyscall::CreateFileMappingW(
INVALID_HANDLE_VALUE, // hFile
NULL, // lpFileMappingAttribute
nullptr, // lpFileMappingAttribute
PAGE_READWRITE | SEC_RESERVE, // flProtect
size >> 32, // dwMaximumSizeHigh
size & 0xFFFFFFFF, // dwMaximumSizeLow
NULL // lpName
nullptr // lpName
);
// Caller responsible for error handling
@ -133,12 +133,12 @@ uintptr_t ZMapper::map_view_no_placeholder(HANDLE file_handle, uintptr_t file_of
void* const res = ZSyscall::MapViewOfFile3(
file_handle, // FileMapping
GetCurrentProcess(), // ProcessHandle
NULL, // BaseAddress
nullptr, // BaseAddress
file_offset, // Offset
size, // ViewSize
0, // AllocationType
PAGE_NOACCESS, // PageProtection
NULL, // ExtendedParameters
nullptr, // ExtendedParameters
0 // ParameterCount
);
@ -165,7 +165,7 @@ uintptr_t ZMapper::commit(uintptr_t addr, size_t size) {
size, // Size
MEM_COMMIT, // AllocationType
PAGE_NOACCESS, // PageProtection
NULL, // ExtendedParameters
nullptr, // ExtendedParameters
0 // ParameterCount
);
@ -206,17 +206,17 @@ HANDLE ZMapper::create_shared_awe_section() {
HANDLE section = ZSyscall::CreateFileMapping2(
INVALID_HANDLE_VALUE, // File
NULL, // SecurityAttributes
nullptr, // SecurityAttributes
SECTION_MAP_READ | SECTION_MAP_WRITE, // DesiredAccess
PAGE_READWRITE, // PageProtection
SEC_RESERVE | SEC_LARGE_PAGES, // AllocationAttributes
0, // MaximumSize
NULL, // Name
nullptr, // Name
&parameter, // ExtendedParameters
1 // ParameterCount
);
if (section == NULL) {
if (section == nullptr) {
fatal("Could not create shared AWE section (%d)", GetLastError());
}
@ -288,11 +288,11 @@ void ZMapper::map_view_replace_placeholder(HANDLE file_handle, uintptr_t file_of
size, // ViewSize
MEM_REPLACE_PLACEHOLDER, // AllocationType
PAGE_READWRITE, // PageProtection
NULL, // ExtendedParameters
nullptr, // ExtendedParameters
0 // ParameterCount
);
if (res == NULL) {
if (res == nullptr) {
fatal_error("Failed to map memory", addr, size);
}
}

View File

@ -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
@ -195,7 +195,7 @@ public:
void unmap(uintptr_t addr, size_t size) const {
const size_t npages = size >> ZGranuleSizeShift;
const bool res = MapUserPhysicalPages((char*)addr, npages, NULL);
const bool res = MapUserPhysicalPages((char*)addr, npages, nullptr);
if (!res) {
fatal("Failed to unmap view " PTR_FORMAT " " SIZE_FORMAT "M (%d)",
addr, size / M, GetLastError());

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 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
@ -38,7 +38,7 @@ static void* lookup_kernelbase_library() {
const char* const name = "KernelBase";
char ebuf[1024];
void* const handle = os::dll_load(name, ebuf, sizeof(ebuf));
if (handle == NULL) {
if (handle == nullptr) {
log_error_p(gc)("Failed to load library: %s", name);
}
return handle;
@ -46,14 +46,14 @@ static void* lookup_kernelbase_library() {
static void* lookup_kernelbase_symbol(const char* name) {
static void* const handle = lookup_kernelbase_library();
if (handle == NULL) {
return NULL;
if (handle == nullptr) {
return nullptr;
}
return os::dll_lookup(handle, name);
}
static bool has_kernelbase_symbol(const char* name) {
return lookup_kernelbase_symbol(name) != NULL;
return lookup_kernelbase_symbol(name) != nullptr;
}
template <typename Fn>
@ -64,7 +64,7 @@ static void install_kernelbase_symbol(Fn*& fn, const char* name) {
template <typename Fn>
static void install_kernelbase_1803_symbol_or_exit(Fn*& fn, const char* name) {
install_kernelbase_symbol(fn, name);
if (fn == NULL) {
if (fn == nullptr) {
log_error_p(gc)("Failed to lookup symbol: %s", name);
vm_exit_during_initialization("ZGC requires Windows version 1803 or later");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 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
@ -30,7 +30,7 @@
uintptr_t ZUtils::alloc_aligned(size_t alignment, size_t size) {
void* const res = _aligned_malloc(size, alignment);
if (res == NULL) {
if (res == nullptr) {
fatal("_aligned_malloc failed");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 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
@ -139,7 +139,7 @@ private:
virtual bool reserve(uintptr_t addr, size_t size) {
const uintptr_t res = ZMapper::reserve(addr, size);
assert(res == addr || res == NULL, "Should not reserve other memory than requested");
assert(res == addr || res == 0, "Should not reserve other memory than requested");
return res == addr;
}
@ -162,7 +162,7 @@ private:
virtual bool reserve(uintptr_t addr, size_t size) {
const uintptr_t res = ZMapper::reserve_for_shared_awe(ZAWESection, addr, size);
assert(res == addr || res == NULL, "Should not reserve other memory than requested");
assert(res == addr || res == 0, "Should not reserve other memory than requested");
return res == addr;
}
@ -171,7 +171,7 @@ private:
}
};
static ZVirtualMemoryManagerImpl* _impl = NULL;
static ZVirtualMemoryManagerImpl* _impl = nullptr;
void ZVirtualMemoryManager::pd_initialize_before_reserve() {
if (ZLargePages::is_enabled()) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 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
@ -32,18 +32,18 @@ typedef DWORD(WINAPI *GetIfTable2_Fn)(PMIB_IF_TABLE2*);
typedef DWORD(WINAPI *FreeMibTable_Fn)(PVOID);
// IPHLP statics
GetIfTable2_Fn IphlpDll::_GetIfTable2 = NULL;
FreeMibTable_Fn IphlpDll::_FreeMibTable = NULL;
GetIfTable2_Fn IphlpDll::_GetIfTable2 = nullptr;
FreeMibTable_Fn IphlpDll::_FreeMibTable = nullptr;
LONG IphlpDll::_critical_section = 0;
LONG IphlpDll::_initialized = 0;
LONG IphlpDll::_iphlp_reference_count = 0;
HMODULE IphlpDll::_hModule = NULL;
HMODULE IphlpDll::_hModule = nullptr;
void IphlpDll::initialize(void) {
_hModule = os::win32::load_Windows_dll("iphlpapi.dll", NULL, 0);
_hModule = os::win32::load_Windows_dll("iphlpapi.dll", nullptr, 0);
if (NULL == _hModule) {
if (nullptr == _hModule) {
return;
}
@ -60,12 +60,12 @@ bool IphlpDll::IphlpDetach(void) {
BOOL ret = false;
if (1 == prev_ref_count) {
if (_initialized && _hModule != NULL) {
if (_initialized && _hModule != nullptr) {
ret = FreeLibrary(_hModule);
if (ret) {
_hModule = NULL;
_GetIfTable2 = NULL;
_FreeMibTable = NULL;
_hModule = nullptr;
_GetIfTable2 = nullptr;
_FreeMibTable = nullptr;
InterlockedExchange(&_initialized, 0);
}
}
@ -88,18 +88,18 @@ bool IphlpDll::IphlpAttach(void) {
while (InterlockedCompareExchange(&_critical_section, 0, 1) == 0);
return (_GetIfTable2 != NULL && _FreeMibTable != NULL);
return (_GetIfTable2 != nullptr && _FreeMibTable != nullptr);
}
DWORD IphlpDll::GetIfTable2(PMIB_IF_TABLE2* Table) {
assert(_initialized && _GetIfTable2 != NULL,
assert(_initialized && _GetIfTable2 != nullptr,
"IphlpAttach() not yet called");
return _GetIfTable2(Table);
}
DWORD IphlpDll::FreeMibTable(PVOID Memory) {
assert(_initialized && _FreeMibTable != NULL,
assert(_initialized && _FreeMibTable != nullptr,
"IphlpAttach() not yet called");
return _FreeMibTable(Memory);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -27,13 +27,13 @@
#include "runtime/osThread.hpp"
void OSThread::pd_initialize() {
set_thread_handle(NULL);
set_thread_id(NULL);
set_interrupt_event(NULL);
set_thread_handle(nullptr);
set_thread_id(0);
set_interrupt_event(nullptr);
}
void OSThread::pd_destroy() {
if (_interrupt_event != NULL) {
if (_interrupt_event != nullptr) {
CloseHandle(_interrupt_event);
}
}

View File

@ -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.
*
* This code is free software; you can redistribute it and/or modify it
@ -87,9 +87,9 @@ static const char* const PROCESS_OBJECT_WITH_INSTANCES_WILDCARD_FMT = "\\%s(%s*)
static const size_t PROCESS_OBJECT_WITH_INSTANCES_WILDCARD_FMT_LEN = 5;
/* pdh string constants built up from fmts on initialization */
static const char* process_image_name = NULL; // e.g. "java" but could have another image name
static char* pdh_process_instance_IDProcess_counter_fmt = NULL; // "\Process(java#%d)\ID Process" */
static char* pdh_process_instance_wildcard_IDProcess_counter = NULL; // "\Process(java*)\ID Process" */
static const char* process_image_name = nullptr; // e.g. "java" but could have another image name
static char* pdh_process_instance_IDProcess_counter_fmt = nullptr; // "\Process(java#%d)\ID Process" */
static char* pdh_process_instance_wildcard_IDProcess_counter = nullptr; // "\Process(java*)\ID Process" */
/*
* Structs for PDH queries.
@ -125,7 +125,7 @@ typedef struct {
} ProcessQueryS, *ProcessQueryP;
static int open_query(HQUERY* pdh_query_handle) {
return PdhDll::PdhOpenQuery(NULL, 0, pdh_query_handle) != ERROR_SUCCESS ? OS_ERR : OS_OK;
return PdhDll::PdhOpenQuery(nullptr, 0, pdh_query_handle) != ERROR_SUCCESS ? OS_ERR : OS_OK;
}
static int open_query(UpdateQueryP query) {
@ -138,21 +138,21 @@ static int open_query(QueryP query) {
}
static void close_query(HQUERY* const pdh_query_handle, HCOUNTER* const counter) {
if (counter != NULL && *counter != NULL) {
if (counter != nullptr && *counter != nullptr) {
PdhDll::PdhRemoveCounter(*counter);
*counter = NULL;
*counter = nullptr;
}
if (pdh_query_handle != NULL && *pdh_query_handle != NULL) {
if (pdh_query_handle != nullptr && *pdh_query_handle != nullptr) {
PdhDll::PdhCloseQuery(*pdh_query_handle);
*pdh_query_handle = NULL;
*pdh_query_handle = nullptr;
}
}
static void close_query(MultiCounterQueryP query) {
for (int i = 0; i < query->noOfCounters; ++i) {
close_query(NULL, &query->counters[i]);
close_query(nullptr, &query->counters[i]);
}
close_query(&query->query.pdh_query_handle, NULL);
close_query(&query->query.pdh_query_handle, nullptr);
query->initialized = false;
}
@ -169,18 +169,18 @@ static MultiCounterQueryP create_multi_counter_query() {
}
static void destroy(CounterQueryP query) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
close_query(&query->query.pdh_query_handle, &query->counter);
FREE_C_HEAP_OBJ(query);
}
static void destroy(MultiCounterQueryP query) {
if (query != NULL) {
if (query != nullptr) {
for (int i = 0; i < query->noOfCounters; ++i) {
close_query(NULL, &query->counters[i]);
close_query(nullptr, &query->counters[i]);
}
FREE_C_HEAP_ARRAY(char, query->counters);
close_query(&query->query.pdh_query_handle, NULL);
close_query(&query->query.pdh_query_handle, nullptr);
FREE_C_HEAP_ARRAY(MultiCounterQueryS, query);
}
}
@ -188,10 +188,10 @@ static void destroy(MultiCounterQueryP query) {
static void destroy_query_set(MultiCounterQuerySetP query_set) {
for (int i = 0; i < query_set->size; i++) {
for (int j = 0; j < query_set->queries[i].noOfCounters; ++j) {
close_query(NULL, &query_set->queries[i].counters[j]);
close_query(nullptr, &query_set->queries[i].counters[j]);
}
FREE_C_HEAP_ARRAY(char, query_set->queries[i].counters);
close_query(&query_set->queries[i].query.pdh_query_handle, NULL);
close_query(&query_set->queries[i].query.pdh_query_handle, nullptr);
}
FREE_C_HEAP_ARRAY(MultiCounterQueryS, query_set->queries);
}
@ -207,17 +207,17 @@ static void destroy(ProcessQueryP query) {
}
static void allocate_counters(MultiCounterQueryP query, size_t nofCounters) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
assert(!query->initialized, "invariant");
assert(0 == query->noOfCounters, "invariant");
assert(query->counters == NULL, "invariant");
assert(query->counters == nullptr, "invariant");
query->counters = NEW_C_HEAP_ARRAY(HCOUNTER, nofCounters, mtInternal);
memset(query->counters, 0, nofCounters * sizeof(HCOUNTER));
query->noOfCounters = (int)nofCounters;
}
static void allocate_counters(MultiCounterQuerySetP query, size_t nofCounters) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
assert(!query->initialized, "invariant");
for (int i = 0; i < query->size; ++i) {
allocate_counters(&query->queries[i], nofCounters);
@ -225,26 +225,26 @@ static void allocate_counters(MultiCounterQuerySetP query, size_t nofCounters) {
}
static void allocate_counters(ProcessQueryP query, size_t nofCounters) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
allocate_counters(&query->set, nofCounters);
}
static void deallocate_counters(MultiCounterQueryP query) {
FREE_C_HEAP_ARRAY(char, query->counters);
query->counters = NULL;
query->counters = nullptr;
query->noOfCounters = 0;
}
static OSReturn add_counter(UpdateQueryP query, HCOUNTER* counter, const char* counter_path, bool first_sample_on_init) {
assert(query != NULL, "invariant");
assert(counter != NULL, "invariant");
assert(counter_path != NULL, "invariant");
if (query->pdh_query_handle == NULL) {
assert(query != nullptr, "invariant");
assert(counter != nullptr, "invariant");
assert(counter_path != nullptr, "invariant");
if (query->pdh_query_handle == nullptr) {
if (open_query(query) != OS_OK) {
return OS_ERR;
}
}
assert(query->pdh_query_handle != NULL, "invariant");
assert(query->pdh_query_handle != nullptr, "invariant");
PDH_STATUS status = PdhDll::PdhAddCounter(query->pdh_query_handle, counter_path, 0, counter);
if (PDH_CSTATUS_NO_OBJECT == status || PDH_CSTATUS_NO_COUNTER == status) {
return OS_ERR;
@ -268,9 +268,9 @@ static OSReturn add_counter(UpdateQueryP query, HCOUNTER* counter, const char* c
template <typename QueryP>
static OSReturn add_counter(QueryP query, HCOUNTER* counter, const char* counter_path, bool first_sample_on_init) {
assert(query != NULL, "invariant");
assert(counter != NULL, "invariant");
assert(counter_path != NULL, "invariant");
assert(query != nullptr, "invariant");
assert(counter != nullptr, "invariant");
assert(counter_path != nullptr, "invariant");
return add_counter(&query->query, counter, counter_path, first_sample_on_init);
}
@ -280,9 +280,9 @@ static OSReturn add_counter(CounterQueryP query, const char* counter_path, bool
}
static OSReturn add_counter(MultiCounterQueryP query, int counter_idx, const char* counter_path, bool first_sample_on_init) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
assert(counter_idx < query->noOfCounters, "invariant");
assert(query->counters[counter_idx] == NULL, "invariant");
assert(query->counters[counter_idx] == nullptr, "invariant");
return add_counter(query, &query->counters[counter_idx], counter_path, first_sample_on_init);
}
@ -292,7 +292,7 @@ static OSReturn add_counter(MultiCounterQueryP query, int counter_idx, const cha
static const int min_update_interval_millis = 500;
static int collect(UpdateQueryP query) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
const s8 now = os::javaTimeNanos();
if (nanos_to_millis(now - query->lastUpdate) > min_update_interval_millis) {
if (PdhDll::PdhCollectQueryData(query->pdh_query_handle) != ERROR_SUCCESS) {
@ -305,31 +305,31 @@ static int collect(UpdateQueryP query) {
template <typename QueryP>
static int collect(QueryP query) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
return collect(&query->query);
}
static int formatted_counter_value(HCOUNTER counter, DWORD format, PDH_FMT_COUNTERVALUE* const value) {
assert(value != NULL, "invariant");
return PdhDll::PdhGetFormattedCounterValue(counter, format, NULL, value) != ERROR_SUCCESS ? OS_ERR : OS_OK;
assert(value != nullptr, "invariant");
return PdhDll::PdhGetFormattedCounterValue(counter, format, nullptr, value) != ERROR_SUCCESS ? OS_ERR : OS_OK;
}
static int read_counter(CounterQueryP query, DWORD format, PDH_FMT_COUNTERVALUE* const value) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
return formatted_counter_value(query->counter, format, value);
}
static int read_counter(MultiCounterQueryP query, int counter_idx, DWORD format, PDH_FMT_COUNTERVALUE* const value) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
assert(counter_idx < query->noOfCounters, "invariant");
assert(query->counters[counter_idx] != NULL, "invariant");
assert(query->counters[counter_idx] != nullptr, "invariant");
return formatted_counter_value(query->counters[counter_idx], format, value);
}
static int read_counter(ProcessQueryP query, int counter_idx, DWORD format, PDH_FMT_COUNTERVALUE* const value) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
MultiCounterQueryP const current_query = &query->set.queries[query->process_idx];
assert(current_query != NULL, "invariant");
assert(current_query != nullptr, "invariant");
return read_counter(current_query, counter_idx, format, value);
}
@ -339,17 +339,17 @@ static int read_counter(ProcessQueryP query, int counter_idx, DWORD format, PDH_
* A tally of this list is returned to the caller.
*/
static int number_of_live_process_instances() {
char* buffer = NULL;
char* buffer = nullptr;
DWORD size = 0;
// determine size
PDH_STATUS status = PdhDll::PdhExpandWildCardPath(NULL,
PDH_STATUS status = PdhDll::PdhExpandWildCardPath(nullptr,
pdh_process_instance_wildcard_IDProcess_counter,
buffer,
&size,
PDH_NOEXPANDCOUNTERS);
while (status == PDH_MORE_DATA) {
buffer = NEW_RESOURCE_ARRAY(char, size);
status = PdhDll::PdhExpandWildCardPath(NULL,
status = PdhDll::PdhExpandWildCardPath(nullptr,
pdh_process_instance_wildcard_IDProcess_counter,
buffer,
&size,
@ -367,11 +367,11 @@ static int number_of_live_process_instances() {
}
static PDH_STATUS pdh_process_idx_to_pid(HQUERY& pdh_query_handle, int idx, LONG* pid) {
assert(pid != NULL, "invariant");
assert(pid != nullptr, "invariant");
char counter_path[PDH_MAX_COUNTER_PATH];
jio_snprintf(counter_path, sizeof(counter_path) - 1, pdh_process_instance_IDProcess_counter_fmt, idx);
assert(strlen(counter_path) < sizeof(counter_path), "invariant");
HCOUNTER counter = NULL;
HCOUNTER counter = nullptr;
PDH_STATUS status = PdhDll::PdhAddCounter(pdh_query_handle, counter_path, 0, &counter);
if (status != ERROR_SUCCESS) {
close_query(&pdh_query_handle, &counter);
@ -379,7 +379,7 @@ static PDH_STATUS pdh_process_idx_to_pid(HQUERY& pdh_query_handle, int idx, LONG
}
status = PdhDll::PdhCollectQueryData(pdh_query_handle);
if (status != ERROR_SUCCESS) {
close_query(NULL, &counter);
close_query(nullptr, &counter);
return PDH_NO_DATA;
}
PDH_FMT_COUNTERVALUE counter_value;
@ -389,7 +389,7 @@ static PDH_STATUS pdh_process_idx_to_pid(HQUERY& pdh_query_handle, int idx, LONG
return status;
}
*pid = counter_value.longValue;
close_query(NULL, &counter);
close_query(nullptr, &counter);
return ERROR_SUCCESS;
}
@ -451,10 +451,10 @@ static int max_process_query_idx = 0;
static int current_process_query_index(int previous_query_idx = 0) {
assert(max_process_query_idx >= 0, "invariant");
assert(max_process_query_idx >= previous_query_idx, "invariant");
assert(process_image_name != NULL, "invariant");
assert(pdh_process_instance_IDProcess_counter_fmt != NULL, "invariant");
assert(process_image_name != nullptr, "invariant");
assert(pdh_process_instance_IDProcess_counter_fmt != nullptr, "invariant");
int result = OS_ERR;
HQUERY tmp_pdh_query_handle = NULL;
HQUERY tmp_pdh_query_handle = nullptr;
if (open_query(&tmp_pdh_query_handle) != OS_OK) {
return OS_ERR;
}
@ -480,12 +480,12 @@ static int current_process_query_index(int previous_query_idx = 0) {
break;
}
}
close_query(&tmp_pdh_query_handle, NULL);
close_query(&tmp_pdh_query_handle, nullptr);
return result;
}
static int ensure_current_process_query_index(ProcessQueryP query) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
const int previous_query_idx = query->process_idx;
if (previous_query_idx == 0) {
return previous_query_idx;
@ -508,18 +508,18 @@ static int ensure_current_process_query_index(ProcessQueryP query) {
}
static MultiCounterQueryP current_process_query(ProcessQueryP query) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
if (ensure_current_process_query_index(query) == OS_ERR) {
return NULL;
return nullptr;
}
assert(query->process_idx < query->set.size, "invariant");
return &query->set.queries[query->process_idx];
}
static int collect(ProcessQueryP query) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
MultiCounterQueryP current_query = current_process_query(query);
return current_query != NULL ? collect(current_query) : OS_ERR;
return current_query != nullptr ? collect(current_query) : OS_ERR;
}
/*
@ -537,10 +537,10 @@ static int collect(ProcessQueryP query) {
*/
static const char* make_fully_qualified_counter_path(const char* object_name,
const char* counter_name,
const char* image_name = NULL,
const char* instance = NULL) {
assert(object_name != NULL, "invariant");
assert(counter_name != NULL, "invariant");
const char* image_name = nullptr,
const char* instance = nullptr) {
assert(object_name != nullptr, "invariant");
assert(counter_name != nullptr, "invariant");
size_t counter_path_len = strlen(object_name) + strlen(counter_name);
char* counter_path;
@ -562,7 +562,7 @@ static const char* make_fully_qualified_counter_path(const char* object_name,
*
* Examples: "\Process(java#0)", \Process(java#1"), ...
*/
assert(instance != NULL, "invariant");
assert(instance != nullptr, "invariant");
counter_path_len += strlen(instance);
counter_path = NEW_RESOURCE_ARRAY(char, counter_path_len + 1);
jio_snprintf_result = jio_snprintf(counter_path,
@ -620,7 +620,7 @@ static void log_invalid_pdh_index(DWORD index) {
static bool is_valid_pdh_index(DWORD index) {
DWORD dummy = 0;
if (PdhDll::PdhLookupPerfNameByIndex(NULL, index, NULL, &dummy) != PDH_MORE_DATA) {
if (PdhDll::PdhLookupPerfNameByIndex(nullptr, index, nullptr, &dummy) != PDH_MORE_DATA) {
log_invalid_pdh_index(index);
return false;
}
@ -637,19 +637,19 @@ static bool is_valid_pdh_index(DWORD index) {
* @return OS_OK if successful, OS_ERR on failure.
*/
static OSReturn lookup_name_by_index(DWORD index, char** p_string) {
assert(p_string != NULL, "invariant");
assert(p_string != nullptr, "invariant");
if (!is_valid_pdh_index(index)) {
return OS_ERR;
}
// determine size needed
DWORD size = 0;
PDH_STATUS status = PdhDll::PdhLookupPerfNameByIndex(NULL, index, NULL, &size);
PDH_STATUS status = PdhDll::PdhLookupPerfNameByIndex(nullptr, index, nullptr, &size);
assert(status == PDH_MORE_DATA, "invariant");
*p_string = NEW_RESOURCE_ARRAY(char, size);
if (PdhDll::PdhLookupPerfNameByIndex(NULL, index, *p_string, &size) != ERROR_SUCCESS) {
if (PdhDll::PdhLookupPerfNameByIndex(nullptr, index, *p_string, &size) != ERROR_SUCCESS) {
return OS_ERR;
}
if (0 == size || *p_string == NULL) {
if (0 == size || *p_string == nullptr) {
return OS_ERR;
}
// windows vista does not null-terminate the string (although the docs says it will)
@ -658,7 +658,7 @@ static OSReturn lookup_name_by_index(DWORD index, char** p_string) {
}
static const char* copy_string_to_c_heap(const char* string) {
assert(string != NULL, "invariant");
assert(string != nullptr, "invariant");
const size_t len = strlen(string);
char* const cheap_allocated_string = NEW_C_HEAP_ARRAY(char, len + 1, mtInternal);
strncpy(cheap_allocated_string, string, len + 1);
@ -671,13 +671,13 @@ static const char* copy_string_to_c_heap(const char* string) {
* Caller will need a ResourceMark.
*
* @param pdh_artifact_idx the counter index as specified in the registry
* @return localized pdh artifact string if successful, NULL on failure.
* @return localized pdh artifact string if successful, null on failure.
*/
static const char* pdh_localized_artifact(DWORD pdh_artifact_idx) {
char* pdh_localized_artifact_string = NULL;
char* pdh_localized_artifact_string = nullptr;
// get localized name for the pdh artifact idx
if (lookup_name_by_index(pdh_artifact_idx, &pdh_localized_artifact_string) != OS_OK) {
return NULL;
return nullptr;
}
return pdh_localized_artifact_string;
}
@ -691,17 +691,17 @@ static const char* pdh_localized_artifact(DWORD pdh_artifact_idx) {
*
* Caller needs ResourceMark.
*
* @return the process image string description, NULL if the call failed.
* @return the process image string description, null if the call failed.
*/
static const char* pdh_process_image_name() {
char* module_name = NEW_RESOURCE_ARRAY(char, MAX_PATH);
// Find our module name and use it to extract the image name used by PDH
DWORD getmfn_return = GetModuleFileName(NULL, module_name, MAX_PATH);
DWORD getmfn_return = GetModuleFileName(nullptr, module_name, MAX_PATH);
if (getmfn_return >= MAX_PATH || 0 == getmfn_return) {
return NULL;
return nullptr;
}
if (os::get_last_error() == ERROR_INSUFFICIENT_BUFFER) {
return NULL;
return nullptr;
}
char* process_image_name = strrchr(module_name, '\\'); //drop path
process_image_name++; //skip slash
@ -712,28 +712,28 @@ static const char* pdh_process_image_name() {
static void deallocate_pdh_constants() {
FREE_C_HEAP_ARRAY(char, process_image_name);
process_image_name = NULL;
process_image_name = nullptr;
FREE_C_HEAP_ARRAY(char, pdh_process_instance_IDProcess_counter_fmt);
pdh_process_instance_IDProcess_counter_fmt = NULL;
pdh_process_instance_IDProcess_counter_fmt = nullptr;
FREE_C_HEAP_ARRAY(char, pdh_process_instance_wildcard_IDProcess_counter);
pdh_process_instance_wildcard_IDProcess_counter = NULL;
pdh_process_instance_wildcard_IDProcess_counter = nullptr;
}
static OSReturn allocate_pdh_constants() {
assert(process_image_name == NULL, "invariant");
assert(process_image_name == nullptr, "invariant");
const char* pdh_image_name = pdh_process_image_name();
if (pdh_image_name == NULL) {
if (pdh_image_name == nullptr) {
return OS_ERR;
}
process_image_name = copy_string_to_c_heap(pdh_image_name);
const char* pdh_localized_process_object = pdh_localized_artifact(PDH_PROCESS_IDX);
if (pdh_localized_process_object == NULL) {
if (pdh_localized_process_object == nullptr) {
return OS_ERR;
}
const char* pdh_localized_IDProcess_counter = pdh_localized_artifact(PDH_ID_PROCESS_IDX);
if (pdh_localized_IDProcess_counter == NULL) {
if (pdh_localized_IDProcess_counter == nullptr) {
return OS_ERR;
}
@ -745,7 +745,7 @@ static OSReturn allocate_pdh_constants() {
PROCESS_OBJECT_WITH_INSTANCES_COUNTER_FMT_LEN +
2; // "%d"
assert(pdh_process_instance_IDProcess_counter_fmt == NULL, "invariant");
assert(pdh_process_instance_IDProcess_counter_fmt == nullptr, "invariant");
pdh_process_instance_IDProcess_counter_fmt = NEW_C_HEAP_ARRAY(char, pdh_IDProcess_counter_fmt_len + 1, mtInternal);
/* "\Process(java#%d)\ID Process" */
@ -757,14 +757,14 @@ static OSReturn allocate_pdh_constants() {
"%d",
pdh_localized_IDProcess_counter);
assert(pdh_process_instance_IDProcess_counter_fmt != NULL, "invariant");
assert(pdh_process_instance_IDProcess_counter_fmt != nullptr, "invariant");
assert(len == pdh_IDProcess_counter_fmt_len, "invariant");
const size_t pdh_IDProcess_wildcard_fmt_len = id_process_base_length +
PROCESS_OBJECT_WITH_INSTANCES_WILDCARD_FMT_LEN;
assert(pdh_process_instance_wildcard_IDProcess_counter == NULL, "invariant");
assert(pdh_process_instance_wildcard_IDProcess_counter == nullptr, "invariant");
pdh_process_instance_wildcard_IDProcess_counter = NEW_C_HEAP_ARRAY(char, pdh_IDProcess_wildcard_fmt_len + 1, mtInternal);
/* "\Process(java*)\ID Process" */
@ -775,7 +775,7 @@ static OSReturn allocate_pdh_constants() {
process_image_name,
pdh_localized_IDProcess_counter);
assert(pdh_process_instance_wildcard_IDProcess_counter != NULL, "invariant");
assert(pdh_process_instance_wildcard_IDProcess_counter != nullptr, "invariant");
assert(len == pdh_IDProcess_wildcard_fmt_len, "invariant");
return OS_OK;
}
@ -784,44 +784,44 @@ static OSReturn allocate_pdh_constants() {
* Enuerate the Processor PDH object and returns a buffer containing the enumerated instances.
* Caller needs ResourceMark;
*
* @return buffer if successful, NULL on failure.
* @return buffer if successful, null on failure.
*/
static const char* enumerate_cpu_instances() {
char* processor; //'Processor' == PDH_PROCESSOR_IDX
if (lookup_name_by_index(PDH_PROCESSOR_IDX, &processor) != OS_OK) {
return NULL;
return nullptr;
}
DWORD c_size = 0;
DWORD i_size = 0;
// enumerate all processors.
PDH_STATUS pdhStat = PdhDll::PdhEnumObjectItems(NULL, // reserved
NULL, // local machine
PDH_STATUS pdhStat = PdhDll::PdhEnumObjectItems(nullptr, // reserved
nullptr, // local machine
processor, // object to enumerate
NULL,
nullptr,
&c_size,
NULL, // instance buffer is NULL and
nullptr, // instance buffer is null and
&i_size, // pass 0 length in order to get the required size
PERF_DETAIL_WIZARD, // counter detail level
0);
if (PdhDll::PdhStatusFail((pdhStat))) {
return NULL;
return nullptr;
}
char* const instances = NEW_RESOURCE_ARRAY(char, i_size);
c_size = 0;
pdhStat = PdhDll::PdhEnumObjectItems(NULL, // reserved
NULL, // local machine
pdhStat = PdhDll::PdhEnumObjectItems(nullptr, // reserved
nullptr, // local machine
processor, // object to enumerate
NULL,
nullptr,
&c_size,
instances, // now instance buffer is allocated to be filled in
&i_size, // and the required size is known
PERF_DETAIL_WIZARD, // counter detail level
0);
return PdhDll::PdhStatusFail(pdhStat) ? NULL : instances;
return PdhDll::PdhStatusFail(pdhStat) ? nullptr : instances;
}
static int count_logical_cpus(const char* instances) {
assert(instances != NULL, "invariant");
assert(instances != nullptr, "invariant");
// count logical instances.
DWORD count;
char* tmp;
@ -835,7 +835,7 @@ static int number_of_logical_cpus() {
static int numberOfCPUS = 0;
if (numberOfCPUS == 0) {
const char* instances = enumerate_cpu_instances();
if (instances == NULL) {
if (instances == nullptr) {
return OS_ERR;
}
numberOfCPUS = count_logical_cpus(instances);
@ -860,22 +860,22 @@ static void log_error_message_on_no_PDH_artifact(const char* counter_path) {
}
static int initialize_cpu_query_counters(MultiCounterQueryP query, DWORD pdh_counter_idx) {
assert(query != NULL, "invariant");
assert(query->counters != NULL, "invariant");
assert(query != nullptr, "invariant");
assert(query->counters != nullptr, "invariant");
char* processor; //'Processor' == PDH_PROCESSOR_IDX
if (lookup_name_by_index(PDH_PROCESSOR_IDX, &processor) != OS_OK) {
return OS_ERR;
}
char* counter_name = NULL;
char* counter_name = nullptr;
if (lookup_name_by_index(pdh_counter_idx, &counter_name) != OS_OK) {
return OS_ERR;
}
if (query->query.pdh_query_handle == NULL) {
if (query->query.pdh_query_handle == nullptr) {
if (open_query(query) != OS_OK) {
return OS_ERR;
}
}
assert(query->query.pdh_query_handle != NULL, "invariant");
assert(query->query.pdh_query_handle != nullptr, "invariant");
size_t counter_len = strlen(processor);
counter_len += strlen(counter_name);
counter_len += OBJECT_WITH_INSTANCES_COUNTER_FMT_LEN; // "\\%s(%s)\\%s"
@ -904,7 +904,7 @@ static int initialize_cpu_query_counters(MultiCounterQueryP query, DWORD pdh_cou
}
static int initialize_cpu_query(MultiCounterQueryP query) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
assert(!query->initialized, "invariant");
const int logical_cpu_count = number_of_logical_cpus();
assert(logical_cpu_count >= os::processor_count(), "invariant");
@ -919,17 +919,17 @@ static int initialize_cpu_query(MultiCounterQueryP query) {
}
static int initialize_query(CounterQueryP query, DWORD pdh_object_idx, DWORD pdh_counter_idx) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
assert(!query->initialized, "invariant");
if (!((is_valid_pdh_index(pdh_object_idx) && is_valid_pdh_index(pdh_counter_idx)))) {
return OS_ERR;
}
const char* object = pdh_localized_artifact(pdh_object_idx);
assert(object != NULL, "invariant");
assert(object != nullptr, "invariant");
const char* counter = pdh_localized_artifact(pdh_counter_idx);
assert(counter != NULL, "invariant");
assert(counter != nullptr, "invariant");
const char* counter_path = make_fully_qualified_counter_path(object, counter);
assert(counter_path != NULL, "invariant");
assert(counter_path != nullptr, "invariant");
if (add_counter(query, counter_path, true) != OS_OK) {
return OS_ERR;
}
@ -944,7 +944,7 @@ static int initialize_context_switches_query(CounterQueryP query) {
static ProcessQueryP create_process_query() {
const int current_process_query_idx = current_process_query_index();
if (current_process_query_idx == OS_ERR) {
return NULL;
return nullptr;
}
ProcessQueryP const query = NEW_C_HEAP_OBJ(ProcessQueryS, mtInternal);
memset(query, 0, sizeof(ProcessQueryS));
@ -961,19 +961,19 @@ static int initialize_process_counter(ProcessQueryP process_query, int counter_i
if (lookup_name_by_index(PDH_PROCESS_IDX, &localized_process_object) != OS_OK) {
return OS_ERR;
}
assert(localized_process_object != NULL, "invariant");
assert(localized_process_object != nullptr, "invariant");
char* localized_counter_name;
if (lookup_name_by_index(pdh_counter_idx, &localized_counter_name) != OS_OK) {
return OS_ERR;
}
assert(localized_counter_name != NULL, "invariant");
assert(localized_counter_name != nullptr, "invariant");
for (int i = 0; i < process_query->set.size; ++i) {
char instanceIndexBuffer[32];
const char* counter_path = make_fully_qualified_counter_path(localized_process_object,
localized_counter_name,
process_image_name,
itoa(i, instanceIndexBuffer, 10));
assert(counter_path != NULL, "invariant");
assert(counter_path != nullptr, "invariant");
MultiCounterQueryP const query = &process_query->set.queries[i];
if (add_counter(query, counter_idx, counter_path, true) != OS_OK) {
return OS_ERR;
@ -987,7 +987,7 @@ static int initialize_process_counter(ProcessQueryP process_query, int counter_i
}
static int initialize_process_query(ProcessQueryP query) {
assert(query != NULL, "invariant");
assert(query != nullptr, "invariant");
assert(!query->set.initialized, "invariant");
allocate_counters(query, 2);
if (initialize_process_counter(query, 0, PDH_PROCESSOR_TIME_IDX) != OS_OK) {
@ -1093,20 +1093,20 @@ class CPUPerformanceInterface::CPUPerformance : public CHeapObj<mtInternal> {
bool initialize();
};
CPUPerformanceInterface::CPUPerformance::CPUPerformance() : _context_switches(NULL), _process_cpu_load(NULL), _machine_cpu_load(NULL) {}
CPUPerformanceInterface::CPUPerformance::CPUPerformance() : _context_switches(nullptr), _process_cpu_load(nullptr), _machine_cpu_load(nullptr) {}
bool CPUPerformanceInterface::CPUPerformance::initialize() {
if (pdh_acquire() != OS_OK) {
return false;
}
_context_switches = create_counter_query();
assert(_context_switches != NULL, "invariant");
assert(_context_switches != nullptr, "invariant");
if (initialize_context_switches_query(_context_switches) != OS_OK) {
return false;
}
assert(_context_switches->initialized, "invariant");
_process_cpu_load = create_process_query();
if (_process_cpu_load == NULL) {
if (_process_cpu_load == nullptr) {
return false;
}
if (initialize_process_query(_process_cpu_load) != OS_OK) {
@ -1114,7 +1114,7 @@ bool CPUPerformanceInterface::CPUPerformance::initialize() {
}
assert(_process_cpu_load->set.initialized, "invariant");
_machine_cpu_load = create_multi_counter_query();
assert(_machine_cpu_load != NULL, "invariant");
assert(_machine_cpu_load != nullptr, "invariant");
if (initialize_cpu_query(_machine_cpu_load) != OS_OK) {
return false;
}
@ -1123,22 +1123,22 @@ bool CPUPerformanceInterface::CPUPerformance::initialize() {
}
CPUPerformanceInterface::CPUPerformance::~CPUPerformance() {
if (_context_switches != NULL) {
if (_context_switches != nullptr) {
destroy(_context_switches);
_context_switches = NULL;
_context_switches = nullptr;
}
if (_process_cpu_load != NULL) {
if (_process_cpu_load != nullptr) {
destroy(_process_cpu_load);
_process_cpu_load = NULL;
_process_cpu_load = nullptr;
}
if (_machine_cpu_load != NULL) {
if (_machine_cpu_load != nullptr) {
destroy(_machine_cpu_load);
_machine_cpu_load = NULL;
_machine_cpu_load = nullptr;
}
pdh_release();
}
CPUPerformanceInterface::CPUPerformanceInterface() : _impl(NULL) {}
CPUPerformanceInterface::CPUPerformanceInterface() : _impl(nullptr) {}
bool CPUPerformanceInterface::initialize() {
_impl = new CPUPerformanceInterface::CPUPerformance();
@ -1146,7 +1146,7 @@ bool CPUPerformanceInterface::initialize() {
}
CPUPerformanceInterface::~CPUPerformanceInterface() {
if (_impl != NULL) {
if (_impl != nullptr) {
delete _impl;
}
}
@ -1171,7 +1171,7 @@ int CPUPerformanceInterface::cpu_loads_process(double* jvm_user_load,
int CPUPerformanceInterface::CPUPerformance::cpu_load(int which_logical_cpu, double* cpu_load) {
*cpu_load = .0;
if (_machine_cpu_load == NULL || !_machine_cpu_load->initialized) {
if (_machine_cpu_load == nullptr || !_machine_cpu_load->initialized) {
return OS_ERR;
}
assert(which_logical_cpu < _machine_cpu_load->noOfCounters, "invariant");
@ -1190,7 +1190,7 @@ int CPUPerformanceInterface::CPUPerformance::cpu_load(int which_logical_cpu, dou
int CPUPerformanceInterface::CPUPerformance::cpu_load_total_process(double* cpu_load) {
*cpu_load = .0;
if (_process_cpu_load == NULL || !_process_cpu_load->set.initialized) {
if (_process_cpu_load == nullptr || !_process_cpu_load->set.initialized) {
return OS_ERR;
}
if (collect(_process_cpu_load) != OS_OK) {
@ -1210,14 +1210,14 @@ int CPUPerformanceInterface::CPUPerformance::cpu_load_total_process(double* cpu_
int CPUPerformanceInterface::CPUPerformance::cpu_loads_process(double* jvm_user_load,
double* jvm_kernel_load,
double* system_total_load) {
assert(jvm_user_load != NULL, "jvm_user_load is NULL!");
assert(jvm_kernel_load != NULL, "jvm_kernel_load is NULL!");
assert(system_total_load != NULL, "system_total_load is NULL!");
assert(jvm_user_load != nullptr, "jvm_user_load is null!");
assert(jvm_kernel_load != nullptr, "jvm_kernel_load is null!");
assert(system_total_load != nullptr, "system_total_load is null!");
*jvm_user_load = .0;
*jvm_kernel_load = .0;
*system_total_load = .0;
if (_process_cpu_load == NULL || !_process_cpu_load->set.initialized) {
if (_process_cpu_load == nullptr || !_process_cpu_load->set.initialized) {
return OS_ERR;
}
if (collect(_process_cpu_load) != OS_OK) {
@ -1263,9 +1263,9 @@ int CPUPerformanceInterface::CPUPerformance::cpu_loads_process(double* jvm_user_
}
int CPUPerformanceInterface::CPUPerformance::context_switch_rate(double* rate) {
assert(rate != NULL, "invariant");
assert(rate != nullptr, "invariant");
*rate = .0;
if (_context_switches == NULL || !_context_switches->initialized) {
if (_context_switches == nullptr || !_context_switches->initialized) {
return OS_ERR;
}
if (collect(_context_switches) != OS_OK) {
@ -1338,10 +1338,10 @@ SystemProcessInterface::SystemProcesses::ProcessIterator::~ProcessIterator() {
int SystemProcessInterface::SystemProcesses::ProcessIterator::current(SystemProcess* process_info) {
assert(is_valid(), "no current process to be fetched!");
assert(process_info != NULL, "process_info is NULL!");
char* exePath = NULL;
assert(process_info != nullptr, "process_info is null!");
char* exePath = nullptr;
HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, _pe32.th32ProcessID);
if (hProcess != NULL) {
if (hProcess != nullptr) {
HMODULE hMod;
DWORD cbNeeded;
if (EnumProcessModules(hProcess, &hMod, sizeof(hMod), &cbNeeded) != 0) {
@ -1358,7 +1358,7 @@ int SystemProcessInterface::SystemProcesses::ProcessIterator::current(SystemProc
}
char* SystemProcessInterface::SystemProcesses::ProcessIterator::allocate_string(const char* str) const {
return str != NULL ? os::strdup_check_oom(str, mtInternal) : NULL;
return str != nullptr ? os::strdup_check_oom(str, mtInternal) : nullptr;
}
int SystemProcessInterface::SystemProcesses::ProcessIterator::next_process() {
@ -1366,7 +1366,7 @@ int SystemProcessInterface::SystemProcesses::ProcessIterator::next_process() {
return OS_OK;
}
SystemProcessInterface::SystemProcesses::SystemProcesses() : _iterator(NULL) {}
SystemProcessInterface::SystemProcesses::SystemProcesses() : _iterator(nullptr) {}
bool SystemProcessInterface::SystemProcesses::initialize() {
_iterator = new SystemProcessInterface::SystemProcesses::ProcessIterator();
@ -1374,20 +1374,20 @@ 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;
// take process snapshot
if (_iterator->snapshot() != OS_OK) {
@ -1399,7 +1399,7 @@ int SystemProcessInterface::SystemProcesses::system_processes(SystemProcess** sy
_iterator->current(tmp);
//if already existing head
if (*system_processes != NULL) {
if (*system_processes != nullptr) {
//move "first to second"
tmp->set_next(*system_processes);
}
@ -1418,7 +1418,7 @@ int SystemProcessInterface::system_processes(SystemProcess** system_procs,
return _impl->system_processes(system_procs, no_of_sys_processes);
}
SystemProcessInterface::SystemProcessInterface() : _impl(NULL) {}
SystemProcessInterface::SystemProcessInterface() : _impl(nullptr) {}
bool SystemProcessInterface::initialize() {
_impl = new SystemProcessInterface::SystemProcesses();
@ -1426,12 +1426,12 @@ bool SystemProcessInterface::initialize() {
}
SystemProcessInterface::~SystemProcessInterface() {
if (_impl != NULL) {
if (_impl != nullptr) {
delete _impl;
}
}
CPUInformationInterface::CPUInformationInterface() : _cpu_info(NULL) {}
CPUInformationInterface::CPUInformationInterface() : _cpu_info(nullptr) {}
bool CPUInformationInterface::initialize() {
_cpu_info = new CPUInformation();
@ -1445,17 +1445,17 @@ bool CPUInformationInterface::initialize() {
}
CPUInformationInterface::~CPUInformationInterface() {
if (_cpu_info != NULL) {
if (_cpu_info != nullptr) {
FREE_C_HEAP_ARRAY(char, _cpu_info->cpu_name());
_cpu_info->set_cpu_name(NULL);
_cpu_info->set_cpu_name(nullptr);
FREE_C_HEAP_ARRAY(char, _cpu_info->cpu_description());
_cpu_info->set_cpu_description(NULL);
_cpu_info->set_cpu_description(nullptr);
delete _cpu_info;
}
}
int CPUInformationInterface::cpu_information(CPUInformation& cpu_info) {
if (NULL == _cpu_info) {
if (nullptr == _cpu_info) {
return OS_ERR;
}
cpu_info = *_cpu_info; // shallow copy assignment
@ -1494,14 +1494,14 @@ int NetworkPerformanceInterface::NetworkPerformance::network_utilization(Network
return OS_ERR;
}
NetworkInterface* ret = NULL;
NetworkInterface* ret = nullptr;
for (ULONG i = 0; i < table->NumEntries; ++i) {
if (table->Table[i].InterfaceAndOperStatusFlags.FilterInterface) {
continue;
}
char buf[256];
if (WideCharToMultiByte(CP_UTF8, 0, table->Table[i].Description, -1, buf, sizeof(buf), NULL, NULL) == 0) {
if (WideCharToMultiByte(CP_UTF8, 0, table->Table[i].Description, -1, buf, sizeof(buf), nullptr, nullptr) == 0) {
continue;
}
@ -1515,10 +1515,10 @@ int NetworkPerformanceInterface::NetworkPerformance::network_utilization(Network
return OS_OK;
}
NetworkPerformanceInterface::NetworkPerformanceInterface() : _impl(NULL) {}
NetworkPerformanceInterface::NetworkPerformanceInterface() : _impl(nullptr) {}
NetworkPerformanceInterface::~NetworkPerformanceInterface() {
if (_impl != NULL) {
if (_impl != nullptr) {
delete _impl;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 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
@ -41,8 +41,8 @@ class PlatformEvent : public CHeapObj<mtSynchronizer> {
public:
PlatformEvent() {
_Event = 0 ;
_ParkHandle = CreateEvent (NULL, false, false, NULL) ;
guarantee (_ParkHandle != NULL, "invariant") ;
_ParkHandle = CreateEvent (nullptr, false, false, nullptr) ;
guarantee (_ParkHandle != nullptr, "invariant") ;
}
// Exercise caution using reset() and fired() - they may require MEMBARs
@ -61,8 +61,8 @@ class PlatformParker {
public:
PlatformParker() {
_ParkHandle = CreateEvent (NULL, true, false, NULL) ;
guarantee(_ParkHandle != NULL, "invariant") ;
_ParkHandle = CreateEvent (nullptr, true, false, nullptr) ;
guarantee(_ParkHandle != nullptr, "invariant") ;
}
~PlatformParker() {
CloseHandle(_ParkHandle);

View File

@ -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
@ -40,25 +40,25 @@ typedef PDH_STATUS (WINAPI *PdhLookupPerfNameByIndex_Fn)(LPCSTR, DWORD, LPSTR, L
typedef PDH_STATUS (WINAPI *PdhMakeCounterPath_Fn)(PDH_COUNTER_PATH_ELEMENTS*, LPTSTR, LPDWORD, DWORD);
typedef PDH_STATUS (WINAPI *PdhExpandWildCardPath_Fn)(LPCSTR, LPCSTR, PZZSTR, LPDWORD, DWORD);
PdhAddCounter_Fn PdhDll::_PdhAddCounter = NULL;
PdhOpenQuery_Fn PdhDll::_PdhOpenQuery = NULL;
PdhCloseQuery_Fn PdhDll::_PdhCloseQuery = NULL;
PdhCollectQueryData_Fn PdhDll::_PdhCollectQueryData = NULL;
PdhGetFormattedCounterValue_Fn PdhDll::_PdhGetFormattedCounterValue = NULL;
PdhEnumObjectItems_Fn PdhDll::_PdhEnumObjectItems = NULL;
PdhRemoveCounter_Fn PdhDll::_PdhRemoveCounter = NULL;
PdhLookupPerfNameByIndex_Fn PdhDll::_PdhLookupPerfNameByIndex = NULL;
PdhMakeCounterPath_Fn PdhDll::_PdhMakeCounterPath = NULL;
PdhExpandWildCardPath_Fn PdhDll::_PdhExpandWildCardPath = NULL;
PdhAddCounter_Fn PdhDll::_PdhAddCounter = nullptr;
PdhOpenQuery_Fn PdhDll::_PdhOpenQuery = nullptr;
PdhCloseQuery_Fn PdhDll::_PdhCloseQuery = nullptr;
PdhCollectQueryData_Fn PdhDll::_PdhCollectQueryData = nullptr;
PdhGetFormattedCounterValue_Fn PdhDll::_PdhGetFormattedCounterValue = nullptr;
PdhEnumObjectItems_Fn PdhDll::_PdhEnumObjectItems = nullptr;
PdhRemoveCounter_Fn PdhDll::_PdhRemoveCounter = nullptr;
PdhLookupPerfNameByIndex_Fn PdhDll::_PdhLookupPerfNameByIndex = nullptr;
PdhMakeCounterPath_Fn PdhDll::_PdhMakeCounterPath = nullptr;
PdhExpandWildCardPath_Fn PdhDll::_PdhExpandWildCardPath = nullptr;
LONG PdhDll::_critical_section = 0;
LONG PdhDll::_initialized = 0;
LONG PdhDll::_pdh_reference_count = 0;
HMODULE PdhDll::_hModule = NULL;
HMODULE PdhDll::_hModule = nullptr;
void PdhDll::initialize(void) {
_hModule = os::win32::load_Windows_dll("pdh.dll", NULL, 0);
if (NULL == _hModule) {
_hModule = os::win32::load_Windows_dll("pdh.dll", nullptr, 0);
if (nullptr == _hModule) {
return;
}
// The 'A' at the end means the ANSI (not the UNICODE) versions of the methods
@ -79,20 +79,20 @@ bool PdhDll::PdhDetach(void) {
LONG prev_ref_count = InterlockedExchangeAdd(&_pdh_reference_count, -1);
BOOL ret = false;
if (1 == prev_ref_count) {
if (_initialized && _hModule != NULL) {
if (_initialized && _hModule != nullptr) {
ret = FreeLibrary(_hModule);
if (ret) {
_hModule = NULL;
_PdhAddCounter = NULL;
_PdhOpenQuery = NULL;
_PdhCloseQuery = NULL;
_PdhCollectQueryData = NULL;
_PdhGetFormattedCounterValue = NULL;
_PdhEnumObjectItems = NULL;
_PdhRemoveCounter = NULL;
_PdhLookupPerfNameByIndex = NULL;
_PdhMakeCounterPath = NULL;
_PdhExpandWildCardPath = NULL;
_hModule = nullptr;
_PdhAddCounter = nullptr;
_PdhOpenQuery = nullptr;
_PdhCloseQuery = nullptr;
_PdhCollectQueryData = nullptr;
_PdhGetFormattedCounterValue = nullptr;
_PdhEnumObjectItems = nullptr;
_PdhRemoveCounter = nullptr;
_PdhLookupPerfNameByIndex = nullptr;
_PdhMakeCounterPath = nullptr;
_PdhExpandWildCardPath = nullptr;
InterlockedExchange(&_initialized, 0);
}
}
@ -110,63 +110,63 @@ bool PdhDll::PdhAttach(void) {
initialize();
}
while (InterlockedCompareExchange(&_critical_section, 0, 1) == 0);
return (_PdhAddCounter != NULL && _PdhOpenQuery != NULL
&& _PdhCloseQuery != NULL && _PdhCollectQueryData != NULL
&& _PdhGetFormattedCounterValue != NULL && _PdhEnumObjectItems != NULL
&& _PdhRemoveCounter != NULL && _PdhLookupPerfNameByIndex != NULL
&& _PdhMakeCounterPath != NULL && _PdhExpandWildCardPath != NULL);
return (_PdhAddCounter != nullptr && _PdhOpenQuery != nullptr
&& _PdhCloseQuery != nullptr && _PdhCollectQueryData != nullptr
&& _PdhGetFormattedCounterValue != nullptr && _PdhEnumObjectItems != nullptr
&& _PdhRemoveCounter != nullptr && _PdhLookupPerfNameByIndex != nullptr
&& _PdhMakeCounterPath != nullptr && _PdhExpandWildCardPath != nullptr);
}
PDH_STATUS PdhDll::PdhAddCounter(HQUERY hQuery, LPCSTR szFullCounterPath, DWORD dwUserData, HCOUNTER* phCounter) {
assert(_initialized && _PdhAddCounter != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhAddCounter != nullptr, "PdhAvailable() not yet called");
return _PdhAddCounter(hQuery, szFullCounterPath, dwUserData, phCounter);
}
PDH_STATUS PdhDll::PdhOpenQuery(LPCWSTR szDataSource, DWORD dwUserData, HQUERY* phQuery) {
assert(_initialized && _PdhOpenQuery != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhOpenQuery != nullptr, "PdhAvailable() not yet called");
return _PdhOpenQuery(szDataSource, dwUserData, phQuery);
}
DWORD PdhDll::PdhCloseQuery(HQUERY hQuery) {
assert(_initialized && _PdhCloseQuery != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhCloseQuery != nullptr, "PdhAvailable() not yet called");
return _PdhCloseQuery(hQuery);
}
PDH_STATUS PdhDll::PdhCollectQueryData(HQUERY hQuery) {
assert(_initialized && _PdhCollectQueryData != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhCollectQueryData != nullptr, "PdhAvailable() not yet called");
return _PdhCollectQueryData(hQuery);
}
DWORD PdhDll::PdhGetFormattedCounterValue(HCOUNTER hCounter, DWORD dwFormat, LPDWORD lpdwType, PPDH_FMT_COUNTERVALUE pValue) {
assert(_initialized && _PdhGetFormattedCounterValue != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhGetFormattedCounterValue != nullptr, "PdhAvailable() not yet called");
return _PdhGetFormattedCounterValue(hCounter, dwFormat, lpdwType, pValue);
}
PDH_STATUS PdhDll::PdhEnumObjectItems(LPCTSTR szDataSource, LPCTSTR szMachineName, LPCTSTR szObjectName,
LPTSTR mszCounterList, LPDWORD pcchCounterListLength, LPTSTR mszInstanceList,
LPDWORD pcchInstanceListLength, DWORD dwDetailLevel, DWORD dwFlags) {
assert(_initialized && _PdhEnumObjectItems != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhEnumObjectItems != nullptr, "PdhAvailable() not yet called");
return _PdhEnumObjectItems(szDataSource, szMachineName, szObjectName, mszCounterList, pcchCounterListLength,
mszInstanceList, pcchInstanceListLength, dwDetailLevel, dwFlags);
}
PDH_STATUS PdhDll::PdhRemoveCounter(HCOUNTER hCounter) {
assert(_initialized && _PdhRemoveCounter != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhRemoveCounter != nullptr, "PdhAvailable() not yet called");
return _PdhRemoveCounter(hCounter);
}
PDH_STATUS PdhDll::PdhLookupPerfNameByIndex(LPCSTR szMachineName, DWORD dwNameIndex, LPSTR szNameBuffer, LPDWORD pcchNameBufferSize) {
assert(_initialized && _PdhLookupPerfNameByIndex != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhLookupPerfNameByIndex != nullptr, "PdhAvailable() not yet called");
return _PdhLookupPerfNameByIndex(szMachineName, dwNameIndex, szNameBuffer, pcchNameBufferSize);
}
PDH_STATUS PdhDll::PdhMakeCounterPath(PDH_COUNTER_PATH_ELEMENTS* pCounterPathElements, LPTSTR szFullPathBuffer, LPDWORD pcchBufferSize, DWORD dwFlags) {
assert(_initialized && _PdhMakeCounterPath != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhMakeCounterPath != nullptr, "PdhAvailable() not yet called");
return _PdhMakeCounterPath(pCounterPathElements, szFullPathBuffer, pcchBufferSize, dwFlags);
}
PDH_STATUS PdhDll::PdhExpandWildCardPath(LPCSTR szDataSource, LPCSTR szWildCardPath, PZZSTR mszExpandedPathList, LPDWORD pcchPathListLength, DWORD dwFlags) {
assert(_initialized && _PdhExpandWildCardPath != NULL, "PdhAvailable() not yet called");
assert(_initialized && _PdhExpandWildCardPath != nullptr, "PdhAvailable() not yet called");
return _PdhExpandWildCardPath(szDataSource, szWildCardPath, mszExpandedPathList, pcchPathListLength, dwFlags);
}

View File

@ -57,8 +57,8 @@ static char* create_standard_memory(size_t size) {
// allocate an aligned chuck of memory
char* mapAddress = os::reserve_memory(size);
if (mapAddress == NULL) {
return NULL;
if (mapAddress == nullptr) {
return nullptr;
}
// commit memory
@ -67,7 +67,7 @@ static char* create_standard_memory(size_t size) {
warning("Could not commit PerfData memory\n");
}
os::release_memory(mapAddress, size);
return NULL;
return nullptr;
}
return mapAddress;
@ -149,9 +149,9 @@ static void save_memory_to_file(char* addr, size_t size) {
// os::get_temp_directory() in os_win32.cpp), control the location of the
// user specific directory and the shared memory backing store file.
static HANDLE sharedmem_fileMapHandle = NULL;
static HANDLE sharedmem_fileMapHandle = nullptr;
static HANDLE sharedmem_fileHandle = INVALID_HANDLE_VALUE;
static char* sharedmem_fileName = NULL;
static char* sharedmem_fileName = nullptr;
// return the user specific temporary directory name.
//
@ -185,7 +185,7 @@ static int filename_to_pid(const char* filename) {
// check if file name can be converted to an integer without
// any leftover characters.
//
char* remainder = NULL;
char* remainder = nullptr;
errno = 0;
int pid = (int)strtol(filename, &remainder, 10);
@ -196,7 +196,7 @@ static int filename_to_pid(const char* filename) {
// check for left over characters. If any, then the filename is
// not a candidate for conversion.
//
if (remainder != NULL && *remainder != '\0') {
if (remainder != nullptr && *remainder != '\0') {
return 0;
}
@ -277,12 +277,12 @@ static char* get_user_name() {
char* user = getenv("USERNAME");
char buf[UNLEN+1];
DWORD buflen = sizeof(buf);
if (user == NULL || strlen(user) == 0) {
if (user == nullptr || strlen(user) == 0) {
if (GetUserName(buf, &buflen)) {
user = buf;
}
else {
return NULL;
return nullptr;
}
}
@ -303,15 +303,15 @@ static char* get_user_name() {
static char* get_user_name_slow(int vmid) {
// directory search
char* latest_user = NULL;
char* latest_user = nullptr;
time_t latest_ctime = 0;
const char* tmpdirname = os::get_temp_directory();
DIR* tmpdirp = os::opendir(tmpdirname);
if (tmpdirp == NULL) {
return NULL;
if (tmpdirp == nullptr) {
return nullptr;
}
// for each entry in the directory that matches the pattern hsperfdata_*,
@ -321,7 +321,7 @@ static char* get_user_name_slow(int vmid) {
//
struct dirent* dentry;
errno = 0;
while ((dentry = os::readdir(tmpdirp)) != NULL) {
while ((dentry = os::readdir(tmpdirp)) != nullptr) {
// check if the directory entry is a hsperfdata file
if (strncmp(dentry->d_name, PERFDATA_NAME, strlen(PERFDATA_NAME)) != 0) {
@ -336,7 +336,7 @@ static char* get_user_name_slow(int vmid) {
DIR* subdirp = os::opendir(usrdir_name);
if (subdirp == NULL) {
if (subdirp == nullptr) {
FREE_C_HEAP_ARRAY(char, usrdir_name);
continue;
}
@ -355,7 +355,7 @@ static char* get_user_name_slow(int vmid) {
struct dirent* udentry;
errno = 0;
while ((udentry = os::readdir(subdirp)) != NULL) {
while ((udentry = os::readdir(subdirp)) != nullptr) {
if (filename_to_pid(udentry->d_name) == vmid) {
struct stat statbuf;
@ -514,7 +514,7 @@ static void remove_file(const char* dirname, const char* filename) {
static bool is_alive(int pid) {
HANDLE ph = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
if (ph == NULL) {
if (ph == nullptr) {
// the process does not exist.
if (PrintMiscellaneous && Verbose) {
DWORD lastError = GetLastError();
@ -553,7 +553,7 @@ static bool is_filesystem_secure(const char* path) {
}
char* first_colon = strchr((char *)path, ':');
if (first_colon == NULL) {
if (first_colon == nullptr) {
if (PrintMiscellaneous && Verbose) {
warning("expected device specifier in path: %s\n", path);
}
@ -568,13 +568,13 @@ static bool is_filesystem_secure(const char* path) {
// check that we have something like "C:\" or "AA:\"
assert(strlen(root_path) >= 3, "device specifier too short");
assert(strchr(root_path, ':') != NULL, "bad device specifier format");
assert(strchr(root_path, '\\') != NULL, "bad device specifier format");
assert(strchr(root_path, ':') != nullptr, "bad device specifier format");
assert(strchr(root_path, '\\') != nullptr, "bad device specifier format");
DWORD maxpath;
DWORD flags;
if (!GetVolumeInformation(root_path, NULL, 0, NULL, &maxpath,
if (!GetVolumeInformation(root_path, nullptr, 0, nullptr, &maxpath,
&flags, fs_type, MAX_PATH)) {
// we can't get information about the volume, so assume unsafe.
if (PrintMiscellaneous && Verbose) {
@ -620,7 +620,7 @@ static void cleanup_sharedmem_resources(const char* dirname) {
// open the user temp directory
DIR* dirp = os::opendir(dirname);
if (dirp == NULL) {
if (dirp == nullptr) {
// directory doesn't exist, so there is nothing to cleanup
return;
}
@ -641,7 +641,7 @@ static void cleanup_sharedmem_resources(const char* dirname) {
//
struct dirent* entry;
errno = 0;
while ((entry = os::readdir(dirp)) != NULL) {
while ((entry = os::readdir(dirp)) != nullptr) {
int pid = filename_to_pid(entry->d_name);
@ -691,7 +691,7 @@ static HANDLE create_file_mapping(const char* name, HANDLE fh, LPSECURITY_ATTRIB
DWORD lowSize = (DWORD)size;
DWORD highSize = 0;
HANDLE fmh = NULL;
HANDLE fmh = nullptr;
// Create a file mapping object with the given name. This function
// will grow the file to the specified size.
@ -704,11 +704,11 @@ static HANDLE create_file_mapping(const char* name, HANDLE fh, LPSECURITY_ATTRIB
lowSize, /* DWORD Low word of max size */
name); /* LPCTSTR name for object */
if (fmh == NULL) {
if (fmh == nullptr) {
if (PrintMiscellaneous && Verbose) {
warning("CreateFileMapping failed, lasterror = %d\n", GetLastError());
}
return NULL;
return nullptr;
}
if (GetLastError() == ERROR_ALREADY_EXISTS) {
@ -723,7 +723,7 @@ static HANDLE create_file_mapping(const char* name, HANDLE fh, LPSECURITY_ATTRIB
}
CloseHandle(fmh);
return NULL;
return nullptr;
}
return fmh;
@ -738,7 +738,7 @@ static void free_security_desc(PSECURITY_DESCRIPTOR pSD) {
BOOL success, exists, isdefault;
PACL pACL;
if (pSD != NULL) {
if (pSD != nullptr) {
// get the access control list from the security descriptor
success = GetSecurityDescriptorDacl(pSD, &exists, &pACL, &isdefault);
@ -746,7 +746,7 @@ static void free_security_desc(PSECURITY_DESCRIPTOR pSD) {
// if an ACL existed and it was not a default acl, then it must
// be an ACL we enlisted. free the resources.
//
if (success && exists && pACL != NULL && !isdefault) {
if (success && exists && pACL != nullptr && !isdefault) {
FREE_C_HEAP_ARRAY(char, pACL);
}
@ -760,10 +760,10 @@ static void free_security_desc(PSECURITY_DESCRIPTOR pSD) {
//
static void free_security_attr(LPSECURITY_ATTRIBUTES lpSA) {
if (lpSA != NULL) {
if (lpSA != nullptr) {
// free the contained security descriptor and the ACL
free_security_desc(lpSA->lpSecurityDescriptor);
lpSA->lpSecurityDescriptor = NULL;
lpSA->lpSecurityDescriptor = nullptr;
// free the security attributes structure
FREE_C_HEAP_OBJ(lpSA);
@ -775,11 +775,11 @@ static void free_security_attr(LPSECURITY_ATTRIBUTES lpSA) {
static PSID get_user_sid(HANDLE hProcess) {
HANDLE hAccessToken;
PTOKEN_USER token_buf = NULL;
PTOKEN_USER token_buf = nullptr;
DWORD rsize = 0;
if (hProcess == NULL) {
return NULL;
if (hProcess == nullptr) {
return nullptr;
}
// get the process token
@ -787,13 +787,13 @@ static PSID get_user_sid(HANDLE hProcess) {
if (PrintMiscellaneous && Verbose) {
warning("OpenProcessToken failure: lasterror = %d \n", GetLastError());
}
return NULL;
return nullptr;
}
// determine the size of the token structured needed to retrieve
// the user token information from the access token.
//
if (!GetTokenInformation(hAccessToken, TokenUser, NULL, rsize, &rsize)) {
if (!GetTokenInformation(hAccessToken, TokenUser, nullptr, rsize, &rsize)) {
DWORD lasterror = GetLastError();
if (lasterror != ERROR_INSUFFICIENT_BUFFER) {
if (PrintMiscellaneous && Verbose) {
@ -801,7 +801,7 @@ static PSID get_user_sid(HANDLE hProcess) {
" rsize = %d\n", lasterror, rsize);
}
CloseHandle(hAccessToken);
return NULL;
return nullptr;
}
}
@ -815,7 +815,7 @@ static PSID get_user_sid(HANDLE hProcess) {
}
FREE_C_HEAP_ARRAY(char, token_buf);
CloseHandle(hAccessToken);
return NULL;
return nullptr;
}
DWORD nbytes = GetLengthSid(token_buf->User.Sid);
@ -829,7 +829,7 @@ static PSID get_user_sid(HANDLE hProcess) {
FREE_C_HEAP_ARRAY(char, token_buf);
FREE_C_HEAP_ARRAY(char, pSID);
CloseHandle(hAccessToken);
return NULL;
return nullptr;
}
// close the access token.
@ -856,10 +856,10 @@ typedef struct ace_data {
static bool add_allow_aces(PSECURITY_DESCRIPTOR pSD,
ace_data_t aces[], int ace_count) {
PACL newACL = NULL;
PACL oldACL = NULL;
PACL newACL = nullptr;
PACL oldACL = nullptr;
if (pSD == NULL) {
if (pSD == nullptr) {
return false;
}
@ -878,8 +878,8 @@ static bool add_allow_aces(PSECURITY_DESCRIPTOR pSD,
ACL_SIZE_INFORMATION aclinfo;
// GetSecurityDescriptorDacl may return true value for exists (lpbDaclPresent)
// while oldACL is NULL for some case.
if (oldACL == NULL) {
// while oldACL is null for some case.
if (oldACL == nullptr) {
exists = FALSE;
}
@ -893,7 +893,7 @@ static bool add_allow_aces(PSECURITY_DESCRIPTOR pSD,
}
}
} else {
aclinfo.AceCount = 0; // assume NULL DACL
aclinfo.AceCount = 0; // assume null DACL
aclinfo.AclBytesFree = 0;
aclinfo.AclBytesInUse = sizeof(ACL);
}
@ -1021,7 +1021,7 @@ static bool add_allow_aces(PSECURITY_DESCRIPTOR pSD,
GetProcAddress(GetModuleHandle(TEXT("advapi32.dll")),
"SetSecurityDescriptorControl");
if (_SetSecurityDescriptorControl != NULL) {
if (_SetSecurityDescriptorControl != nullptr) {
// We do not want to further propagate inherited DACLs, so making them
// protected prevents that.
if (!_SetSecurityDescriptorControl(pSD, SE_DACL_PROTECTED,
@ -1063,13 +1063,13 @@ static LPSECURITY_ATTRIBUTES make_security_attr(ace_data_t aces[], int count) {
"lasterror = %d \n", GetLastError());
}
free_security_desc(pSD);
return NULL;
return nullptr;
}
// add the access control entries
if (!add_allow_aces(pSD, aces, count)) {
free_security_desc(pSD);
return NULL;
return nullptr;
}
// allocate and initialize the security attributes structure and
@ -1104,10 +1104,10 @@ static LPSECURITY_ATTRIBUTES make_user_everybody_admin_security_attr(
aces[0].mask = umask;
if (aces[0].pSid == 0)
return NULL;
return nullptr;
// get the well known SID for BUILTIN\Administrators
PSID administratorsSid = NULL;
PSID administratorsSid = nullptr;
SID_IDENTIFIER_AUTHORITY SIDAuthAdministrators = SECURITY_NT_AUTHORITY;
if (!AllocateAndInitializeSid( &SIDAuthAdministrators, 2,
@ -1119,7 +1119,7 @@ static LPSECURITY_ATTRIBUTES make_user_everybody_admin_security_attr(
warning("AllocateAndInitializeSid failure: "
"lasterror = %d \n", GetLastError());
}
return NULL;
return nullptr;
}
// initialize the ace data for administrator group
@ -1127,7 +1127,7 @@ static LPSECURITY_ATTRIBUTES make_user_everybody_admin_security_attr(
aces[1].mask = amask;
// get the well known SID for the universal Everybody
PSID everybodySid = NULL;
PSID everybodySid = nullptr;
SID_IDENTIFIER_AUTHORITY SIDAuthEverybody = SECURITY_WORLD_SID_AUTHORITY;
if (!AllocateAndInitializeSid( &SIDAuthEverybody, 1, SECURITY_WORLD_RID,
@ -1137,7 +1137,7 @@ static LPSECURITY_ATTRIBUTES make_user_everybody_admin_security_attr(
warning("AllocateAndInitializeSid failure: "
"lasterror = %d \n", GetLastError());
}
return NULL;
return nullptr;
}
// initialize the ace data for everybody else.
@ -1222,7 +1222,7 @@ static bool make_user_tmp_dir(const char* dirname) {
LPSECURITY_ATTRIBUTES pDirSA = make_tmpdir_security_attr();
if (pDirSA == NULL) {
if (pDirSA == nullptr) {
return false;
}
@ -1276,20 +1276,20 @@ static bool make_user_tmp_dir(const char* dirname) {
static HANDLE create_sharedmem_resources(const char* dirname, const char* filename, const char* objectname, size_t size) {
HANDLE fh = INVALID_HANDLE_VALUE;
HANDLE fmh = NULL;
HANDLE fmh = nullptr;
// create the security attributes for the backing store file
LPSECURITY_ATTRIBUTES lpFileSA = make_file_security_attr();
if (lpFileSA == NULL) {
return NULL;
if (lpFileSA == nullptr) {
return nullptr;
}
// create the security attributes for the shared memory object
LPSECURITY_ATTRIBUTES lpSmoSA = make_smo_security_attr();
if (lpSmoSA == NULL) {
if (lpSmoSA == nullptr) {
free_security_attr(lpFileSA);
return NULL;
return nullptr;
}
// create the user temporary directory
@ -1298,7 +1298,7 @@ static HANDLE create_sharedmem_resources(const char* dirname, const char* filena
// was not secure
free_security_attr(lpFileSA);
free_security_attr(lpSmoSA);
return NULL;
return nullptr;
}
// Create the file - the FILE_FLAG_DELETE_ON_CLOSE flag allows the
@ -1320,7 +1320,7 @@ static HANDLE create_sharedmem_resources(const char* dirname, const char* filena
*/
FILE_FLAG_DELETE_ON_CLOSE, /* DWORD flags and attributes */
NULL); /* HANDLE template file access */
nullptr); /* HANDLE template file access */
free_security_attr(lpFileSA);
@ -1330,7 +1330,7 @@ static HANDLE create_sharedmem_resources(const char* dirname, const char* filena
warning("could not create file %s: %d\n", filename, lasterror);
}
free_security_attr(lpSmoSA);
return NULL;
return nullptr;
}
// try to create the file mapping
@ -1338,15 +1338,15 @@ static HANDLE create_sharedmem_resources(const char* dirname, const char* filena
free_security_attr(lpSmoSA);
if (fmh == NULL) {
if (fmh == nullptr) {
// closing the file handle here will decrement the reference count
// on the file. When all processes accessing the file close their
// handle to it, the reference count will decrement to 0 and the
// OS will delete the file. These semantics are requested by the
// FILE_FLAG_DELETE_ON_CLOSE flag in CreateFile call above.
CloseHandle(fh);
fh = NULL;
return NULL;
fh = nullptr;
return nullptr;
} else {
// We created the file mapping, but rarely the size of the
// backing store file is reported as zero (0) which can cause
@ -1360,9 +1360,9 @@ static HANDLE create_sharedmem_resources(const char* dirname, const char* filena
}
CloseHandle(fmh);
CloseHandle(fh);
fh = NULL;
fmh = NULL;
return NULL;
fh = nullptr;
fmh = nullptr;
return nullptr;
}
// We could always call FlushFileBuffers() but the Microsoft
@ -1375,9 +1375,9 @@ static HANDLE create_sharedmem_resources(const char* dirname, const char* filena
}
CloseHandle(fmh);
CloseHandle(fh);
fh = NULL;
fmh = NULL;
return NULL;
fh = nullptr;
fmh = nullptr;
return nullptr;
}
}
@ -1401,7 +1401,7 @@ static HANDLE open_sharedmem_object(const char* objectname, DWORD ofm_access, TR
FALSE, /* BOOL inherit flag - Do not allow inherit */
objectname); /* name for object */
if (fmh == NULL) {
if (fmh == nullptr) {
DWORD lasterror = GetLastError();
if (PrintMiscellaneous && Verbose) {
warning("OpenFileMapping failed for shared memory object %s:"
@ -1437,8 +1437,8 @@ static char* mapping_create_shared(size_t size) {
// get the name of the user associated with this process
char* user = get_user_name();
if (user == NULL) {
return NULL;
if (user == nullptr) {
return nullptr;
}
// construct the name of the user specific temporary directory
@ -1448,7 +1448,7 @@ static char* mapping_create_shared(size_t size) {
if (!is_filesystem_secure(dirname)) {
FREE_C_HEAP_ARRAY(char, dirname);
FREE_C_HEAP_ARRAY(char, user);
return NULL;
return nullptr;
}
// create the names of the backing store files and for the
@ -1473,8 +1473,8 @@ static char* mapping_create_shared(size_t size) {
FREE_C_HEAP_ARRAY(char, objectname);
FREE_C_HEAP_ARRAY(char, dirname);
if (sharedmem_fileMapHandle == NULL) {
return NULL;
if (sharedmem_fileMapHandle == nullptr) {
return nullptr;
}
// map the file into the address space
@ -1485,13 +1485,13 @@ static char* mapping_create_shared(size_t size) {
0, /* DWORD Low word of offset */
(DWORD)size); /* DWORD Number of bytes to map */
if (mapAddress == NULL) {
if (mapAddress == nullptr) {
if (PrintMiscellaneous && Verbose) {
warning("MapViewOfFile failed, lasterror = %d\n", GetLastError());
}
CloseHandle(sharedmem_fileMapHandle);
sharedmem_fileMapHandle = NULL;
return NULL;
sharedmem_fileMapHandle = nullptr;
return nullptr;
}
// clear the shared memory region
@ -1521,9 +1521,9 @@ static void delete_file_mapping(char* addr, size_t size) {
// by the OS as long as any other JVM processes has an open file mapping
// handle or a mapped view of the file.
//
if (sharedmem_fileMapHandle != NULL) {
if (sharedmem_fileMapHandle != nullptr) {
CloseHandle(sharedmem_fileMapHandle);
sharedmem_fileMapHandle = NULL;
sharedmem_fileMapHandle = nullptr;
}
// close the file handle. This will decrement the reference count on the
@ -1581,7 +1581,7 @@ static void open_file_mapping(int vmid, char** addrp, size_t* sizep, TRAPS) {
DWORD mv_access = FILE_MAP_READ;
const char* luser = get_user_name(vmid);
if (luser == NULL) {
if (luser == nullptr) {
THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
"Could not map vmid to user name");
}
@ -1639,7 +1639,7 @@ static void open_file_mapping(int vmid, char** addrp, size_t* sizep, TRAPS) {
0, /* DWORD Low word of offset */
size); /* DWORD Number of bytes to map */
if (mapAddress == NULL) {
if (mapAddress == nullptr) {
if (PrintMiscellaneous && Verbose) {
warning("MapViewOfFile failed, lasterror = %d\n", GetLastError());
}
@ -1706,7 +1706,7 @@ void PerfMemory::create_memory_region(size_t size) {
}
else {
_start = create_shared_memory(size);
if (_start == NULL) {
if (_start == nullptr) {
// creation of the shared memory region failed, attempt
// to create a contiguous, non-shared memory region instead.
@ -1719,7 +1719,7 @@ void PerfMemory::create_memory_region(size_t size) {
}
}
if (_start != NULL) _capacity = size;
if (_start != nullptr) _capacity = size;
}
@ -1731,13 +1731,13 @@ void PerfMemory::create_memory_region(size_t size) {
//
void PerfMemory::delete_memory_region() {
assert((start() != NULL && capacity() > 0), "verify proper state");
assert((start() != nullptr && capacity() > 0), "verify proper state");
// If user specifies PerfDataSaveFile, it will save the performance data
// to the specified file name no matter whether PerfDataSaveToFile is specified
// or not. In other word, -XX:PerfDataSaveFile=.. overrides flag
// -XX:+PerfDataSaveToFile.
if (PerfDataSaveToFile || PerfDataSaveFile != NULL) {
if (PerfDataSaveToFile || PerfDataSaveFile != nullptr) {
save_memory_to_file(start(), capacity());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2018, 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,9 +30,9 @@
#include <errno.h>
WindowsSemaphore::WindowsSemaphore(uint value) {
_semaphore = ::CreateSemaphore(NULL, value, LONG_MAX, NULL);
_semaphore = ::CreateSemaphore(nullptr, value, LONG_MAX, nullptr);
guarantee(_semaphore != NULL, "CreateSemaphore failed with error code: %lu", GetLastError());
guarantee(_semaphore != nullptr, "CreateSemaphore failed with error code: %lu", GetLastError());
}
WindowsSemaphore::~WindowsSemaphore() {
@ -41,7 +41,7 @@ WindowsSemaphore::~WindowsSemaphore() {
void WindowsSemaphore::signal(uint count) {
if (count > 0) {
BOOL ret = ::ReleaseSemaphore(_semaphore, count, NULL);
BOOL ret = ::ReleaseSemaphore(_semaphore, count, nullptr);
assert(ret != 0, "ReleaseSemaphore failed with error code: %lu", GetLastError());
}

View File

@ -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
@ -91,7 +91,7 @@ class SimpleBufferWithFallback {
public:
SimpleBufferWithFallback<T, MINIMAL_CAPACITY, OPTIMAL_CAPACITY> ()
: _p(NULL), _capacity(0)
: _p(nullptr), _capacity(0)
{}
// Note: no destructor because these buffers should, once
@ -101,10 +101,10 @@ public:
// Note: We use raw ::malloc/::free here instead of os::malloc()/os::free
// to prevent circularities or secondary crashes during error reporting.
virtual void initialize () {
assert(_p == NULL && _capacity == 0, "Only call once.");
assert(_p == nullptr && _capacity == 0, "Only call once.");
const size_t bytes = OPTIMAL_CAPACITY * sizeof(T);
T* q = (T*) ::malloc(bytes);
if (q != NULL) {
if (q != nullptr) {
_p = q;
_capacity = OPTIMAL_CAPACITY;
} else {
@ -206,7 +206,7 @@ public:
// Search PDB path for a directory. Search is case insensitive. Returns
// true if directory was found in the path, false otherwise.
bool contains_directory(const char* directory) {
if (ptr() == NULL) {
if (ptr() == nullptr) {
return false;
}
const size_t len = strlen(directory);
@ -216,7 +216,7 @@ public:
char* p = ptr();
for(;;) {
char* q = strchr(p, ';');
if (q != NULL) {
if (q != nullptr) {
if (len == (q - p)) {
if (_strnicmp(p, directory, len) == 0) {
return true;
@ -309,7 +309,7 @@ static struct {
// For each loaded module, add the directory it is located in to the pdb search
// path, but avoid duplicates. Prior search path content is preserved.
//
// If p_search_path_was_updated is not NULL, points to a bool which, upon
// If p_search_path_was_updated is not null, points to a bool which, upon
// successful return from the function, contains true if the search path
// was updated, false if no update was needed because no new DLLs were
// loaded or unloaded.
@ -386,7 +386,7 @@ static bool recalc_search_path_locked(bool* p_search_path_was_updated) {
// Cut file name part off.
char* last_slash = ::strrchr(filebuffer, '\\');
if (last_slash == NULL) {
if (last_slash == nullptr) {
last_slash = ::strrchr(filebuffer, '/');
}
if (last_slash) {
@ -433,10 +433,10 @@ static bool decode_locked(const void* addr, char* buf, int buflen, int* offset,
assert(g_buffers.decode_buffer.capacity() >= (sizeof(IMAGEHLP_SYMBOL64) + MINIMUM_SYMBOL_NAME_LEN),
"Decode buffer too small.");
assert(buf != NULL && buflen > 0 && offset != NULL, "invalid output buffer.");
assert(buf != nullptr && buflen > 0 && offset != nullptr, "invalid output buffer.");
DWORD64 displacement;
PIMAGEHLP_SYMBOL64 pSymbol = NULL;
PIMAGEHLP_SYMBOL64 pSymbol = nullptr;
bool success = false;
pSymbol = (PIMAGEHLP_SYMBOL64) g_buffers.decode_buffer.ptr();
@ -492,7 +492,7 @@ static void initialize() {
HANDLE hProcess = ::GetCurrentProcess();
WindowsDbgHelp::symSetOptions(SYMOPT_FAIL_CRITICAL_ERRORS | SYMOPT_DEFERRED_LOADS |
SYMOPT_EXACT_SYMBOLS | SYMOPT_LOAD_LINES);
if (!WindowsDbgHelp::symInitialize(hProcess, NULL, TRUE)) {
if (!WindowsDbgHelp::symInitialize(hProcess, nullptr, TRUE)) {
return;
}
@ -500,7 +500,7 @@ static void initialize() {
// usable enough.
g_state = state_ready;
(void)recalc_search_path_locked(NULL);
(void)recalc_search_path_locked(nullptr);
}
@ -533,11 +533,11 @@ void SymbolEngine::pre_initialize() {
bool SymbolEngine::decode(const void* addr, char* buf, int buflen, int* offset, bool do_demangle) {
assert(buf != NULL && buflen > 0 && offset != NULL, "Argument error");
assert(buf != nullptr && buflen > 0 && offset != nullptr, "Argument error");
buf[0] = '\0';
*offset = -1;
if (addr == NULL) {
if (addr == nullptr) {
return false;
}
@ -579,11 +579,11 @@ bool SymbolEngine::recalc_search_path(bool* p_search_path_was_updated) {
bool SymbolEngine::get_source_info(const void* addr, char* buf, size_t buflen,
int* line_no)
{
assert(buf != NULL && buflen > 0 && line_no != NULL, "Argument error");
assert(buf != nullptr && buflen > 0 && line_no != nullptr, "Argument error");
buf[0] = '\0';
*line_no = -1;
if (addr == NULL) {
if (addr == nullptr) {
return false;
}
@ -595,7 +595,7 @@ bool SymbolEngine::get_source_info(const void* addr, char* buf, size_t buflen,
DWORD displacement;
if (WindowsDbgHelp::symGetLineFromAddr64(::GetCurrentProcess(), (DWORD64)addr,
&displacement, &lineinfo)) {
if (buf != NULL && buflen > 0 && lineinfo.FileName != NULL) {
if (buf != nullptr && buflen > 0 && lineinfo.FileName != nullptr) {
// We only return the file name, not the whole path.
char* p = lineinfo.FileName;
char* q = strrchr(lineinfo.FileName, '\\');

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017 SAP SE. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
@ -42,12 +42,12 @@ namespace SymbolEngine {
// to the current search path, unless they are already part of the search
// path. Prior search path content is preserved, directories are only
// added, never removed.
// If p_search_path_was_updated is not NULL, points to a bool which, upon
// If p_search_path_was_updated is not null, points to a bool which, upon
// successful return from the function, contains true if the search path
// was updated, false if no update was needed because no new DLLs were
// loaded or unloaded.
// Returns true for success, false for error.
bool recalc_search_path(bool* p_search_path_was_updated = NULL);
bool recalc_search_path(bool* p_search_path_was_updated = nullptr);
// Print one liner describing state (if library loaded, which functions are
// missing - if any, and the dbhelp API version)

View File

@ -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
@ -26,8 +26,8 @@
#include "runtime/thread.hpp"
#include "runtime/threadCrashProtection.hpp"
Thread* ThreadCrashProtection::_protected_thread = NULL;
ThreadCrashProtection* ThreadCrashProtection::_crash_protection = NULL;
Thread* ThreadCrashProtection::_protected_thread = nullptr;
ThreadCrashProtection* ThreadCrashProtection::_crash_protection = nullptr;
ThreadCrashProtection::ThreadCrashProtection() {
_protected_thread = Thread::current();
@ -49,7 +49,7 @@ bool ThreadCrashProtection::call(CrashProtectionCallback& cb) {
// only for protection, nothing to do
success = false;
}
_crash_protection = NULL;
_protected_thread = NULL;
_crash_protection = nullptr;
_protected_thread = nullptr;
return success;
}

View File

@ -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
@ -41,7 +41,7 @@ class Thread;
class ThreadCrashProtection : public StackObj {
public:
static bool is_crash_protected(Thread* thr) {
return _crash_protection != NULL && _protected_thread == thr;
return _crash_protection != nullptr && _protected_thread == thr;
}
ThreadCrashProtection();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 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
@ -52,13 +52,13 @@ static DWORD lock_owner = 0;
//
static BOOL WINAPI initialize(PINIT_ONCE InitOnce, PVOID Parameter, PVOID *Context) {
lock_event = CreateEvent(NULL, false, true, NULL);
assert(lock_event != NULL, "unexpected return value from CreateEvent");
lock_event = CreateEvent(nullptr, false, true, nullptr);
assert(lock_event != nullptr, "unexpected return value from CreateEvent");
return true;
}
ThreadCritical::ThreadCritical() {
InitOnceExecuteOnce(&initialized, &initialize, NULL, NULL);
InitOnceExecuteOnce(&initialized, &initialize, nullptr, nullptr);
DWORD current_thread = GetCurrentThreadId();
if (lock_owner != current_thread) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -31,7 +31,7 @@
LONG WINAPI crash_handler(struct _EXCEPTION_POINTERS* exceptionInfo) {
DWORD exception_code = exceptionInfo->ExceptionRecord->ExceptionCode;
VMError::report_and_die(NULL, exception_code, NULL, exceptionInfo->ExceptionRecord,
VMError::report_and_die(nullptr, exception_code, nullptr, exceptionInfo->ExceptionRecord,
exceptionInfo->ContextRecord);
return EXCEPTION_CONTINUE_SEARCH;
}
@ -49,7 +49,7 @@ void VMError::check_failing_cds_access(outputStream* st, const void* siginfo) {
if (er->ExceptionCode == EXCEPTION_IN_PAGE_ERROR &&
er->NumberParameters >= 2) {
const void* const fault_addr = (const void*) er->ExceptionInformation[1];
if (fault_addr != NULL) {
if (fault_addr != nullptr) {
if (MetaspaceShared::is_in_shared_metaspace(fault_addr)) {
st->print("Error accessing class data sharing archive. "
"Mapped file inaccessible during execution, possible disk/network problem.");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 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
@ -77,7 +77,7 @@ static pfn_##functionname g_pfn_##functionname;
FOR_ALL_FUNCTIONS(DECLARE_FUNCTION_POINTER)
static HMODULE g_dll_handle = NULL;
static HMODULE g_dll_handle = nullptr;
static DWORD g_dll_load_error = 0;
static API_VERSION g_version = { 0, 0, 0, 0 };
@ -93,7 +93,7 @@ static void initialize() {
g_state = state_error;
g_dll_handle = ::LoadLibrary("DBGHELP.DLL");
if (g_dll_handle == NULL) {
if (g_dll_handle == nullptr) {
g_dll_load_error = ::GetLastError();
} else {
// Note: We loaded the DLL successfully. From here on we count
@ -146,7 +146,7 @@ void WindowsDbgHelp::pre_initialize() {
DWORD WindowsDbgHelp::symSetOptions(DWORD arg) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_SymSetOptions != NULL) {
if (g_pfn_SymSetOptions != nullptr) {
return g_pfn_SymSetOptions(arg);
}
return 0;
@ -154,7 +154,7 @@ DWORD WindowsDbgHelp::symSetOptions(DWORD arg) {
DWORD WindowsDbgHelp::symGetOptions(void) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_SymGetOptions != NULL) {
if (g_pfn_SymGetOptions != nullptr) {
return g_pfn_SymGetOptions();
}
return 0;
@ -162,7 +162,7 @@ DWORD WindowsDbgHelp::symGetOptions(void) {
BOOL WindowsDbgHelp::symInitialize(HANDLE hProcess, PCTSTR UserSearchPath, BOOL fInvadeProcess) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_SymInitialize != NULL) {
if (g_pfn_SymInitialize != nullptr) {
return g_pfn_SymInitialize(hProcess, UserSearchPath, fInvadeProcess);
}
return FALSE;
@ -171,7 +171,7 @@ BOOL WindowsDbgHelp::symInitialize(HANDLE hProcess, PCTSTR UserSearchPath, BOOL
BOOL WindowsDbgHelp::symGetSymFromAddr64(HANDLE hProcess, DWORD64 the_address,
PDWORD64 Displacement, PIMAGEHLP_SYMBOL64 Symbol) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_SymGetSymFromAddr64 != NULL) {
if (g_pfn_SymGetSymFromAddr64 != nullptr) {
return g_pfn_SymGetSymFromAddr64(hProcess, the_address, Displacement, Symbol);
}
return FALSE;
@ -180,10 +180,10 @@ BOOL WindowsDbgHelp::symGetSymFromAddr64(HANDLE hProcess, DWORD64 the_address,
DWORD WindowsDbgHelp::unDecorateSymbolName(const char* DecoratedName, char* UnDecoratedName,
DWORD UndecoratedLength, DWORD Flags) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_UnDecorateSymbolName != NULL) {
if (g_pfn_UnDecorateSymbolName != nullptr) {
return g_pfn_UnDecorateSymbolName(DecoratedName, UnDecoratedName, UndecoratedLength, Flags);
}
if (UnDecoratedName != NULL && UndecoratedLength > 0) {
if (UnDecoratedName != nullptr && UndecoratedLength > 0) {
UnDecoratedName[0] = '\0';
}
return 0;
@ -191,7 +191,7 @@ DWORD WindowsDbgHelp::unDecorateSymbolName(const char* DecoratedName, char* UnDe
BOOL WindowsDbgHelp::symSetSearchPath(HANDLE hProcess, PCTSTR SearchPath) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_SymSetSearchPath != NULL) {
if (g_pfn_SymSetSearchPath != nullptr) {
return g_pfn_SymSetSearchPath(hProcess, SearchPath);
}
return FALSE;
@ -199,7 +199,7 @@ BOOL WindowsDbgHelp::symSetSearchPath(HANDLE hProcess, PCTSTR SearchPath) {
BOOL WindowsDbgHelp::symGetSearchPath(HANDLE hProcess, PTSTR SearchPath, int SearchPathLength) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_SymGetSearchPath != NULL) {
if (g_pfn_SymGetSearchPath != nullptr) {
return g_pfn_SymGetSearchPath(hProcess, SearchPath, SearchPathLength);
}
return FALSE;
@ -211,13 +211,13 @@ BOOL WindowsDbgHelp::stackWalk64(DWORD MachineType,
LPSTACKFRAME64 StackFrame,
PVOID ContextRecord) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_StackWalk64 != NULL) {
if (g_pfn_StackWalk64 != nullptr) {
return g_pfn_StackWalk64(MachineType, hProcess, hThread, StackFrame,
ContextRecord,
NULL, // ReadMemoryRoutine
nullptr, // ReadMemoryRoutine
g_pfn_SymFunctionTableAccess64, // FunctionTableAccessRoutine,
g_pfn_SymGetModuleBase64, // GetModuleBaseRoutine
NULL // TranslateAddressRoutine
nullptr // TranslateAddressRoutine
);
}
return FALSE;
@ -225,15 +225,15 @@ BOOL WindowsDbgHelp::stackWalk64(DWORD MachineType,
PVOID WindowsDbgHelp::symFunctionTableAccess64(HANDLE hProcess, DWORD64 AddrBase) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_SymFunctionTableAccess64 != NULL) {
if (g_pfn_SymFunctionTableAccess64 != nullptr) {
return g_pfn_SymFunctionTableAccess64(hProcess, AddrBase);
}
return NULL;
return nullptr;
}
DWORD64 WindowsDbgHelp::symGetModuleBase64(HANDLE hProcess, DWORD64 dwAddr) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_SymGetModuleBase64 != NULL) {
if (g_pfn_SymGetModuleBase64 != nullptr) {
return g_pfn_SymGetModuleBase64(hProcess, dwAddr);
}
return 0;
@ -244,7 +244,7 @@ BOOL WindowsDbgHelp::miniDumpWriteDump(HANDLE hProcess, DWORD ProcessId, HANDLE
PMINIDUMP_USER_STREAM_INFORMATION UserStreamParam,
PMINIDUMP_CALLBACK_INFORMATION CallbackParam) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_MiniDumpWriteDump != NULL) {
if (g_pfn_MiniDumpWriteDump != nullptr) {
return g_pfn_MiniDumpWriteDump(hProcess, ProcessId, hFile, DumpType,
ExceptionParam, UserStreamParam, CallbackParam);
}
@ -254,7 +254,7 @@ BOOL WindowsDbgHelp::miniDumpWriteDump(HANDLE hProcess, DWORD ProcessId, HANDLE
BOOL WindowsDbgHelp::symGetLineFromAddr64(HANDLE hProcess, DWORD64 dwAddr,
PDWORD pdwDisplacement, PIMAGEHLP_LINE64 Line) {
WindowsDbgHelpEntry entry_guard;
if (g_pfn_SymGetLineFromAddr64 != NULL) {
if (g_pfn_SymGetLineFromAddr64 != nullptr) {
return g_pfn_SymGetLineFromAddr64(hProcess, dwAddr, pdwDisplacement, Line);
}
return FALSE;
@ -288,7 +288,7 @@ void WindowsDbgHelp::print_state_on(outputStream* st) {
st->print(" - missing functions: ");
#define CHECK_AND_PRINT_IF_NULL(functionname) \
if (g_pfn_##functionname == NULL) { \
if (g_pfn_##functionname == nullptr) { \
st->print("%s" #functionname, ((num_missing > 0) ? ", " : "")); \
num_missing ++; \
}