mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:53:55 +00:00
[build] Support --clang when building dart sdk on Windows.
It relies on flutter copy of clang distribution, same one that is used to build flutter/engine. It addressed several deprecated warnings from clang compiler for functions like strdup, unlink, etc. It allows few warnings still since they are triggered in third_party sources. Change-Id: Ieb13792c011438d46dbbc0fa030e1b5e4ea14315 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142704 Commit-Queue: Alexander Aprelev <aam@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com>
This commit is contained in:
parent
8eb0b79ac1
commit
d33e51df3c
10
DEPS
10
DEPS
|
@ -190,6 +190,16 @@ deps = {
|
||||||
Var("chromium_git") + "/chromium/llvm-project/cfe/tools/clang-format.git" +
|
Var("chromium_git") + "/chromium/llvm-project/cfe/tools/clang-format.git" +
|
||||||
"@" + Var("clang_format_scripts_rev"),
|
"@" + Var("clang_format_scripts_rev"),
|
||||||
|
|
||||||
|
Var("dart_root") + "/third_party/llvm-build/Release+Asserts": {
|
||||||
|
"packages": [
|
||||||
|
{
|
||||||
|
"package": "flutter/clang/win-amd64",
|
||||||
|
"version": "git_revision:5ec206df8534d2dd8cb9217c3180e5ddba587393"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"condition": "download_windows_deps",
|
||||||
|
"dep_type": "cipd",
|
||||||
|
},
|
||||||
Var("dart_root") + "/benchmarks-internal": {
|
Var("dart_root") + "/benchmarks-internal": {
|
||||||
"url": Var("dart_internal_git") + "/benchmarks-internal.git" +
|
"url": Var("dart_internal_git") + "/benchmarks-internal.git" +
|
||||||
"@" + Var("benchmarks_internal_rev"),
|
"@" + Var("benchmarks_internal_rev"),
|
||||||
|
|
|
@ -364,7 +364,11 @@ set_defaults("component") {
|
||||||
|
|
||||||
if (is_win) {
|
if (is_win) {
|
||||||
# On windows we use the same toolchain for host and target by default.
|
# On windows we use the same toolchain for host and target by default.
|
||||||
|
if (is_clang) {
|
||||||
|
host_toolchain = "//build/toolchain/win:clang_$current_cpu"
|
||||||
|
} else {
|
||||||
host_toolchain = "//build/toolchain/win:$current_cpu"
|
host_toolchain = "//build/toolchain/win:$current_cpu"
|
||||||
|
}
|
||||||
set_default_toolchain("$host_toolchain")
|
set_default_toolchain("$host_toolchain")
|
||||||
} else if (is_android) {
|
} else if (is_android) {
|
||||||
if (host_os == "linux") {
|
if (host_os == "linux") {
|
||||||
|
|
|
@ -514,6 +514,18 @@ if (is_win) {
|
||||||
default_warning_flags += [ "/WX" ] # Treat warnings as errors.
|
default_warning_flags += [ "/WX" ] # Treat warnings as errors.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_clang) {
|
||||||
|
default_warning_flags += [
|
||||||
|
"-Wno-deprecated-declarations", # crashpad
|
||||||
|
"-Wno-ignored-pragma-optimize", # icu, double-conversion
|
||||||
|
"-Wno-implicit-int-float-conversion", # icu
|
||||||
|
"-Wno-macro-redefined",
|
||||||
|
"-Wno-microsoft-cast",
|
||||||
|
"-Wno-microsoft-unqualified-friend",
|
||||||
|
"-Wno-unknown-argument", # icu
|
||||||
|
"-Wno-unused-value", # crashpad
|
||||||
|
]
|
||||||
|
} else {
|
||||||
default_warning_flags += [
|
default_warning_flags += [
|
||||||
# Permanent.
|
# Permanent.
|
||||||
"/wd4091", # typedef warning from dbghelp.h
|
"/wd4091", # typedef warning from dbghelp.h
|
||||||
|
@ -527,6 +539,7 @@ if (is_win) {
|
||||||
"/wd4311", # Pointer truncation from PVOID to DWORD.
|
"/wd4311", # Pointer truncation from PVOID to DWORD.
|
||||||
"/wd4477", # Format string requires wchar_t*
|
"/wd4477", # Format string requires wchar_t*
|
||||||
]
|
]
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
# Common GCC warning setup.
|
# Common GCC warning setup.
|
||||||
default_warning_flags += [
|
default_warning_flags += [
|
||||||
|
|
|
@ -72,7 +72,11 @@ template("msvc_toolchain") {
|
||||||
# TODO(brettw) enable this when GN support in the binary has been rolled.
|
# TODO(brettw) enable this when GN support in the binary has been rolled.
|
||||||
#precompiled_header_type = "msvc"
|
#precompiled_header_type = "msvc"
|
||||||
pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb"
|
pdbname = "{{target_out_dir}}/{{target_output_name}}_c.pdb"
|
||||||
command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
|
flags = ""
|
||||||
|
if (invoker.current_cpu == "x86") {
|
||||||
|
flags = "-m32"
|
||||||
|
}
|
||||||
|
command = "ninja -t msvc -e $env -- $cl $flags /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
|
||||||
depsformat = "msvc"
|
depsformat = "msvc"
|
||||||
description = "CC {{output}}"
|
description = "CC {{output}}"
|
||||||
outputs = [
|
outputs = [
|
||||||
|
@ -89,7 +93,11 @@ template("msvc_toolchain") {
|
||||||
|
|
||||||
# The PDB name needs to be different between C and C++ compiled files.
|
# The PDB name needs to be different between C and C++ compiled files.
|
||||||
pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb"
|
pdbname = "{{target_out_dir}}/{{target_output_name}}_cc.pdb"
|
||||||
command = "ninja -t msvc -e $env -- $cl /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
|
flags = ""
|
||||||
|
if (invoker.current_cpu == "x86") {
|
||||||
|
flags = "-m32"
|
||||||
|
}
|
||||||
|
command = "ninja -t msvc -e $env -- $cl $flags /nologo /showIncludes /FC @$rspfile /c {{source}} /Fo{{output}} /Fd$pdbname"
|
||||||
depsformat = "msvc"
|
depsformat = "msvc"
|
||||||
description = "CXX {{output}}"
|
description = "CXX {{output}}"
|
||||||
outputs = [
|
outputs = [
|
||||||
|
|
|
@ -71,7 +71,7 @@ Dart_Isolate CreateKernelServiceIsolate(const IsolateCreationData& data,
|
||||||
Dart_EnterScope();
|
Dart_EnterScope();
|
||||||
Dart_Handle result = Dart_LoadScriptFromKernel(buffer, buffer_size);
|
Dart_Handle result = Dart_LoadScriptFromKernel(buffer, buffer_size);
|
||||||
if (Dart_IsError(result)) {
|
if (Dart_IsError(result)) {
|
||||||
*error = strdup(Dart_GetError(result));
|
*error = Utils::StrDup(Dart_GetError(result));
|
||||||
Dart_ExitScope();
|
Dart_ExitScope();
|
||||||
Dart_ShutdownIsolate();
|
Dart_ShutdownIsolate();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -89,7 +89,7 @@ Dart_Isolate CreateVmServiceIsolate(const IsolateCreationData& data,
|
||||||
const uint8_t* isolate_instr,
|
const uint8_t* isolate_instr,
|
||||||
char** error) {
|
char** error) {
|
||||||
if (data.flags == nullptr) {
|
if (data.flags == nullptr) {
|
||||||
*error = strdup("Expected non-null flags");
|
*error = Utils::StrDup("Expected non-null flags");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
data.flags->load_vmservice_library = true;
|
data.flags->load_vmservice_library = true;
|
||||||
|
@ -108,7 +108,7 @@ Dart_Isolate CreateVmServiceIsolate(const IsolateCreationData& data,
|
||||||
config.write_service_info_filename,
|
config.write_service_info_filename,
|
||||||
/*trace_loading=*/false, config.deterministic,
|
/*trace_loading=*/false, config.deterministic,
|
||||||
/*enable_service_port_fallback=*/false)) {
|
/*enable_service_port_fallback=*/false)) {
|
||||||
*error = strdup(bin::VmService::GetErrorMessage());
|
*error = Utils::StrDup(bin::VmService::GetErrorMessage());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ Dart_Isolate CreateVmServiceIsolateFromKernel(
|
||||||
intptr_t kernel_buffer_size,
|
intptr_t kernel_buffer_size,
|
||||||
char** error) {
|
char** error) {
|
||||||
if (data.flags == nullptr) {
|
if (data.flags == nullptr) {
|
||||||
*error = strdup("Expected non-null flags");
|
*error = Utils::StrDup("Expected non-null flags");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
data.flags->load_vmservice_library = true;
|
data.flags->load_vmservice_library = true;
|
||||||
|
@ -143,7 +143,7 @@ Dart_Isolate CreateVmServiceIsolateFromKernel(
|
||||||
config.write_service_info_filename,
|
config.write_service_info_filename,
|
||||||
/*trace_loading=*/false, config.deterministic,
|
/*trace_loading=*/false, config.deterministic,
|
||||||
/*enable_service_port_fallback=*/false)) {
|
/*enable_service_port_fallback=*/false)) {
|
||||||
*error = strdup(bin::VmService::GetErrorMessage());
|
*error = Utils::StrDup(bin::VmService::GetErrorMessage());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -242,7 +242,7 @@ const char* DartUtils::RemoveScheme(const char* url) {
|
||||||
char* DartUtils::DirName(const char* url) {
|
char* DartUtils::DirName(const char* url) {
|
||||||
const char* slash = strrchr(url, File::PathSeparator()[0]);
|
const char* slash = strrchr(url, File::PathSeparator()[0]);
|
||||||
if (slash == NULL) {
|
if (slash == NULL) {
|
||||||
return strdup(url);
|
return Utils::StrDup(url);
|
||||||
} else {
|
} else {
|
||||||
return Utils::StrNDup(url, slash - url + 1);
|
return Utils::StrNDup(url, slash - url + 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -439,7 +439,7 @@ static bool TryReadKernelListBuffer(const char* script_uri,
|
||||||
|
|
||||||
StringPointer resolved_filename(
|
StringPointer resolved_filename(
|
||||||
File::IsAbsolutePath(filename)
|
File::IsAbsolutePath(filename)
|
||||||
? strdup(filename)
|
? Utils::StrDup(filename)
|
||||||
: Utils::SCreate("%s%s", kernel_list_dirname, filename));
|
: Utils::SCreate("%s%s", kernel_list_dirname, filename));
|
||||||
if (!TryReadFile(resolved_filename.c_str(), &this_buffer,
|
if (!TryReadFile(resolved_filename.c_str(), &this_buffer,
|
||||||
&this_kernel_size)) {
|
&this_kernel_size)) {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "include/dart_native_api.h"
|
#include "include/dart_native_api.h"
|
||||||
#include "platform/assert.h"
|
#include "platform/assert.h"
|
||||||
#include "platform/globals.h"
|
#include "platform/globals.h"
|
||||||
|
#include "platform/utils.h"
|
||||||
|
|
||||||
namespace dart {
|
namespace dart {
|
||||||
namespace bin {
|
namespace bin {
|
||||||
|
@ -31,7 +32,7 @@ class DFE {
|
||||||
if (frontend_filename_ != nullptr) {
|
if (frontend_filename_ != nullptr) {
|
||||||
free(frontend_filename_);
|
free(frontend_filename_);
|
||||||
}
|
}
|
||||||
frontend_filename_ = strdup(name);
|
frontend_filename_ = Utils::StrDup(name);
|
||||||
set_use_dfe();
|
set_use_dfe();
|
||||||
}
|
}
|
||||||
void set_use_dfe(bool value = true) { use_dfe_ = value; }
|
void set_use_dfe(bool value = true) { use_dfe_ = value; }
|
||||||
|
|
|
@ -260,7 +260,7 @@ void Directory::SetSystemTemp(const char* path) {
|
||||||
system_temp_path_override_ = NULL;
|
system_temp_path_override_ = NULL;
|
||||||
}
|
}
|
||||||
if (path != NULL) {
|
if (path != NULL) {
|
||||||
system_temp_path_override_ = strdup(path);
|
system_temp_path_override_ = Utils::StrDup(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ Utils::CStringUniquePtr EXEUtils::GetDirectoryPrefixFromExeName() {
|
||||||
name = File::LinkTarget(namespc, GetFileNameFromPath(name), target,
|
name = File::LinkTarget(namespc, GetFileNameFromPath(name), target,
|
||||||
kTargetSize);
|
kTargetSize);
|
||||||
if (name == nullptr) {
|
if (name == nullptr) {
|
||||||
return Utils::CreateCStringUniquePtr(strdup(""));
|
return Utils::CreateCStringUniquePtr(Utils::StrDup(""));
|
||||||
}
|
}
|
||||||
} while (File::GetType(namespc, name, false) == File::kIsLink);
|
} while (File::GetType(namespc, name, false) == File::kIsLink);
|
||||||
target_size = strlen(name);
|
target_size = strlen(name);
|
||||||
|
@ -117,7 +117,8 @@ Utils::CStringUniquePtr EXEUtils::GetDirectoryPrefixFromExeName() {
|
||||||
result = GetDirectoryFromPath(target, nullptr);
|
result = GetDirectoryFromPath(target, nullptr);
|
||||||
}
|
}
|
||||||
namespc->Release();
|
namespc->Release();
|
||||||
return Utils::CreateCStringUniquePtr(result == nullptr ? strdup("") : result);
|
return Utils::CreateCStringUniquePtr(result == nullptr ? Utils::StrDup("")
|
||||||
|
: result);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace bin
|
} // namespace bin
|
||||||
|
|
|
@ -65,7 +65,7 @@ void* Extensions::MakePathAndResolve(const char* dir, const char* name) {
|
||||||
// loaded from the standard location.
|
// loaded from the standard location.
|
||||||
void* Extensions::ResolveAbsPathExtension(const char* extension_path) {
|
void* Extensions::ResolveAbsPathExtension(const char* extension_path) {
|
||||||
const char* last_slash = strrchr(extension_path, PathSeparator()) + 1;
|
const char* last_slash = strrchr(extension_path, PathSeparator()) + 1;
|
||||||
char* name = strdup(last_slash);
|
char* name = Utils::StrDup(last_slash);
|
||||||
char* dir = Utils::StrNDup(extension_path, last_slash - extension_path);
|
char* dir = Utils::StrNDup(extension_path, last_slash - extension_path);
|
||||||
void* library_handle = MakePathAndResolve(dir, name);
|
void* library_handle = MakePathAndResolve(dir, name);
|
||||||
free(dir);
|
free(dir);
|
||||||
|
|
|
@ -29,7 +29,8 @@ void* Extensions::LoadExtensionLibrary(const char* library_file) {
|
||||||
|
|
||||||
void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) {
|
void* Extensions::ResolveSymbol(void* lib_handle, const char* symbol) {
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
return GetProcAddress(reinterpret_cast<HMODULE>(lib_handle), symbol);
|
return reinterpret_cast<void*>(
|
||||||
|
GetProcAddress(reinterpret_cast<HMODULE>(lib_handle), symbol));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Extensions::UnloadLibrary(void* lib_handle) {
|
void Extensions::UnloadLibrary(void* lib_handle) {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include <fcntl.h> // NOLINT
|
#include <fcntl.h> // NOLINT
|
||||||
#include <io.h> // NOLINT
|
#include <io.h> // NOLINT
|
||||||
#include <Shlwapi.h> // NOLINT
|
#include <Shlwapi.h> // NOLINT
|
||||||
|
#undef StrDup // defined in Shlwapi.h as StrDupW
|
||||||
#include <stdio.h> // NOLINT
|
#include <stdio.h> // NOLINT
|
||||||
#include <string.h> // NOLINT
|
#include <string.h> // NOLINT
|
||||||
#include <sys/stat.h> // NOLINT
|
#include <sys/stat.h> // NOLINT
|
||||||
|
@ -55,9 +56,9 @@ void File::Close() {
|
||||||
int fd = _open("NUL", _O_WRONLY);
|
int fd = _open("NUL", _O_WRONLY);
|
||||||
ASSERT(fd >= 0);
|
ASSERT(fd >= 0);
|
||||||
_dup2(fd, closing_fd);
|
_dup2(fd, closing_fd);
|
||||||
close(fd);
|
Utils::Close(fd);
|
||||||
} else {
|
} else {
|
||||||
int err = close(closing_fd);
|
int err = Utils::Close(closing_fd);
|
||||||
if (err != 0) {
|
if (err != 0) {
|
||||||
Syslog::PrintErr("%s\n", strerror(errno));
|
Syslog::PrintErr("%s\n", strerror(errno));
|
||||||
}
|
}
|
||||||
|
@ -141,7 +142,7 @@ void MappedMemory::Unmap() {
|
||||||
|
|
||||||
int64_t File::Read(void* buffer, int64_t num_bytes) {
|
int64_t File::Read(void* buffer, int64_t num_bytes) {
|
||||||
ASSERT(handle_->fd() >= 0);
|
ASSERT(handle_->fd() >= 0);
|
||||||
return read(handle_->fd(), buffer, num_bytes);
|
return Utils::Read(handle_->fd(), buffer, num_bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t File::Write(const void* buffer, int64_t num_bytes) {
|
int64_t File::Write(const void* buffer, int64_t num_bytes) {
|
||||||
|
@ -311,7 +312,7 @@ Utils::CStringUniquePtr File::UriToPath(const char* uri) {
|
||||||
|
|
||||||
Utf8ToWideScope uri_w(uri_decoder.decoded());
|
Utf8ToWideScope uri_w(uri_decoder.decoded());
|
||||||
if (!UrlIsFileUrlW(uri_w.wide())) {
|
if (!UrlIsFileUrlW(uri_w.wide())) {
|
||||||
return Utils::CreateCStringUniquePtr(strdup(uri_decoder.decoded()));
|
return Utils::CreateCStringUniquePtr(Utils::StrDup(uri_decoder.decoded()));
|
||||||
}
|
}
|
||||||
wchar_t filename_w[MAX_PATH];
|
wchar_t filename_w[MAX_PATH];
|
||||||
DWORD filename_len = MAX_PATH;
|
DWORD filename_len = MAX_PATH;
|
||||||
|
@ -382,7 +383,7 @@ bool File::Create(Namespace* namespc, const char* name) {
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return (close(fd) == 0);
|
return (Utils::Close(fd) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This structure is needed for creating and reading Junctions.
|
// This structure is needed for creating and reading Junctions.
|
||||||
|
|
|
@ -13,14 +13,14 @@ IsolateGroupData::IsolateGroupData(const char* url,
|
||||||
const char* packages_file,
|
const char* packages_file,
|
||||||
AppSnapshot* app_snapshot,
|
AppSnapshot* app_snapshot,
|
||||||
bool isolate_run_app_snapshot)
|
bool isolate_run_app_snapshot)
|
||||||
: script_url((url != NULL) ? strdup(url) : NULL),
|
: script_url((url != NULL) ? Utils::StrDup(url) : NULL),
|
||||||
app_snapshot_(app_snapshot),
|
app_snapshot_(app_snapshot),
|
||||||
resolved_packages_config_(NULL),
|
resolved_packages_config_(NULL),
|
||||||
kernel_buffer_(NULL),
|
kernel_buffer_(NULL),
|
||||||
kernel_buffer_size_(0),
|
kernel_buffer_size_(0),
|
||||||
isolate_run_app_snapshot_(isolate_run_app_snapshot) {
|
isolate_run_app_snapshot_(isolate_run_app_snapshot) {
|
||||||
if (packages_file != NULL) {
|
if (packages_file != NULL) {
|
||||||
packages_file_ = strdup(packages_file);
|
packages_file_ = Utils::StrDup(packages_file);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ IsolateData::IsolateData(IsolateGroupData* isolate_group_data)
|
||||||
loader_(nullptr),
|
loader_(nullptr),
|
||||||
packages_file_(nullptr) {
|
packages_file_(nullptr) {
|
||||||
if (isolate_group_data->packages_file_ != nullptr) {
|
if (isolate_group_data->packages_file_ != nullptr) {
|
||||||
packages_file_ = strdup(isolate_group_data->packages_file_);
|
packages_file_ = Utils::StrDup(isolate_group_data->packages_file_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "include/dart_api.h"
|
#include "include/dart_api.h"
|
||||||
#include "platform/assert.h"
|
#include "platform/assert.h"
|
||||||
#include "platform/globals.h"
|
#include "platform/globals.h"
|
||||||
|
#include "platform/utils.h"
|
||||||
|
|
||||||
namespace dart {
|
namespace dart {
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ class IsolateGroupData {
|
||||||
free(resolved_packages_config_);
|
free(resolved_packages_config_);
|
||||||
resolved_packages_config_ = NULL;
|
resolved_packages_config_ = NULL;
|
||||||
}
|
}
|
||||||
resolved_packages_config_ = strdup(packages_config);
|
resolved_packages_config_ = Utils::StrDup(packages_config);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RunFromAppSnapshot() const {
|
bool RunFromAppSnapshot() const {
|
||||||
|
@ -125,7 +126,7 @@ class IsolateData {
|
||||||
free(packages_file_);
|
free(packages_file_);
|
||||||
packages_file_ = nullptr;
|
packages_file_ = nullptr;
|
||||||
}
|
}
|
||||||
packages_file_ = strdup(packages_file);
|
packages_file_ = Utils::StrDup(packages_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
// While loading a loader is associated with the isolate.
|
// While loading a loader is associated with the isolate.
|
||||||
|
|
|
@ -80,7 +80,7 @@ Dart_Handle Loader::LoadImportExtension(const char* url_string,
|
||||||
if (strncmp(lib_uri_str, "file://", 7) == 0) {
|
if (strncmp(lib_uri_str, "file://", 7) == 0) {
|
||||||
lib_path = DartUtils::DirName(lib_uri_str + 7);
|
lib_path = DartUtils::DirName(lib_uri_str + 7);
|
||||||
} else {
|
} else {
|
||||||
lib_path = strdup(lib_uri_str);
|
lib_path = Utils::StrDup(lib_uri_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* path = DartUtils::RemoveScheme(url_string);
|
const char* path = DartUtils::RemoveScheme(url_string);
|
||||||
|
@ -126,7 +126,7 @@ Dart_Handle Loader::ReloadNativeExtensions() {
|
||||||
if (strncmp(lib_uri, "file://", 7) == 0) {
|
if (strncmp(lib_uri, "file://", 7) == 0) {
|
||||||
lib_path = DartUtils::DirName(DartUtils::RemoveScheme(lib_uri));
|
lib_path = DartUtils::DirName(DartUtils::RemoveScheme(lib_uri));
|
||||||
} else {
|
} else {
|
||||||
lib_path = strdup(lib_uri);
|
lib_path = Utils::StrDup(lib_uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
result = Extensions::LoadExtension(lib_path, extension_path, importer);
|
result = Extensions::LoadExtension(lib_path, extension_path, importer);
|
||||||
|
|
|
@ -99,7 +99,7 @@ static Dart_Handle CreateRuntimeOptions(CommandLineOptions* options) {
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SAVE_ERROR_AND_EXIT(result) \
|
#define SAVE_ERROR_AND_EXIT(result) \
|
||||||
*error = strdup(Dart_GetError(result)); \
|
*error = Utils::StrDup(Dart_GetError(result)); \
|
||||||
if (Dart_IsCompilationError(result)) { \
|
if (Dart_IsCompilationError(result)) { \
|
||||||
*exit_code = kCompilationErrorExitCode; \
|
*exit_code = kCompilationErrorExitCode; \
|
||||||
} else if (Dart_IsApiError(result)) { \
|
} else if (Dart_IsApiError(result)) { \
|
||||||
|
@ -278,7 +278,7 @@ static bool OnIsolateInitialize(void** child_callback_data, char** error) {
|
||||||
return *error == nullptr;
|
return *error == nullptr;
|
||||||
|
|
||||||
failed:
|
failed:
|
||||||
*error = strdup(Dart_GetError(result));
|
*error = Utils::StrDup(Dart_GetError(result));
|
||||||
Dart_ExitScope();
|
Dart_ExitScope();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -368,7 +368,7 @@ static Dart_Isolate IsolateSetupHelper(Dart_Isolate isolate,
|
||||||
&resolved_script_uri);
|
&resolved_script_uri);
|
||||||
CHECK_RESULT(result);
|
CHECK_RESULT(result);
|
||||||
ASSERT(app_script_uri == NULL);
|
ASSERT(app_script_uri == NULL);
|
||||||
app_script_uri = strdup(resolved_script_uri);
|
app_script_uri = Utils::StrDup(resolved_script_uri);
|
||||||
}
|
}
|
||||||
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
#endif // !defined(DART_PRECOMPILED_RUNTIME)
|
||||||
} else {
|
} else {
|
||||||
|
@ -559,7 +559,7 @@ static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
|
||||||
Options::vm_service_dev_mode(), Options::vm_service_auth_disabled(),
|
Options::vm_service_dev_mode(), Options::vm_service_auth_disabled(),
|
||||||
Options::vm_write_service_info_filename(), Options::trace_loading(),
|
Options::vm_write_service_info_filename(), Options::trace_loading(),
|
||||||
Options::deterministic(), Options::enable_service_port_fallback())) {
|
Options::deterministic(), Options::enable_service_port_fallback())) {
|
||||||
*error = strdup(VmService::GetErrorMessage());
|
*error = Utils::StrDup(VmService::GetErrorMessage());
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (Options::compile_all()) {
|
if (Options::compile_all()) {
|
||||||
|
|
|
@ -392,7 +392,8 @@ bool Options::ProcessEnableExperimentOption(const char* arg,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
vm_options->AddArgument(arg);
|
vm_options->AddArgument(arg);
|
||||||
Utils::CStringUniquePtr tmp = Utils::CreateCStringUniquePtr(strdup(value));
|
Utils::CStringUniquePtr tmp = Utils::CreateCStringUniquePtr(
|
||||||
|
Utils::StrDup(value));
|
||||||
char* save_ptr; // Needed for strtok_r.
|
char* save_ptr; // Needed for strtok_r.
|
||||||
char* token = strtok_r(const_cast<char*>(tmp.get()), ",", &save_ptr);
|
char* token = strtok_r(const_cast<char*>(tmp.get()), ",", &save_ptr);
|
||||||
while (token != NULL) {
|
while (token != NULL) {
|
||||||
|
@ -526,7 +527,7 @@ int Options::ParseArguments(int argc,
|
||||||
script_or_cmd_index = i;
|
script_or_cmd_index = i;
|
||||||
if (Options::disable_dart_dev() ||
|
if (Options::disable_dart_dev() ||
|
||||||
(is_potential_file_path && !enable_vm_service_)) {
|
(is_potential_file_path && !enable_vm_service_)) {
|
||||||
*script_name = strdup(argv[i]);
|
*script_name = Utils::StrDup(argv[i]);
|
||||||
run_script = true;
|
run_script = true;
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -81,7 +81,7 @@ bool OptionProcessor::ProcessEnvironmentOption(
|
||||||
name = reinterpret_cast<char*>(malloc(name_len + 1));
|
name = reinterpret_cast<char*>(malloc(name_len + 1));
|
||||||
strncpy(name, arg, name_len);
|
strncpy(name, arg, name_len);
|
||||||
name[name_len] = '\0';
|
name[name_len] = '\0';
|
||||||
value = strdup(equals_pos + 1);
|
value = Utils::StrDup(equals_pos + 1);
|
||||||
SimpleHashMap::Entry* entry =
|
SimpleHashMap::Entry* entry =
|
||||||
(*environment)
|
(*environment)
|
||||||
->Lookup(GetHashmapKeyFromString(name),
|
->Lookup(GetHashmapKeyFromString(name),
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "bin/builtin.h"
|
#include "bin/builtin.h"
|
||||||
#include "platform/globals.h"
|
#include "platform/globals.h"
|
||||||
|
#include "platform/utils.h"
|
||||||
|
|
||||||
namespace dart {
|
namespace dart {
|
||||||
namespace bin {
|
namespace bin {
|
||||||
|
@ -82,7 +83,7 @@ class Platform {
|
||||||
// Try to resolve the executable path using platform specific APIs.
|
// Try to resolve the executable path using platform specific APIs.
|
||||||
const char* resolved_name = Platform::ResolveExecutablePath();
|
const char* resolved_name = Platform::ResolveExecutablePath();
|
||||||
if (resolved_name != NULL) {
|
if (resolved_name != NULL) {
|
||||||
resolved_executable_name_ = strdup(resolved_name);
|
resolved_executable_name_ = Utils::StrDup(resolved_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resolved_executable_name_;
|
return resolved_executable_name_;
|
||||||
|
|
|
@ -94,7 +94,7 @@ static void PrintUsage() {
|
||||||
|
|
||||||
#define CHECK_RESULT(result) \
|
#define CHECK_RESULT(result) \
|
||||||
if (Dart_IsError(result)) { \
|
if (Dart_IsError(result)) { \
|
||||||
*error = strdup(Dart_GetError(result)); \
|
*error = Utils::StrDup(Dart_GetError(result)); \
|
||||||
Dart_ExitScope(); \
|
Dart_ExitScope(); \
|
||||||
Dart_ShutdownIsolate(); \
|
Dart_ShutdownIsolate(); \
|
||||||
return nullptr; \
|
return nullptr; \
|
||||||
|
@ -150,7 +150,7 @@ static Dart_Isolate CreateAndSetupServiceIsolate(const char* script_uri,
|
||||||
/*write_service_info_filename*/ "",
|
/*write_service_info_filename*/ "",
|
||||||
/*trace_loading=*/false, /*deterministic=*/true,
|
/*trace_loading=*/false, /*deterministic=*/true,
|
||||||
/*enable_service_port_fallback=*/false)) {
|
/*enable_service_port_fallback=*/false)) {
|
||||||
*error = strdup(bin::VmService::GetErrorMessage());
|
*error = Utils::StrDup(bin::VmService::GetErrorMessage());
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
result = Dart_SetEnvironmentCallback(bin::DartUtils::EnvironmentCallback);
|
result = Dart_SetEnvironmentCallback(bin::DartUtils::EnvironmentCallback);
|
||||||
|
@ -176,8 +176,8 @@ static Dart_Isolate CreateIsolateAndSetup(const char* script_uri,
|
||||||
const bool is_kernel_isolate =
|
const bool is_kernel_isolate =
|
||||||
strcmp(script_uri, DART_KERNEL_ISOLATE_NAME) == 0;
|
strcmp(script_uri, DART_KERNEL_ISOLATE_NAME) == 0;
|
||||||
if (!is_kernel_isolate) {
|
if (!is_kernel_isolate) {
|
||||||
*error =
|
*error = Utils::StrDup(
|
||||||
strdup("Spawning of only Kernel isolate is supported in run_vm_tests.");
|
"Spawning of only Kernel isolate is supported in run_vm_tests.");
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
Dart_Isolate isolate = nullptr;
|
Dart_Isolate isolate = nullptr;
|
||||||
|
@ -337,7 +337,7 @@ static int Main(int argc, const char** argv) {
|
||||||
PrintUsage();
|
PrintUsage();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
kernel_snapshot = strdup(delim + 1);
|
kernel_snapshot = Utils::StrDup(delim + 1);
|
||||||
start_kernel_isolate = true;
|
start_kernel_isolate = true;
|
||||||
ShiftArgs(&argc, argv);
|
ShiftArgs(&argc, argv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -494,7 +494,7 @@ void SSLFilter::Connect(const char* hostname,
|
||||||
// Sets the hostname in the certificate-checking object, so it is checked
|
// Sets the hostname in the certificate-checking object, so it is checked
|
||||||
// against the certificate presented by the server.
|
// against the certificate presented by the server.
|
||||||
X509_VERIFY_PARAM* certificate_checking_parameters = SSL_get0_param(ssl_);
|
X509_VERIFY_PARAM* certificate_checking_parameters = SSL_get0_param(ssl_);
|
||||||
hostname_ = strdup(hostname);
|
hostname_ = Utils::StrDup(hostname);
|
||||||
X509_VERIFY_PARAM_set_flags(
|
X509_VERIFY_PARAM_set_flags(
|
||||||
certificate_checking_parameters,
|
certificate_checking_parameters,
|
||||||
X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_TRUSTED_FIRST);
|
X509_V_FLAG_PARTIAL_CHAIN | X509_V_FLAG_TRUSTED_FIRST);
|
||||||
|
|
|
@ -289,10 +289,10 @@ bool ListeningSocketRegistry::CloseOneSafe(OSSocket* os_socket,
|
||||||
// If the socket is abstract, which has a path starting with a null byte,
|
// If the socket is abstract, which has a path starting with a null byte,
|
||||||
// unlink() is not necessary because the file doesn't exist.
|
// unlink() is not necessary because the file doesn't exist.
|
||||||
if (os_socket->address.un.sun_path[0] != '\0') {
|
if (os_socket->address.un.sun_path[0] != '\0') {
|
||||||
unlink(os_socket->address.un.sun_path);
|
Utils::Unlink(os_socket->address.un.sun_path);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
unlink(os_socket->address.un.sun_path);
|
Utils::Unlink(os_socket->address.un.sun_path);
|
||||||
#endif // defined(HOST_OS_LINUX) || defined(HOST_OS_ANDROID)
|
#endif // defined(HOST_OS_LINUX) || defined(HOST_OS_ANDROID)
|
||||||
// Remove os_socket from unix_domain_sockets_ list.
|
// Remove os_socket from unix_domain_sockets_ list.
|
||||||
OSSocket* prev = nullptr;
|
OSSocket* prev = nullptr;
|
||||||
|
|
|
@ -65,7 +65,15 @@ bool SocketBase::FormatNumericAddress(const RawAddr& addr,
|
||||||
socklen_t salen = SocketAddress::GetAddrLength(addr);
|
socklen_t salen = SocketAddress::GetAddrLength(addr);
|
||||||
DWORD l = len;
|
DWORD l = len;
|
||||||
RawAddr& raw = const_cast<RawAddr&>(addr);
|
RawAddr& raw = const_cast<RawAddr&>(addr);
|
||||||
return WSAAddressToStringA(&raw.addr, salen, NULL, address, &l) != 0;
|
wchar_t* waddress = reinterpret_cast<wchar_t*>(
|
||||||
|
Dart_ScopeAllocate((salen + 1) * sizeof(wchar_t)));
|
||||||
|
intptr_t result = WSAAddressToStringW(&raw.addr, salen, NULL, waddress, &l);
|
||||||
|
if (result != 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
WideToUtf8Scope wide_name(waddress);
|
||||||
|
strncpy(address, wide_name.utf8(), l);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
intptr_t SocketBase::Available(intptr_t fd) {
|
intptr_t SocketBase::Available(intptr_t fd) {
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
#include "include/dart_api.h"
|
#include "include/dart_api.h"
|
||||||
#include "platform/globals.h"
|
#include "platform/globals.h"
|
||||||
|
#include "platform/utils.h"
|
||||||
|
|
||||||
namespace dart {
|
namespace dart {
|
||||||
namespace bin {
|
namespace bin {
|
||||||
|
@ -43,7 +44,7 @@ class OSError {
|
||||||
if (message == NULL) {
|
if (message == NULL) {
|
||||||
message_ = NULL;
|
message_ = NULL;
|
||||||
} else {
|
} else {
|
||||||
message_ = strdup(message);
|
message_ = Utils::StrDup(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "bin/thread.h"
|
#include "bin/thread.h"
|
||||||
#include "bin/utils.h"
|
#include "bin/utils.h"
|
||||||
#include "platform/text_buffer.h"
|
#include "platform/text_buffer.h"
|
||||||
|
#include "platform/utils.h"
|
||||||
|
|
||||||
namespace dart {
|
namespace dart {
|
||||||
namespace bin {
|
namespace bin {
|
||||||
|
@ -24,7 +25,7 @@ namespace bin {
|
||||||
|
|
||||||
#define SHUTDOWN_ON_ERROR(handle) \
|
#define SHUTDOWN_ON_ERROR(handle) \
|
||||||
if (Dart_IsError(handle)) { \
|
if (Dart_IsError(handle)) { \
|
||||||
error_msg_ = strdup(Dart_GetError(handle)); \
|
error_msg_ = Utils::StrDup(Dart_GetError(handle)); \
|
||||||
Dart_ExitScope(); \
|
Dart_ExitScope(); \
|
||||||
Dart_ShutdownIsolate(); \
|
Dart_ShutdownIsolate(); \
|
||||||
return false; \
|
return false; \
|
||||||
|
|
|
@ -105,7 +105,8 @@ static void* ResolveSymbol(void* handle, const char* symbol) {
|
||||||
return pointer;
|
return pointer;
|
||||||
#elif defined(HOST_OS_WINDOWS)
|
#elif defined(HOST_OS_WINDOWS)
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
void* pointer = GetProcAddress(reinterpret_cast<HMODULE>(handle), symbol);
|
void* pointer = reinterpret_cast<void*>(
|
||||||
|
GetProcAddress(reinterpret_cast<HMODULE>(handle), symbol));
|
||||||
if (pointer == nullptr) {
|
if (pointer == nullptr) {
|
||||||
const int error = GetLastError();
|
const int error = GetLastError();
|
||||||
const String& msg = String::Handle(
|
const String& msg = String::Handle(
|
||||||
|
|
|
@ -414,8 +414,13 @@ class Utils {
|
||||||
|
|
||||||
// Not all platforms support strndup.
|
// Not all platforms support strndup.
|
||||||
static char* StrNDup(const char* s, intptr_t n);
|
static char* StrNDup(const char* s, intptr_t n);
|
||||||
|
static char* StrDup(const char* s);
|
||||||
static intptr_t StrNLen(const char* s, intptr_t n);
|
static intptr_t StrNLen(const char* s, intptr_t n);
|
||||||
|
|
||||||
|
static int Close(int fildes);
|
||||||
|
static size_t Read(int filedes, void* buf, size_t nbyte);
|
||||||
|
static int Unlink(const char* path);
|
||||||
|
|
||||||
// Print formatted output info a buffer.
|
// Print formatted output info a buffer.
|
||||||
//
|
//
|
||||||
// Does not write more than size characters (including the trailing '\0').
|
// Does not write more than size characters (including the trailing '\0').
|
||||||
|
|
|
@ -13,6 +13,10 @@ char* Utils::StrNDup(const char* s, intptr_t n) {
|
||||||
return strndup(s, n);
|
return strndup(s, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* Utils::StrDup(const char* s) {
|
||||||
|
return strdup(s);
|
||||||
|
}
|
||||||
|
|
||||||
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
||||||
return strnlen(s, n);
|
return strnlen(s, n);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +37,16 @@ int Utils::VSNPrint(char* str, size_t size, const char* format, va_list args) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Utils::Close(int fildes) {
|
||||||
|
return close(fildes);
|
||||||
|
}
|
||||||
|
size_t Utils::Read(int filedes, void* buf, size_t nbyte) {
|
||||||
|
return read(filedes, buf, nbyte);
|
||||||
|
}
|
||||||
|
int Utils::Unlink(const char* path) {
|
||||||
|
return unlink(path);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dart
|
} // namespace dart
|
||||||
|
|
||||||
#endif // defined(HOST_OS_ANDROID)
|
#endif // defined(HOST_OS_ANDROID)
|
||||||
|
|
|
@ -17,6 +17,10 @@ char* Utils::StrNDup(const char* s, intptr_t n) {
|
||||||
return strndup(s, n);
|
return strndup(s, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* Utils::StrDup(const char* s) {
|
||||||
|
return strdup(s);
|
||||||
|
}
|
||||||
|
|
||||||
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
||||||
return strnlen(s, n);
|
return strnlen(s, n);
|
||||||
}
|
}
|
||||||
|
@ -37,6 +41,16 @@ int Utils::VSNPrint(char* str, size_t size, const char* format, va_list args) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Utils::Close(int fildes) {
|
||||||
|
return close(fildes);
|
||||||
|
}
|
||||||
|
size_t Utils::Read(int filedes, void* buf, size_t nbyte) {
|
||||||
|
return read(filedes, buf, nbyte);
|
||||||
|
}
|
||||||
|
int Utils::Unlink(const char* path) {
|
||||||
|
return unlink(path);
|
||||||
|
}
|
||||||
|
|
||||||
sys::ComponentContext* ComponentContext() {
|
sys::ComponentContext* ComponentContext() {
|
||||||
static std::unique_ptr<sys::ComponentContext> context =
|
static std::unique_ptr<sys::ComponentContext> context =
|
||||||
sys::ComponentContext::CreateAndServeOutgoingDirectory();
|
sys::ComponentContext::CreateAndServeOutgoingDirectory();
|
||||||
|
|
|
@ -13,6 +13,10 @@ char* Utils::StrNDup(const char* s, intptr_t n) {
|
||||||
return strndup(s, n);
|
return strndup(s, n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* Utils::StrDup(const char* s) {
|
||||||
|
return strdup(s);
|
||||||
|
}
|
||||||
|
|
||||||
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
||||||
return strnlen(s, n);
|
return strnlen(s, n);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +38,16 @@ int Utils::VSNPrint(char* str, size_t size, const char* format, va_list args) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Utils::Close(int fildes) {
|
||||||
|
return close(fildes);
|
||||||
|
}
|
||||||
|
size_t Utils::Read(int filedes, void* buf, size_t nbyte) {
|
||||||
|
return read(filedes, buf, nbyte);
|
||||||
|
}
|
||||||
|
int Utils::Unlink(const char* path) {
|
||||||
|
return unlink(path);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dart
|
} // namespace dart
|
||||||
|
|
||||||
#endif // defined(HOST_OS_LINUX)
|
#endif // defined(HOST_OS_LINUX)
|
||||||
|
|
|
@ -35,6 +35,10 @@ char* Utils::StrNDup(const char* s, intptr_t n) {
|
||||||
#endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
|
#endif // !defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) || ...
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* Utils::StrDup(const char* s) {
|
||||||
|
return strdup(s);
|
||||||
|
}
|
||||||
|
|
||||||
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
||||||
// strnlen has only been added to Mac OS X in 10.7. We are supplying
|
// strnlen has only been added to Mac OS X in 10.7. We are supplying
|
||||||
// our own copy here if needed.
|
// our own copy here if needed.
|
||||||
|
@ -67,6 +71,16 @@ int Utils::VSNPrint(char* str, size_t size, const char* format, va_list args) {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Utils::Close(int fildes) {
|
||||||
|
return close(fildes);
|
||||||
|
}
|
||||||
|
size_t Utils::Read(int filedes, void* buf, size_t nbyte) {
|
||||||
|
return read(filedes, buf, nbyte);
|
||||||
|
}
|
||||||
|
int Utils::Unlink(const char* path) {
|
||||||
|
return unlink(path);
|
||||||
|
}
|
||||||
|
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
|
||||||
// Returns the running system's Darwin major version. Don't call this, it's
|
// Returns the running system's Darwin major version. Don't call this, it's
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#include "platform/globals.h"
|
#include "platform/globals.h"
|
||||||
#if defined(HOST_OS_WINDOWS)
|
#if defined(HOST_OS_WINDOWS)
|
||||||
|
|
||||||
|
#include <io.h> // NOLINT
|
||||||
#include "platform/utils.h"
|
#include "platform/utils.h"
|
||||||
|
|
||||||
namespace dart {
|
namespace dart {
|
||||||
|
@ -25,6 +26,10 @@ char* Utils::StrNDup(const char* s, intptr_t n) {
|
||||||
return reinterpret_cast<char*>(memmove(result, s, len));
|
return reinterpret_cast<char*>(memmove(result, s, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* Utils::StrDup(const char* s) {
|
||||||
|
return _strdup(s);
|
||||||
|
}
|
||||||
|
|
||||||
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
intptr_t Utils::StrNLen(const char* s, intptr_t n) {
|
||||||
return strnlen(s, n);
|
return strnlen(s, n);
|
||||||
}
|
}
|
||||||
|
@ -71,6 +76,16 @@ int Utils::VSNPrint(char* str, size_t size, const char* format, va_list args) {
|
||||||
return written;
|
return written;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int Utils::Close(int fildes) {
|
||||||
|
return _close(fildes);
|
||||||
|
}
|
||||||
|
size_t Utils::Read(int filedes, void* buf, size_t nbyte) {
|
||||||
|
return _read(filedes, buf, nbyte);
|
||||||
|
}
|
||||||
|
int Utils::Unlink(const char* path) {
|
||||||
|
return _unlink(path);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace dart
|
} // namespace dart
|
||||||
|
|
||||||
#endif // defined(HOST_OS_WINDOWS)
|
#endif // defined(HOST_OS_WINDOWS)
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "platform/assert.h"
|
#include "platform/assert.h"
|
||||||
#include "platform/globals.h"
|
#include "platform/globals.h"
|
||||||
|
#include "platform/utils.h"
|
||||||
|
|
||||||
#include "vm/clustered_snapshot.h"
|
#include "vm/clustered_snapshot.h"
|
||||||
#include "vm/dart_api_impl.h"
|
#include "vm/dart_api_impl.h"
|
||||||
|
@ -63,7 +64,7 @@ BENCHMARK(CorelibCompileAll) {
|
||||||
// which is depended on by run_vm_tests.
|
// which is depended on by run_vm_tests.
|
||||||
static char* ComputeKernelServicePath(const char* arg) {
|
static char* ComputeKernelServicePath(const char* arg) {
|
||||||
char buffer[2048];
|
char buffer[2048];
|
||||||
char* kernel_service_path = strdup(File::GetCanonicalPath(NULL, arg));
|
char* kernel_service_path = Utils::StrDup(File::GetCanonicalPath(NULL, arg));
|
||||||
EXPECT(kernel_service_path != NULL);
|
EXPECT(kernel_service_path != NULL);
|
||||||
const char* compiler_path = "%s%sgen%skernel_service.dill";
|
const char* compiler_path = "%s%sgen%skernel_service.dill";
|
||||||
const char* path_separator = File::PathSeparator();
|
const char* path_separator = File::PathSeparator();
|
||||||
|
@ -82,14 +83,14 @@ static char* ComputeKernelServicePath(const char* arg) {
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return strdup(buffer);
|
return Utils::StrDup(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This file is created by the target //runtime/bin:gen_kernel_bytecode_dill
|
// This file is created by the target //runtime/bin:gen_kernel_bytecode_dill
|
||||||
// which is depended on by run_vm_tests.
|
// which is depended on by run_vm_tests.
|
||||||
static char* ComputeGenKernelKernelPath(const char* arg) {
|
static char* ComputeGenKernelKernelPath(const char* arg) {
|
||||||
char buffer[2048];
|
char buffer[2048];
|
||||||
char* gen_kernel_path = strdup(File::GetCanonicalPath(NULL, arg));
|
char* gen_kernel_path = Utils::StrDup(File::GetCanonicalPath(NULL, arg));
|
||||||
EXPECT(gen_kernel_path != NULL);
|
EXPECT(gen_kernel_path != NULL);
|
||||||
const char* compiler_path = "%s%sgen_kernel_bytecode.dill";
|
const char* compiler_path = "%s%sgen_kernel_bytecode.dill";
|
||||||
const char* path_separator = File::PathSeparator();
|
const char* path_separator = File::PathSeparator();
|
||||||
|
@ -108,7 +109,7 @@ static char* ComputeGenKernelKernelPath(const char* arg) {
|
||||||
if (ptr == NULL) {
|
if (ptr == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return strdup(buffer);
|
return Utils::StrDup(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int64_t GenKernelKernelBenchmark(const char* name,
|
static int64_t GenKernelKernelBenchmark(const char* name,
|
||||||
|
|
|
@ -6134,7 +6134,7 @@ char* SnapshotHeaderReader::ReadFeatures(const char** features,
|
||||||
}
|
}
|
||||||
|
|
||||||
char* SnapshotHeaderReader::BuildError(const char* message) {
|
char* SnapshotHeaderReader::BuildError(const char* message) {
|
||||||
return strdup(message);
|
return Utils::StrDup(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiErrorPtr FullSnapshotReader::ConvertToApiError(char* message) {
|
ApiErrorPtr FullSnapshotReader::ConvertToApiError(char* message) {
|
||||||
|
|
|
@ -779,7 +779,7 @@ void Assembler::negatepd(XmmRegister dst) {
|
||||||
static const struct ALIGN16 {
|
static const struct ALIGN16 {
|
||||||
uint64_t a;
|
uint64_t a;
|
||||||
uint64_t b;
|
uint64_t b;
|
||||||
} double_negate_constant = {0x8000000000000000LL, 0x8000000000000000LL};
|
} double_negate_constant = {0x8000000000000000LLU, 0x8000000000000000LLU};
|
||||||
xorpd(dst,
|
xorpd(dst,
|
||||||
Address::Absolute(reinterpret_cast<uword>(&double_negate_constant)));
|
Address::Absolute(reinterpret_cast<uword>(&double_negate_constant)));
|
||||||
}
|
}
|
||||||
|
@ -2075,7 +2075,7 @@ void Assembler::DoubleNegate(XmmRegister d) {
|
||||||
static const struct ALIGN16 {
|
static const struct ALIGN16 {
|
||||||
uint64_t a;
|
uint64_t a;
|
||||||
uint64_t b;
|
uint64_t b;
|
||||||
} double_negate_constant = {0x8000000000000000LL, 0x8000000000000000LL};
|
} double_negate_constant = {0x8000000000000000LLU, 0x8000000000000000LLU};
|
||||||
xorpd(d, Address::Absolute(reinterpret_cast<uword>(&double_negate_constant)));
|
xorpd(d, Address::Absolute(reinterpret_cast<uword>(&double_negate_constant)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,11 +81,11 @@ void CpuId::Cleanup() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CpuId::id_string() {
|
const char* CpuId::id_string() {
|
||||||
return strdup(id_string_);
|
return Utils::StrDup(id_string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CpuId::brand_string() {
|
const char* CpuId::brand_string() {
|
||||||
return strdup(brand_string_);
|
return Utils::StrDup(brand_string_);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* CpuId::field(CpuInfoIndices idx) {
|
const char* CpuId::field(CpuInfoIndices idx) {
|
||||||
|
@ -115,7 +115,7 @@ const char* CpuId::field(CpuInfoIndices idx) {
|
||||||
}
|
}
|
||||||
// Remove last space before returning string.
|
// Remove last space before returning string.
|
||||||
if (p != buffer) *(p - 1) = '\0';
|
if (p != buffer) *(p - 1) = '\0';
|
||||||
return strdup(buffer);
|
return Utils::StrDup(buffer);
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#define RUNTIME_VM_CPUINFO_H_
|
#define RUNTIME_VM_CPUINFO_H_
|
||||||
|
|
||||||
#include "platform/assert.h"
|
#include "platform/assert.h"
|
||||||
|
#include "platform/utils.h"
|
||||||
#include "vm/allocation.h"
|
#include "vm/allocation.h"
|
||||||
|
|
||||||
namespace dart {
|
namespace dart {
|
||||||
|
@ -56,7 +57,7 @@ class CpuInfo : public AllStatic {
|
||||||
if (HasField(FieldName(kCpuInfoHardware))) {
|
if (HasField(FieldName(kCpuInfoHardware))) {
|
||||||
return ExtractField(kCpuInfoHardware);
|
return ExtractField(kCpuInfoHardware);
|
||||||
} else {
|
} else {
|
||||||
return strdup("Unknown");
|
return Utils::StrDup("Unknown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ static void native_echo(Dart_NativeArguments args) {
|
||||||
if (saved_echo != nullptr) {
|
if (saved_echo != nullptr) {
|
||||||
free(saved_echo);
|
free(saved_echo);
|
||||||
}
|
}
|
||||||
saved_echo = strdup(c_str);
|
saved_echo = Utils::StrDup(c_str);
|
||||||
OS::PrintErr("-- (isolate=%p) %s\n", Dart_CurrentIsolate(), c_str);
|
OS::PrintErr("-- (isolate=%p) %s\n", Dart_CurrentIsolate(), c_str);
|
||||||
Dart_ExitScope();
|
Dart_ExitScope();
|
||||||
}
|
}
|
||||||
|
@ -262,7 +262,7 @@ static void CustomIsolateImpl_start(Dart_NativeArguments args) {
|
||||||
EXPECT(Dart_IsString(param));
|
EXPECT(Dart_IsString(param));
|
||||||
const char* isolate_main = NULL;
|
const char* isolate_main = NULL;
|
||||||
EXPECT_VALID(Dart_StringToCString(param, &isolate_main));
|
EXPECT_VALID(Dart_StringToCString(param, &isolate_main));
|
||||||
isolate_main = strdup(isolate_main);
|
isolate_main = Utils::StrDup(isolate_main);
|
||||||
|
|
||||||
// Save current isolate.
|
// Save current isolate.
|
||||||
Dart_Isolate saved_isolate = Dart_CurrentIsolate();
|
Dart_Isolate saved_isolate = Dart_CurrentIsolate();
|
||||||
|
|
|
@ -161,11 +161,11 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
|
||||||
CheckOffsets();
|
CheckOffsets();
|
||||||
// TODO(iposva): Fix race condition here.
|
// TODO(iposva): Fix race condition here.
|
||||||
if (vm_isolate_ != NULL || !Flags::Initialized()) {
|
if (vm_isolate_ != NULL || !Flags::Initialized()) {
|
||||||
return strdup("VM already initialized or flags not initialized.");
|
return Utils::StrDup("VM already initialized or flags not initialized.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FLAG_causal_async_stacks && FLAG_lazy_async_stacks) {
|
if (FLAG_causal_async_stacks && FLAG_lazy_async_stacks) {
|
||||||
return strdup(
|
return Utils::StrDup(
|
||||||
"To use --lazy-async-stacks, please disable --causal-async-stacks!");
|
"To use --lazy-async-stacks, please disable --causal-async-stacks!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,7 +173,7 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
|
||||||
if (vm_isolate_snapshot != nullptr) {
|
if (vm_isolate_snapshot != nullptr) {
|
||||||
snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot);
|
snapshot = Snapshot::SetupFromBuffer(vm_isolate_snapshot);
|
||||||
if (snapshot == nullptr) {
|
if (snapshot == nullptr) {
|
||||||
return strdup("Invalid vm isolate snapshot seen");
|
return Utils::StrDup("Invalid vm isolate snapshot seen");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,15 +282,16 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
|
||||||
if (Snapshot::IncludesCode(vm_snapshot_kind_)) {
|
if (Snapshot::IncludesCode(vm_snapshot_kind_)) {
|
||||||
if (vm_snapshot_kind_ == Snapshot::kFullAOT) {
|
if (vm_snapshot_kind_ == Snapshot::kFullAOT) {
|
||||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||||
return strdup("JIT runtime cannot run a precompiled snapshot");
|
return Utils::StrDup("JIT runtime cannot run a precompiled snapshot");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (instructions_snapshot == NULL) {
|
if (instructions_snapshot == NULL) {
|
||||||
return strdup("Missing instructions snapshot");
|
return Utils::StrDup("Missing instructions snapshot");
|
||||||
}
|
}
|
||||||
} else if (Snapshot::IsFull(vm_snapshot_kind_)) {
|
} else if (Snapshot::IsFull(vm_snapshot_kind_)) {
|
||||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||||
return strdup("Precompiled runtime requires a precompiled snapshot");
|
return Utils::StrDup(
|
||||||
|
"Precompiled runtime requires a precompiled snapshot");
|
||||||
#else
|
#else
|
||||||
StubCode::Init();
|
StubCode::Init();
|
||||||
Object::FinishInit(vm_isolate_);
|
Object::FinishInit(vm_isolate_);
|
||||||
|
@ -303,13 +304,13 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
|
||||||
MallocHooks::Init();
|
MallocHooks::Init();
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
return strdup("Invalid vm isolate snapshot seen");
|
return Utils::StrDup("Invalid vm isolate snapshot seen");
|
||||||
}
|
}
|
||||||
FullSnapshotReader reader(snapshot, instructions_snapshot, T);
|
FullSnapshotReader reader(snapshot, instructions_snapshot, T);
|
||||||
const Error& error = Error::Handle(reader.ReadVMSnapshot());
|
const Error& error = Error::Handle(reader.ReadVMSnapshot());
|
||||||
if (!error.IsNull()) {
|
if (!error.IsNull()) {
|
||||||
// Must copy before leaving the zone.
|
// Must copy before leaving the zone.
|
||||||
return strdup(error.ToErrorCString());
|
return Utils::StrDup(error.ToErrorCString());
|
||||||
}
|
}
|
||||||
|
|
||||||
ReversePcLookupCache::BuildAndAttachToIsolateGroup(vm_isolate_->group());
|
ReversePcLookupCache::BuildAndAttachToIsolateGroup(vm_isolate_->group());
|
||||||
|
@ -337,7 +338,8 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||||
return strdup("Precompiled runtime requires a precompiled snapshot");
|
return Utils::StrDup(
|
||||||
|
"Precompiled runtime requires a precompiled snapshot");
|
||||||
#else
|
#else
|
||||||
vm_snapshot_kind_ = Snapshot::kNone;
|
vm_snapshot_kind_ = Snapshot::kNone;
|
||||||
StubCode::Init();
|
StubCode::Init();
|
||||||
|
@ -358,7 +360,7 @@ char* Dart::Init(const uint8_t* vm_isolate_snapshot,
|
||||||
#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
|
#if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64)
|
||||||
// Dart VM requires at least SSE2.
|
// Dart VM requires at least SSE2.
|
||||||
if (!TargetCPUFeatures::sse2_supported()) {
|
if (!TargetCPUFeatures::sse2_supported()) {
|
||||||
return strdup("SSE2 is required.");
|
return Utils::StrDup("SSE2 is required.");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
@ -469,7 +471,7 @@ void Dart::WaitForIsolateShutdown() {
|
||||||
char* Dart::Cleanup() {
|
char* Dart::Cleanup() {
|
||||||
ASSERT(Isolate::Current() == NULL);
|
ASSERT(Isolate::Current() == NULL);
|
||||||
if (vm_isolate_ == NULL) {
|
if (vm_isolate_ == NULL) {
|
||||||
return strdup("VM already terminated.");
|
return Utils::StrDup("VM already terminated.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (FLAG_trace_shutdown) {
|
if (FLAG_trace_shutdown) {
|
||||||
|
|
|
@ -1047,13 +1047,13 @@ DART_EXPORT const char* Dart_VersionString() {
|
||||||
|
|
||||||
DART_EXPORT char* Dart_Initialize(Dart_InitializeParams* params) {
|
DART_EXPORT char* Dart_Initialize(Dart_InitializeParams* params) {
|
||||||
if (params == NULL) {
|
if (params == NULL) {
|
||||||
return strdup(
|
return Utils::StrDup(
|
||||||
"Dart_Initialize: "
|
"Dart_Initialize: "
|
||||||
"Dart_InitializeParams is null.");
|
"Dart_InitializeParams is null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params->version != DART_INITIALIZE_PARAMS_CURRENT_VERSION) {
|
if (params->version != DART_INITIALIZE_PARAMS_CURRENT_VERSION) {
|
||||||
return strdup(
|
return Utils::StrDup(
|
||||||
"Dart_Initialize: "
|
"Dart_Initialize: "
|
||||||
"Invalid Dart_InitializeParams version.");
|
"Invalid Dart_InitializeParams version.");
|
||||||
}
|
}
|
||||||
|
@ -1139,7 +1139,7 @@ static Dart_Isolate CreateIsolate(IsolateGroup* group,
|
||||||
Isolate* I = Dart::CreateIsolate(name, source->flags, group);
|
Isolate* I = Dart::CreateIsolate(name, source->flags, group);
|
||||||
if (I == NULL) {
|
if (I == NULL) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
*error = strdup("Isolate creation failed");
|
*error = Utils::StrDup("Isolate creation failed");
|
||||||
}
|
}
|
||||||
return reinterpret_cast<Dart_Isolate>(NULL);
|
return reinterpret_cast<Dart_Isolate>(NULL);
|
||||||
}
|
}
|
||||||
|
@ -1166,7 +1166,7 @@ static Dart_Isolate CreateIsolate(IsolateGroup* group,
|
||||||
#endif // defined(DEBUG) && !defined(DART_PRECOMPILED_RUNTIME).
|
#endif // defined(DEBUG) && !defined(DART_PRECOMPILED_RUNTIME).
|
||||||
success = true;
|
success = true;
|
||||||
} else if (error != NULL) {
|
} else if (error != NULL) {
|
||||||
*error = strdup(error_obj.ToErrorCString());
|
*error = Utils::StrDup(error_obj.ToErrorCString());
|
||||||
}
|
}
|
||||||
// We exit the API scope entered above.
|
// We exit the API scope entered above.
|
||||||
T->ExitApiScope();
|
T->ExitApiScope();
|
||||||
|
@ -1615,7 +1615,7 @@ DART_EXPORT bool Dart_WriteProfileToTimeline(Dart_Port main_port,
|
||||||
#else
|
#else
|
||||||
if (!FLAG_profiler) {
|
if (!FLAG_profiler) {
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
*error = strdup("The profiler is not running.");
|
*error = Utils::StrDup("The profiler is not running.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1898,7 +1898,7 @@ DART_EXPORT char* Dart_IsolateMakeRunnable(Dart_Isolate isolate) {
|
||||||
error = iso->MakeRunnable();
|
error = iso->MakeRunnable();
|
||||||
}
|
}
|
||||||
if (error != NULL) {
|
if (error != NULL) {
|
||||||
return strdup(error);
|
return Utils::StrDup(error);
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -5986,7 +5986,7 @@ Dart_CompileToKernel(const char* script_uri,
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Dart_CompileToKernel is unsupported.");
|
result.error = Utils::StrDup("Dart_CompileToKernel is unsupported.");
|
||||||
#else
|
#else
|
||||||
result = KernelIsolate::CompileToKernel(script_uri, platform_kernel,
|
result = KernelIsolate::CompileToKernel(script_uri, platform_kernel,
|
||||||
platform_kernel_size, 0, NULL,
|
platform_kernel_size, 0, NULL,
|
||||||
|
@ -6009,7 +6009,7 @@ DART_EXPORT Dart_KernelCompilationResult Dart_KernelListDependencies() {
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
#if defined(DART_PRECOMPILED_RUNTIME)
|
#if defined(DART_PRECOMPILED_RUNTIME)
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Dart_KernelListDependencies is unsupported.");
|
result.error = Utils::StrDup("Dart_KernelListDependencies is unsupported.");
|
||||||
#else
|
#else
|
||||||
result = KernelIsolate::ListDependencies();
|
result = KernelIsolate::ListDependencies();
|
||||||
#endif
|
#endif
|
||||||
|
@ -6092,28 +6092,28 @@ DART_EXPORT char* Dart_SetServiceStreamCallbacks(
|
||||||
#else
|
#else
|
||||||
if (listen_callback != NULL) {
|
if (listen_callback != NULL) {
|
||||||
if (Service::stream_listen_callback() != NULL) {
|
if (Service::stream_listen_callback() != NULL) {
|
||||||
return strdup(
|
return Utils::StrDup(
|
||||||
"Dart_SetServiceStreamCallbacks "
|
"Dart_SetServiceStreamCallbacks "
|
||||||
"permits only one listen callback to be registered, please "
|
"permits only one listen callback to be registered, please "
|
||||||
"remove the existing callback and then add this callback");
|
"remove the existing callback and then add this callback");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Service::stream_listen_callback() == NULL) {
|
if (Service::stream_listen_callback() == NULL) {
|
||||||
return strdup(
|
return Utils::StrDup(
|
||||||
"Dart_SetServiceStreamCallbacks "
|
"Dart_SetServiceStreamCallbacks "
|
||||||
"expects 'listen_callback' to be present in the callback set.");
|
"expects 'listen_callback' to be present in the callback set.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cancel_callback != NULL) {
|
if (cancel_callback != NULL) {
|
||||||
if (Service::stream_cancel_callback() != NULL) {
|
if (Service::stream_cancel_callback() != NULL) {
|
||||||
return strdup(
|
return Utils::StrDup(
|
||||||
"Dart_SetServiceStreamCallbacks "
|
"Dart_SetServiceStreamCallbacks "
|
||||||
"permits only one cancel callback to be registered, please "
|
"permits only one cancel callback to be registered, please "
|
||||||
"remove the existing callback and then add this callback");
|
"remove the existing callback and then add this callback");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Service::stream_cancel_callback() == NULL) {
|
if (Service::stream_cancel_callback() == NULL) {
|
||||||
return strdup(
|
return Utils::StrDup(
|
||||||
"Dart_SetServiceStreamCallbacks "
|
"Dart_SetServiceStreamCallbacks "
|
||||||
"expects 'cancel_callback' to be present in the callback set.");
|
"expects 'cancel_callback' to be present in the callback set.");
|
||||||
}
|
}
|
||||||
|
@ -6162,14 +6162,14 @@ DART_EXPORT char* Dart_SetFileModifiedCallback(
|
||||||
#if !defined(DART_PRECOMPILED_RUNTIME)
|
#if !defined(DART_PRECOMPILED_RUNTIME)
|
||||||
if (file_modified_callback != NULL) {
|
if (file_modified_callback != NULL) {
|
||||||
if (IsolateGroupReloadContext::file_modified_callback() != NULL) {
|
if (IsolateGroupReloadContext::file_modified_callback() != NULL) {
|
||||||
return strdup(
|
return Utils::StrDup(
|
||||||
"Dart_SetFileModifiedCallback permits only one callback to be"
|
"Dart_SetFileModifiedCallback permits only one callback to be"
|
||||||
" registered, please remove the existing callback and then add"
|
" registered, please remove the existing callback and then add"
|
||||||
" this callback");
|
" this callback");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (IsolateGroupReloadContext::file_modified_callback() == NULL) {
|
if (IsolateGroupReloadContext::file_modified_callback() == NULL) {
|
||||||
return strdup(
|
return Utils::StrDup(
|
||||||
"Dart_SetFileModifiedCallback expects 'file_modified_callback' to"
|
"Dart_SetFileModifiedCallback expects 'file_modified_callback' to"
|
||||||
" be set before it is cleared.");
|
" be set before it is cleared.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -6917,7 +6917,8 @@ static void UnreachableFinalizer(void* isolate_callback_data,
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(DartAPI_PostCObject_DoesNotRunFinalizerOnFailure) {
|
TEST_CASE(DartAPI_PostCObject_DoesNotRunFinalizerOnFailure) {
|
||||||
char* my_str = strdup("Ownership of this memory remains with the caller");
|
char* my_str =
|
||||||
|
Utils::StrDup("Ownership of this memory remains with the caller");
|
||||||
|
|
||||||
Dart_CObject message;
|
Dart_CObject message;
|
||||||
message.type = Dart_CObject_kExternalTypedData;
|
message.type = Dart_CObject_kExternalTypedData;
|
||||||
|
|
|
@ -291,7 +291,7 @@ bool Flags::SetFlagFromString(Flag* flag, const char* argument) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Flag::kString: {
|
case Flag::kString: {
|
||||||
*flag->charp_ptr_ = argument == NULL ? NULL : strdup(argument);
|
*flag->charp_ptr_ = argument == NULL ? NULL : Utils::StrDup(argument);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Flag::kInteger: {
|
case Flag::kInteger: {
|
||||||
|
@ -423,7 +423,7 @@ int Flags::CompareFlagNames(const void* left, const void* right) {
|
||||||
char* Flags::ProcessCommandLineFlags(int number_of_vm_flags,
|
char* Flags::ProcessCommandLineFlags(int number_of_vm_flags,
|
||||||
const char** vm_flags) {
|
const char** vm_flags) {
|
||||||
if (initialized_) {
|
if (initialized_) {
|
||||||
return strdup("Flags already set");
|
return Utils::StrDup("Flags already set");
|
||||||
}
|
}
|
||||||
|
|
||||||
qsort(flags_, num_flags_, sizeof flags_[0], CompareFlagNames);
|
qsort(flags_, num_flags_, sizeof flags_[0], CompareFlagNames);
|
||||||
|
|
|
@ -649,7 +649,7 @@ class MergeIsolatesHeapsHandler : public MessageHandler {
|
||||||
if (response_obj.IsString()) {
|
if (response_obj.IsString()) {
|
||||||
String& response = String::Handle();
|
String& response = String::Handle();
|
||||||
response ^= response_obj.raw();
|
response ^= response_obj.raw();
|
||||||
msg_.reset(strdup(response.ToCString()));
|
msg_.reset(Utils::StrDup(response.ToCString()));
|
||||||
} else {
|
} else {
|
||||||
ASSERT(response_obj.IsArray());
|
ASSERT(response_obj.IsArray());
|
||||||
Array& response_array = Array::Handle();
|
Array& response_array = Array::Handle();
|
||||||
|
@ -657,7 +657,7 @@ class MergeIsolatesHeapsHandler : public MessageHandler {
|
||||||
ASSERT(response_array.Length() == 1);
|
ASSERT(response_array.Length() == 1);
|
||||||
ExternalTypedData& response = ExternalTypedData::Handle();
|
ExternalTypedData& response = ExternalTypedData::Handle();
|
||||||
response ^= response_array.At(0);
|
response ^= response_array.At(0);
|
||||||
msg_.reset(strdup(reinterpret_cast<char*>(response.DataAddr(0))));
|
msg_.reset(Utils::StrDup(reinterpret_cast<char*>(response.DataAddr(0))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return kOK;
|
return kOK;
|
||||||
|
|
|
@ -1508,11 +1508,11 @@ void Isolate::FlagsCopyFrom(const Dart_IsolateFlags& api_flags) {
|
||||||
embedder_entry_points_ = new Dart_QualifiedFunctionName[count + 1];
|
embedder_entry_points_ = new Dart_QualifiedFunctionName[count + 1];
|
||||||
for (intptr_t i = 0; i < count; i++) {
|
for (intptr_t i = 0; i < count; i++) {
|
||||||
embedder_entry_points_[i].library_uri =
|
embedder_entry_points_[i].library_uri =
|
||||||
strdup(api_flags.entry_points[i].library_uri);
|
Utils::StrDup(api_flags.entry_points[i].library_uri);
|
||||||
embedder_entry_points_[i].class_name =
|
embedder_entry_points_[i].class_name =
|
||||||
strdup(api_flags.entry_points[i].class_name);
|
Utils::StrDup(api_flags.entry_points[i].class_name);
|
||||||
embedder_entry_points_[i].function_name =
|
embedder_entry_points_[i].function_name =
|
||||||
strdup(api_flags.entry_points[i].function_name);
|
Utils::StrDup(api_flags.entry_points[i].function_name);
|
||||||
}
|
}
|
||||||
memset(&embedder_entry_points_[count], 0,
|
memset(&embedder_entry_points_[count], 0,
|
||||||
sizeof(Dart_QualifiedFunctionName));
|
sizeof(Dart_QualifiedFunctionName));
|
||||||
|
@ -1830,7 +1830,7 @@ void Isolate::ScheduleInterrupts(uword interrupt_bits) {
|
||||||
|
|
||||||
void Isolate::set_name(const char* name) {
|
void Isolate::set_name(const char* name) {
|
||||||
free(name_);
|
free(name_);
|
||||||
name_ = strdup(name);
|
name_ = Utils::StrDup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t IsolateGroup::UptimeMicros() const {
|
int64_t IsolateGroup::UptimeMicros() const {
|
||||||
|
@ -1884,7 +1884,7 @@ void Isolate::BuildName(const char* name_prefix) {
|
||||||
if (name_prefix == nullptr) {
|
if (name_prefix == nullptr) {
|
||||||
name_ = OS::SCreate(nullptr, "isolate-%" Pd64 "", main_port());
|
name_ = OS::SCreate(nullptr, "isolate-%" Pd64 "", main_port());
|
||||||
} else {
|
} else {
|
||||||
name_ = strdup(name_prefix);
|
name_ = Utils::StrDup(name_prefix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -192,7 +192,7 @@ class IsolateGroupSource {
|
||||||
intptr_t kernel_buffer_size,
|
intptr_t kernel_buffer_size,
|
||||||
Dart_IsolateFlags flags)
|
Dart_IsolateFlags flags)
|
||||||
: script_uri(script_uri),
|
: script_uri(script_uri),
|
||||||
name(strdup(name)),
|
name(Utils::StrDup(name)),
|
||||||
snapshot_data(snapshot_data),
|
snapshot_data(snapshot_data),
|
||||||
snapshot_instructions(snapshot_instructions),
|
snapshot_instructions(snapshot_instructions),
|
||||||
kernel_buffer(kernel_buffer),
|
kernel_buffer(kernel_buffer),
|
||||||
|
|
|
@ -409,10 +409,10 @@ MallocGrowableArray<char*>* KernelIsolate::experimental_flags_ =
|
||||||
|
|
||||||
void KernelIsolate::AddExperimentalFlag(const char* value) {
|
void KernelIsolate::AddExperimentalFlag(const char* value) {
|
||||||
char* save_ptr; // Needed for strtok_r.
|
char* save_ptr; // Needed for strtok_r.
|
||||||
char* temp = strdup(value);
|
char* temp = Utils::StrDup(value);
|
||||||
char* token = strtok_r(temp, ",", &save_ptr);
|
char* token = strtok_r(temp, ",", &save_ptr);
|
||||||
while (token != NULL) {
|
while (token != NULL) {
|
||||||
experimental_flags_->Add(strdup(token));
|
experimental_flags_->Add(Utils::StrDup(token));
|
||||||
token = strtok_r(NULL, ",", &save_ptr);
|
token = strtok_r(NULL, ",", &save_ptr);
|
||||||
}
|
}
|
||||||
free(temp);
|
free(temp);
|
||||||
|
@ -928,7 +928,7 @@ class KernelCompilationRequest : public ValueObject {
|
||||||
}
|
}
|
||||||
// This is an error.
|
// This is an error.
|
||||||
ASSERT(response[1]->type == Dart_CObject_kString);
|
ASSERT(response[1]->type == Dart_CObject_kString);
|
||||||
result_.error = strdup(response[1]->value.as_string);
|
result_.error = Utils::StrDup(response[1]->value.as_string);
|
||||||
}
|
}
|
||||||
ml.Notify();
|
ml.Notify();
|
||||||
}
|
}
|
||||||
|
@ -1007,7 +1007,7 @@ Dart_KernelCompilationResult KernelIsolate::CompileToKernel(
|
||||||
if (!Start()) {
|
if (!Start()) {
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Error while starting Kernel isolate task");
|
result.error = Utils::StrDup("Error while starting Kernel isolate task");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1017,7 +1017,7 @@ Dart_KernelCompilationResult KernelIsolate::CompileToKernel(
|
||||||
if (kernel_port == ILLEGAL_PORT) {
|
if (kernel_port == ILLEGAL_PORT) {
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Error while initializing Kernel isolate");
|
result.error = Utils::StrDup("Error while initializing Kernel isolate");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1036,7 +1036,7 @@ bool KernelIsolate::DetectNullSafety(const char* script_uri,
|
||||||
if (!Start()) {
|
if (!Start()) {
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Error while starting Kernel isolate task");
|
result.error = Utils::StrDup("Error while starting Kernel isolate task");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Wait for Kernel isolate to finish initialization.
|
// Wait for Kernel isolate to finish initialization.
|
||||||
|
@ -1044,7 +1044,7 @@ bool KernelIsolate::DetectNullSafety(const char* script_uri,
|
||||||
if (kernel_port == ILLEGAL_PORT) {
|
if (kernel_port == ILLEGAL_PORT) {
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Error while initializing Kernel isolate");
|
result.error = Utils::StrDup("Error while initializing Kernel isolate");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
KernelCompilationRequest request;
|
KernelCompilationRequest request;
|
||||||
|
@ -1060,7 +1060,7 @@ Dart_KernelCompilationResult KernelIsolate::ListDependencies() {
|
||||||
if (kernel_port == ILLEGAL_PORT) {
|
if (kernel_port == ILLEGAL_PORT) {
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Error while initializing Kernel isolate");
|
result.error = Utils::StrDup("Error while initializing Kernel isolate");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1077,7 +1077,7 @@ Dart_KernelCompilationResult KernelIsolate::AcceptCompilation() {
|
||||||
if (kernel_port == ILLEGAL_PORT) {
|
if (kernel_port == ILLEGAL_PORT) {
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Error while initializing Kernel isolate");
|
result.error = Utils::StrDup("Error while initializing Kernel isolate");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1098,7 +1098,7 @@ Dart_KernelCompilationResult KernelIsolate::CompileExpressionToKernel(
|
||||||
if (kernel_port == ILLEGAL_PORT) {
|
if (kernel_port == ILLEGAL_PORT) {
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Error while initializing Kernel isolate");
|
result.error = Utils::StrDup("Error while initializing Kernel isolate");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1119,7 +1119,7 @@ Dart_KernelCompilationResult KernelIsolate::UpdateInMemorySources(
|
||||||
if (kernel_port == ILLEGAL_PORT) {
|
if (kernel_port == ILLEGAL_PORT) {
|
||||||
Dart_KernelCompilationResult result = {};
|
Dart_KernelCompilationResult result = {};
|
||||||
result.status = Dart_KernelCompilationStatus_Unknown;
|
result.status = Dart_KernelCompilationStatus_Unknown;
|
||||||
result.error = strdup("Error while initializing Kernel isolate");
|
result.error = Utils::StrDup("Error while initializing Kernel isolate");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
namespace dart {
|
namespace dart {
|
||||||
|
|
||||||
static uint8_t* AllocMsg(const char* str) {
|
static uint8_t* AllocMsg(const char* str) {
|
||||||
return reinterpret_cast<uint8_t*>(strdup(str));
|
return reinterpret_cast<uint8_t*>(Utils::StrDup(str));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE(MessageQueue_BasicOperations) {
|
TEST_CASE(MessageQueue_BasicOperations) {
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "include/dart_native_api.h"
|
#include "include/dart_native_api.h"
|
||||||
|
|
||||||
#include "platform/assert.h"
|
#include "platform/assert.h"
|
||||||
|
#include "platform/utils.h"
|
||||||
#include "vm/dart_api_impl.h"
|
#include "vm/dart_api_impl.h"
|
||||||
#include "vm/dart_api_message.h"
|
#include "vm/dart_api_message.h"
|
||||||
#include "vm/dart_api_state.h"
|
#include "vm/dart_api_state.h"
|
||||||
|
@ -141,7 +142,7 @@ DART_EXPORT bool Dart_InvokeVMServiceMethod(uint8_t* request_json,
|
||||||
::Dart_NewNativePort("service-rpc", &Utils::HandleResponse, false);
|
::Dart_NewNativePort("service-rpc", &Utils::HandleResponse, false);
|
||||||
if (port == ILLEGAL_PORT) {
|
if (port == ILLEGAL_PORT) {
|
||||||
if (error != nullptr) {
|
if (error != nullptr) {
|
||||||
*error = strdup("Was unable to create native port.");
|
*error = ::dart::Utils::StrDup("Was unable to create native port.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -179,7 +180,7 @@ DART_EXPORT bool Dart_InvokeVMServiceMethod(uint8_t* request_json,
|
||||||
}
|
}
|
||||||
#else // !defined(PRODUCT)
|
#else // !defined(PRODUCT)
|
||||||
if (error != nullptr) {
|
if (error != nullptr) {
|
||||||
*error = strdup("VM Service is not supoorted in PRODUCT mode.");
|
*error = Utils::StrDup("VM Service is not supported in PRODUCT mode.");
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
#endif // !defined(PRODUCT)
|
#endif // !defined(PRODUCT)
|
||||||
|
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#include "vm/native_message_handler.h"
|
#include "vm/native_message_handler.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#include "vm/dart_api_message.h"
|
#include "vm/dart_api_message.h"
|
||||||
#include "vm/isolate.h"
|
#include "vm/isolate.h"
|
||||||
#include "vm/message.h"
|
#include "vm/message.h"
|
||||||
|
@ -13,7 +15,7 @@ namespace dart {
|
||||||
|
|
||||||
NativeMessageHandler::NativeMessageHandler(const char* name,
|
NativeMessageHandler::NativeMessageHandler(const char* name,
|
||||||
Dart_NativeMessageHandler func)
|
Dart_NativeMessageHandler func)
|
||||||
: name_(strdup(name)), func_(func) {}
|
: name_(Utils::StrDup(name)), func_(func) {}
|
||||||
|
|
||||||
NativeMessageHandler::~NativeMessageHandler() {
|
NativeMessageHandler::~NativeMessageHandler() {
|
||||||
free(name_);
|
free(name_);
|
||||||
|
|
|
@ -75,7 +75,7 @@ char* NativeSymbolResolver::LookupSymbolName(uword pc, uword* start) {
|
||||||
if (start != NULL) {
|
if (start != NULL) {
|
||||||
*start = pc - displacement;
|
*start = pc - displacement;
|
||||||
}
|
}
|
||||||
return strdup(pSymbol->Name);
|
return Utils::StrDup(pSymbol->Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativeSymbolResolver::FreeSymbolName(char* name) {
|
void NativeSymbolResolver::FreeSymbolName(char* name) {
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "platform/atomic.h"
|
#include "platform/atomic.h"
|
||||||
#include "platform/globals.h"
|
#include "platform/globals.h"
|
||||||
#include "platform/safe_stack.h"
|
#include "platform/safe_stack.h"
|
||||||
|
#include "platform/utils.h"
|
||||||
#include "vm/allocation.h"
|
#include "vm/allocation.h"
|
||||||
#include "vm/globals.h"
|
#include "vm/globals.h"
|
||||||
|
|
||||||
|
@ -113,7 +114,7 @@ class OSThread : public BaseThread {
|
||||||
ASSERT(OSThread::Current() == this);
|
ASSERT(OSThread::Current() == this);
|
||||||
ASSERT(name_ == NULL);
|
ASSERT(name_ == NULL);
|
||||||
ASSERT(name != NULL);
|
ASSERT(name != NULL);
|
||||||
name_ = strdup(name);
|
name_ = Utils::StrDup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
Mutex* timeline_block_lock() const { return &timeline_block_lock_; }
|
Mutex* timeline_block_lock() const { return &timeline_block_lock_; }
|
||||||
|
|
|
@ -134,7 +134,7 @@ TEST_CASE(PortMap_PostMessage) {
|
||||||
intptr_t message_len = strlen(message) + 1;
|
intptr_t message_len = strlen(message) + 1;
|
||||||
|
|
||||||
EXPECT(PortMap::PostMessage(
|
EXPECT(PortMap::PostMessage(
|
||||||
Message::New(port, reinterpret_cast<uint8_t*>(strdup(message)),
|
Message::New(port, reinterpret_cast<uint8_t*>(Utils::StrDup(message)),
|
||||||
message_len, nullptr, Message::kNormalPriority)));
|
message_len, nullptr, Message::kNormalPriority)));
|
||||||
|
|
||||||
// Check that the message notify callback was called.
|
// Check that the message notify callback was called.
|
||||||
|
@ -178,7 +178,7 @@ TEST_CASE(PortMap_PostMessageClosedPort) {
|
||||||
intptr_t message_len = strlen(message) + 1;
|
intptr_t message_len = strlen(message) + 1;
|
||||||
|
|
||||||
EXPECT(!PortMap::PostMessage(
|
EXPECT(!PortMap::PostMessage(
|
||||||
Message::New(port, reinterpret_cast<uint8_t*>(strdup(message)),
|
Message::New(port, reinterpret_cast<uint8_t*>(Utils::StrDup(message)),
|
||||||
message_len, nullptr, Message::kNormalPriority)));
|
message_len, nullptr, Message::kNormalPriority)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -768,8 +768,9 @@ void IRRegExpMacroAssembler::CheckNotAtStart(intptr_t cp_offset,
|
||||||
auto neg_len_def =
|
auto neg_len_def =
|
||||||
Bind(InstanceCall(InstanceCallDescriptor::FromToken(Token::kNEGATE),
|
Bind(InstanceCall(InstanceCallDescriptor::FromToken(Token::kNEGATE),
|
||||||
PushLocal(string_param_length_)));
|
PushLocal(string_param_length_)));
|
||||||
auto offset_def =
|
auto current_pos_def = PushLocal(current_position_);
|
||||||
Bind(Add(PushLocal(current_position_), Bind(Int64Constant(cp_offset))));
|
auto cp_offset_def = Bind(Int64Constant(cp_offset));
|
||||||
|
auto offset_def = Bind(Add(current_pos_def, cp_offset_def));
|
||||||
BranchOrBacktrack(Comparison(kNE, neg_len_def, offset_def), on_not_at_start);
|
BranchOrBacktrack(Comparison(kNE, neg_len_def, offset_def), on_not_at_start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1201,7 +1201,7 @@ class EmbedderServiceHandler {
|
||||||
explicit EmbedderServiceHandler(const char* name)
|
explicit EmbedderServiceHandler(const char* name)
|
||||||
: name_(NULL), callback_(NULL), user_data_(NULL), next_(NULL) {
|
: name_(NULL), callback_(NULL), user_data_(NULL), next_(NULL) {
|
||||||
ASSERT(name != NULL);
|
ASSERT(name != NULL);
|
||||||
name_ = strdup(name);
|
name_ = Utils::StrDup(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
~EmbedderServiceHandler() { free(name_); }
|
~EmbedderServiceHandler() { free(name_); }
|
||||||
|
@ -4653,7 +4653,7 @@ static const MethodParameter* set_vm_name_params[] = {
|
||||||
static bool SetVMName(Thread* thread, JSONStream* js) {
|
static bool SetVMName(Thread* thread, JSONStream* js) {
|
||||||
const char* name_param = js->LookupParam("name");
|
const char* name_param = js->LookupParam("name");
|
||||||
free(vm_name);
|
free(vm_name);
|
||||||
vm_name = strdup(name_param);
|
vm_name = Utils::StrDup(name_param);
|
||||||
if (Service::vm_stream.enabled()) {
|
if (Service::vm_stream.enabled()) {
|
||||||
ServiceEvent event(NULL, ServiceEvent::kVMUpdate);
|
ServiceEvent event(NULL, ServiceEvent::kVMUpdate);
|
||||||
Service::HandleEvent(&event);
|
Service::HandleEvent(&event);
|
||||||
|
|
|
@ -110,7 +110,7 @@ void ServiceIsolate::SetServerAddress(const char* address) {
|
||||||
if (address == NULL) {
|
if (address == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
server_address_ = strdup(address);
|
server_address_ = Utils::StrDup(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ServiceIsolate::NameEquals(const char* name) {
|
bool ServiceIsolate::NameEquals(const char* name) {
|
||||||
|
@ -192,10 +192,10 @@ bool ServiceIsolate::SendServiceRpc(uint8_t* request_json,
|
||||||
"Service isolate failed to start up: %s.",
|
"Service isolate failed to start up: %s.",
|
||||||
startup_failure_reason_);
|
startup_failure_reason_);
|
||||||
} else {
|
} else {
|
||||||
*error = strdup("No service isolate port was found.");
|
*error = Utils::StrDup("No service isolate port was found.");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
*error = strdup("Was unable to post message to service isolate.");
|
*error = Utils::StrDup("Was unable to post message to service isolate.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ void ServiceIsolate::Run() {
|
||||||
create_group_callback_ = Isolate::CreateGroupCallback();
|
create_group_callback_ = Isolate::CreateGroupCallback();
|
||||||
if (create_group_callback_ == NULL) {
|
if (create_group_callback_ == NULL) {
|
||||||
ServiceIsolate::InitializingFailed(
|
ServiceIsolate::InitializingFailed(
|
||||||
strdup("The 'create_group' callback was not provided"));
|
Utils::StrDup("The 'create_group' callback was not provided"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
bool task_started = Dart::thread_pool()->Run<RunServiceTask>();
|
bool task_started = Dart::thread_pool()->Run<RunServiceTask>();
|
||||||
|
|
|
@ -55,7 +55,7 @@ class ServiceTestMessageHandler : public MessageHandler {
|
||||||
if (response_obj.IsString()) {
|
if (response_obj.IsString()) {
|
||||||
String& response = String::Handle();
|
String& response = String::Handle();
|
||||||
response ^= response_obj.raw();
|
response ^= response_obj.raw();
|
||||||
_msg = strdup(response.ToCString());
|
_msg = Utils::StrDup(response.ToCString());
|
||||||
} else {
|
} else {
|
||||||
ASSERT(response_obj.IsArray());
|
ASSERT(response_obj.IsArray());
|
||||||
Array& response_array = Array::Handle();
|
Array& response_array = Array::Handle();
|
||||||
|
@ -63,7 +63,7 @@ class ServiceTestMessageHandler : public MessageHandler {
|
||||||
ASSERT(response_array.Length() == 1);
|
ASSERT(response_array.Length() == 1);
|
||||||
ExternalTypedData& response = ExternalTypedData::Handle();
|
ExternalTypedData& response = ExternalTypedData::Handle();
|
||||||
response ^= response_array.At(0);
|
response ^= response_array.At(0);
|
||||||
_msg = strdup(reinterpret_cast<char*>(response.DataAddr(0)));
|
_msg = Utils::StrDup(reinterpret_cast<char*>(response.DataAddr(0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return kOK;
|
return kOK;
|
||||||
|
@ -567,7 +567,7 @@ static bool alpha_callback(const char* name,
|
||||||
intptr_t num_options,
|
intptr_t num_options,
|
||||||
void* user_data,
|
void* user_data,
|
||||||
const char** result) {
|
const char** result) {
|
||||||
*result = strdup("alpha");
|
*result = Utils::StrDup("alpha");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -577,7 +577,7 @@ static bool beta_callback(const char* name,
|
||||||
intptr_t num_options,
|
intptr_t num_options,
|
||||||
void* user_data,
|
void* user_data,
|
||||||
const char** result) {
|
const char** result) {
|
||||||
*result = strdup("beta");
|
*result = Utils::StrDup("beta");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,10 +166,10 @@ static MallocGrowableArray<char*>* GetEnabledByDefaultTimelineStreams() {
|
||||||
}
|
}
|
||||||
char* save_ptr; // Needed for strtok_r.
|
char* save_ptr; // Needed for strtok_r.
|
||||||
// strtok modifies arg 1 so we make a copy of it.
|
// strtok modifies arg 1 so we make a copy of it.
|
||||||
char* streams = strdup(FLAG_timeline_streams);
|
char* streams = Utils::StrDup(FLAG_timeline_streams);
|
||||||
char* token = strtok_r(streams, ",", &save_ptr);
|
char* token = strtok_r(streams, ",", &save_ptr);
|
||||||
while (token != NULL) {
|
while (token != NULL) {
|
||||||
result->Add(strdup(token));
|
result->Add(Utils::StrDup(token));
|
||||||
token = strtok_r(NULL, ",", &save_ptr);
|
token = strtok_r(NULL, ",", &save_ptr);
|
||||||
}
|
}
|
||||||
free(streams);
|
free(streams);
|
||||||
|
@ -347,7 +347,7 @@ void TimelineEventArguments::SetArgument(intptr_t i,
|
||||||
void TimelineEventArguments::CopyArgument(intptr_t i,
|
void TimelineEventArguments::CopyArgument(intptr_t i,
|
||||||
const char* name,
|
const char* name,
|
||||||
const char* argument) {
|
const char* argument) {
|
||||||
SetArgument(i, name, strdup(argument));
|
SetArgument(i, name, Utils::StrDup(argument));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimelineEventArguments::FormatArgument(intptr_t i,
|
void TimelineEventArguments::FormatArgument(intptr_t i,
|
||||||
|
|
10
tools/gn.py
10
tools/gn.py
|
@ -119,12 +119,6 @@ def ParseStringMap(key, string_map):
|
||||||
return l[1]
|
return l[1]
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def DontUseClang(args, target_os, host_cpu, target_cpu):
|
|
||||||
# We don't have clang on Windows.
|
|
||||||
return target_os == 'win'
|
|
||||||
|
|
||||||
|
|
||||||
def UseSysroot(args, gn_args):
|
def UseSysroot(args, gn_args):
|
||||||
# Don't try to use a Linux sysroot if we aren't on Linux.
|
# Don't try to use a Linux sysroot if we aren't on Linux.
|
||||||
if gn_args['target_os'] != 'linux' and HOST_OS != 'linux':
|
if gn_args['target_os'] != 'linux' and HOST_OS != 'linux':
|
||||||
|
@ -209,9 +203,7 @@ def ToGnArgs(args, mode, arch, target_os, sanitizer):
|
||||||
|
|
||||||
gn_args['exclude_kernel_service'] = args.exclude_kernel_service
|
gn_args['exclude_kernel_service'] = args.exclude_kernel_service
|
||||||
|
|
||||||
dont_use_clang = DontUseClang(args, gn_args['target_os'],
|
gn_args['is_clang'] = args.clang
|
||||||
gn_args['host_cpu'], gn_args['target_cpu'])
|
|
||||||
gn_args['is_clang'] = args.clang and not dont_use_clang
|
|
||||||
|
|
||||||
enable_code_coverage = args.code_coverage and gn_args['is_clang']
|
enable_code_coverage = args.code_coverage and gn_args['is_clang']
|
||||||
gn_args['dart_vm_code_coverage'] = enable_code_coverage
|
gn_args['dart_vm_code_coverage'] = enable_code_coverage
|
||||||
|
|
Loading…
Reference in a new issue