Commit d4498c2a authored by Bill Budge's avatar Bill Budge

[platform] Change NULL to nullptr in platform-win32.cc.

Bug: v8:6928
Change-Id: Ie414566a8286e0ccb54447828aea660e13bafb94
Reviewed-on: https://chromium-review.googlesource.com/783632Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarMichael Lippautz <mlippautz@chromium.org>
Cr-Commit-Position: refs/heads/master@{#49587}
parent d59bf4dc
...@@ -47,14 +47,14 @@ inline void MemoryFence() { ...@@ -47,14 +47,14 @@ inline void MemoryFence() {
int localtime_s(tm* out_tm, const time_t* time) { int localtime_s(tm* out_tm, const time_t* time) {
tm* posix_local_time_struct = localtime_r(time, out_tm); tm* posix_local_time_struct = localtime_r(time, out_tm);
if (posix_local_time_struct == NULL) return 1; if (posix_local_time_struct == nullptr) return 1;
return 0; return 0;
} }
int fopen_s(FILE** pFile, const char* filename, const char* mode) { int fopen_s(FILE** pFile, const char* filename, const char* mode) {
*pFile = fopen(filename, mode); *pFile = fopen(filename, mode);
return *pFile != NULL ? 0 : 1; return *pFile != nullptr ? 0 : 1;
} }
int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count, int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count,
...@@ -65,8 +65,8 @@ int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count, ...@@ -65,8 +65,8 @@ int _vsnprintf_s(char* buffer, size_t sizeOfBuffer, size_t count,
int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) { int strncpy_s(char* dest, size_t dest_size, const char* source, size_t count) {
CHECK(source != NULL); CHECK(source != nullptr);
CHECK(dest != NULL); CHECK(dest != nullptr);
CHECK_GT(dest_size, 0); CHECK_GT(dest_size, 0);
if (count == _TRUNCATE) { if (count == _TRUNCATE) {
...@@ -139,11 +139,11 @@ class WindowsTimezoneCache : public TimezoneCache { ...@@ -139,11 +139,11 @@ class WindowsTimezoneCache : public TimezoneCache {
} }
// Make standard and DST timezone names. // Make standard and DST timezone names.
WideCharToMultiByte(CP_UTF8, 0, tzinfo_.StandardName, -1, WideCharToMultiByte(CP_UTF8, 0, tzinfo_.StandardName, -1, std_tz_name_,
std_tz_name_, kTzNameSize, NULL, NULL); kTzNameSize, nullptr, nullptr);
std_tz_name_[kTzNameSize - 1] = '\0'; std_tz_name_[kTzNameSize - 1] = '\0';
WideCharToMultiByte(CP_UTF8, 0, tzinfo_.DaylightName, -1, WideCharToMultiByte(CP_UTF8, 0, tzinfo_.DaylightName, -1, dst_tz_name_,
dst_tz_name_, kTzNameSize, NULL, NULL); kTzNameSize, nullptr, nullptr);
dst_tz_name_[kTzNameSize - 1] = '\0'; dst_tz_name_[kTzNameSize - 1] = '\0';
// If OS returned empty string or resource id (like "@tzres.dll,-211") // If OS returned empty string or resource id (like "@tzres.dll,-211")
...@@ -553,7 +553,7 @@ FILE* OS::FOpen(const char* path, const char* mode) { ...@@ -553,7 +553,7 @@ FILE* OS::FOpen(const char* path, const char* mode) {
if (fopen_s(&result, path, mode) == 0) { if (fopen_s(&result, path, mode) == 0) {
return result; return result;
} else { } else {
return NULL; return nullptr;
} }
} }
...@@ -574,13 +574,13 @@ FILE* OS::OpenTemporaryFile() { ...@@ -574,13 +574,13 @@ FILE* OS::OpenTemporaryFile() {
char tempPathBuffer[MAX_PATH]; char tempPathBuffer[MAX_PATH];
DWORD path_result = 0; DWORD path_result = 0;
path_result = GetTempPathA(MAX_PATH, tempPathBuffer); path_result = GetTempPathA(MAX_PATH, tempPathBuffer);
if (path_result > MAX_PATH || path_result == 0) return NULL; if (path_result > MAX_PATH || path_result == 0) return nullptr;
UINT name_result = 0; UINT name_result = 0;
char tempNameBuffer[MAX_PATH]; char tempNameBuffer[MAX_PATH];
name_result = GetTempFileNameA(tempPathBuffer, "", 0, tempNameBuffer); name_result = GetTempFileNameA(tempPathBuffer, "", 0, tempNameBuffer);
if (name_result == 0) return NULL; if (name_result == 0) return nullptr;
FILE* result = FOpen(tempNameBuffer, "w+"); // Same mode as tmpfile uses. FILE* result = FOpen(tempNameBuffer, "w+"); // Same mode as tmpfile uses.
if (result != NULL) { if (result != nullptr) {
Remove(tempNameBuffer); // Delete on close. Remove(tempNameBuffer); // Delete on close.
} }
return result; return result;
...@@ -748,7 +748,7 @@ DWORD GetProtectionFromMemoryPermission(OS::MemoryPermission access) { ...@@ -748,7 +748,7 @@ DWORD GetProtectionFromMemoryPermission(OS::MemoryPermission access) {
uint8_t* RandomizedVirtualAlloc(size_t size, DWORD flags, DWORD protect, uint8_t* RandomizedVirtualAlloc(size_t size, DWORD flags, DWORD protect,
void* hint) { void* hint) {
LPVOID base = NULL; LPVOID base = nullptr;
static BOOL use_aslr = -1; static BOOL use_aslr = -1;
#ifdef V8_HOST_ARCH_32_BIT #ifdef V8_HOST_ARCH_32_BIT
// Don't bother randomizing on 32-bit hosts, because they lack the room and // Don't bother randomizing on 32-bit hosts, because they lack the room and
...@@ -900,15 +900,16 @@ class Win32MemoryMappedFile final : public OS::MemoryMappedFile { ...@@ -900,15 +900,16 @@ class Win32MemoryMappedFile final : public OS::MemoryMappedFile {
OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) { OS::MemoryMappedFile* OS::MemoryMappedFile::open(const char* name) {
// Open a physical file // Open a physical file
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
if (file == INVALID_HANDLE_VALUE) return NULL; OPEN_EXISTING, 0, nullptr);
if (file == INVALID_HANDLE_VALUE) return nullptr;
DWORD size = GetFileSize(file, NULL); DWORD size = GetFileSize(file, nullptr);
// Create a file mapping for the physical file // Create a file mapping for the physical file
HANDLE file_mapping = HANDLE file_mapping =
CreateFileMapping(file, NULL, PAGE_READWRITE, 0, size, NULL); CreateFileMapping(file, nullptr, PAGE_READWRITE, 0, size, nullptr);
if (file_mapping == NULL) return NULL; if (file_mapping == nullptr) return nullptr;
// Map a view of the file into memory // Map a view of the file into memory
void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size); void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
...@@ -921,13 +922,13 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name, ...@@ -921,13 +922,13 @@ OS::MemoryMappedFile* OS::MemoryMappedFile::create(const char* name,
size_t size, void* initial) { size_t size, void* initial) {
// Open a physical file // Open a physical file
HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE, HANDLE file = CreateFileA(name, GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr,
OPEN_ALWAYS, 0, NULL); OPEN_ALWAYS, 0, nullptr);
if (file == NULL) return NULL; if (file == nullptr) return nullptr;
// Create a file mapping for the physical file // Create a file mapping for the physical file
HANDLE file_mapping = CreateFileMapping(file, NULL, PAGE_READWRITE, 0, HANDLE file_mapping = CreateFileMapping(file, nullptr, PAGE_READWRITE, 0,
static_cast<DWORD>(size), NULL); static_cast<DWORD>(size), nullptr);
if (file_mapping == NULL) return NULL; if (file_mapping == nullptr) return nullptr;
// Map a view of the file into memory // Map a view of the file into memory
void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size); void* memory = MapViewOfFile(file_mapping, FILE_MAP_ALL_ACCESS, 0, 0, size);
if (memory) memmove(memory, initial, size); if (memory) memmove(memory, initial, size);
...@@ -1043,7 +1044,7 @@ typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32NextW))(HANDLE hSnapshot, ...@@ -1043,7 +1044,7 @@ typedef BOOL (__stdcall *DLL_FUNC_TYPE(Module32NextW))(HANDLE hSnapshot,
#undef VOID #undef VOID
// Declare a variable for each dynamically loaded DLL function. // Declare a variable for each dynamically loaded DLL function.
#define DEF_DLL_FUNCTION(name) DLL_FUNC_TYPE(name) DLL_FUNC_VAR(name) = NULL; #define DEF_DLL_FUNCTION(name) DLL_FUNC_TYPE(name) DLL_FUNC_VAR(name) = nullptr;
DBGHELP_FUNCTION_LIST(DEF_DLL_FUNCTION) DBGHELP_FUNCTION_LIST(DEF_DLL_FUNCTION)
TLHELP32_FUNCTION_LIST(DEF_DLL_FUNCTION) TLHELP32_FUNCTION_LIST(DEF_DLL_FUNCTION)
#undef DEF_DLL_FUNCTION #undef DEF_DLL_FUNCTION
...@@ -1060,7 +1061,7 @@ static bool LoadDbgHelpAndTlHelp32() { ...@@ -1060,7 +1061,7 @@ static bool LoadDbgHelpAndTlHelp32() {
// Load functions from the dbghelp.dll module. // Load functions from the dbghelp.dll module.
module = LoadLibrary(TEXT("dbghelp.dll")); module = LoadLibrary(TEXT("dbghelp.dll"));
if (module == NULL) { if (module == nullptr) {
return false; return false;
} }
...@@ -1075,7 +1076,7 @@ DBGHELP_FUNCTION_LIST(LOAD_DLL_FUNC) ...@@ -1075,7 +1076,7 @@ DBGHELP_FUNCTION_LIST(LOAD_DLL_FUNC)
// Load functions from the kernel32.dll module (the TlHelp32.h function used // Load functions from the kernel32.dll module (the TlHelp32.h function used
// to be in tlhelp32.dll but are now moved to kernel32.dll). // to be in tlhelp32.dll but are now moved to kernel32.dll).
module = LoadLibrary(TEXT("kernel32.dll")); module = LoadLibrary(TEXT("kernel32.dll"));
if (module == NULL) { if (module == nullptr) {
return false; return false;
} }
...@@ -1088,14 +1089,14 @@ TLHELP32_FUNCTION_LIST(LOAD_DLL_FUNC) ...@@ -1088,14 +1089,14 @@ TLHELP32_FUNCTION_LIST(LOAD_DLL_FUNC)
#undef LOAD_DLL_FUNC #undef LOAD_DLL_FUNC
// Check that all functions where loaded. // Check that all functions where loaded.
bool result = bool result =
#define DLL_FUNC_LOADED(name) (DLL_FUNC_VAR(name) != NULL) && #define DLL_FUNC_LOADED(name) (DLL_FUNC_VAR(name) != nullptr)&&
DBGHELP_FUNCTION_LIST(DLL_FUNC_LOADED) DBGHELP_FUNCTION_LIST(DLL_FUNC_LOADED)
TLHELP32_FUNCTION_LIST(DLL_FUNC_LOADED) TLHELP32_FUNCTION_LIST(DLL_FUNC_LOADED)
#undef DLL_FUNC_LOADED #undef DLL_FUNC_LOADED
true; true;
dbghelp_loaded = result; dbghelp_loaded = result;
return result; return result;
...@@ -1122,7 +1123,7 @@ static std::vector<OS::SharedLibraryAddress> LoadSymbols( ...@@ -1122,7 +1123,7 @@ static std::vector<OS::SharedLibraryAddress> LoadSymbols(
// Initialize the symbol engine. // Initialize the symbol engine.
ok = _SymInitialize(process_handle, // hProcess ok = _SymInitialize(process_handle, // hProcess
NULL, // UserSearchPath nullptr, // UserSearchPath
false); // fInvadeProcess false); // fInvadeProcess
if (!ok) return result; if (!ok) return result;
...@@ -1166,10 +1167,10 @@ static std::vector<OS::SharedLibraryAddress> LoadSymbols( ...@@ -1166,10 +1167,10 @@ static std::vector<OS::SharedLibraryAddress> LoadSymbols(
} }
} }
int lib_name_length = WideCharToMultiByte( int lib_name_length = WideCharToMultiByte(
CP_UTF8, 0, module_entry.szExePath, -1, NULL, 0, NULL, NULL); CP_UTF8, 0, module_entry.szExePath, -1, nullptr, 0, nullptr, nullptr);
std::string lib_name(lib_name_length, 0); std::string lib_name(lib_name_length, 0);
WideCharToMultiByte(CP_UTF8, 0, module_entry.szExePath, -1, &lib_name[0], WideCharToMultiByte(CP_UTF8, 0, module_entry.szExePath, -1, &lib_name[0],
lib_name_length, NULL, NULL); lib_name_length, nullptr, nullptr);
result.push_back(OS::SharedLibraryAddress( result.push_back(OS::SharedLibraryAddress(
lib_name, reinterpret_cast<uintptr_t>(module_entry.modBaseAddr), lib_name, reinterpret_cast<uintptr_t>(module_entry.modBaseAddr),
reinterpret_cast<uintptr_t>(module_entry.modBaseAddr + reinterpret_cast<uintptr_t>(module_entry.modBaseAddr +
...@@ -1245,8 +1246,7 @@ class Thread::PlatformData { ...@@ -1245,8 +1246,7 @@ class Thread::PlatformData {
// handle until it is started. // handle until it is started.
Thread::Thread(const Options& options) Thread::Thread(const Options& options)
: stack_size_(options.stack_size()), : stack_size_(options.stack_size()), start_semaphore_(nullptr) {
start_semaphore_(NULL) {
data_ = new PlatformData(kNoThread); data_ = new PlatformData(kNoThread);
set_name(options.name()); set_name(options.name());
} }
...@@ -1270,12 +1270,8 @@ Thread::~Thread() { ...@@ -1270,12 +1270,8 @@ Thread::~Thread() {
// initialize thread specific structures in the C runtime library. // initialize thread specific structures in the C runtime library.
void Thread::Start() { void Thread::Start() {
data_->thread_ = reinterpret_cast<HANDLE>( data_->thread_ = reinterpret_cast<HANDLE>(
_beginthreadex(NULL, _beginthreadex(nullptr, static_cast<unsigned>(stack_size_), ThreadEntry,
static_cast<unsigned>(stack_size_), this, 0, &data_->thread_id_));
ThreadEntry,
this,
0,
&data_->thread_id_));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment