[fuchsia] Fixes for the Fuchsia build

Makes public some include paths needed for the dart_runner to depend on
dart_io.

Also updates some dart:io implementations to give and OSError
instead of crashing when something is unimplemented.

Change-Id: I862fc7cc43f56e74de791ecc021b88238b54a8e5
Reviewed-on: https://dart-review.googlesource.com/c/84920
Reviewed-by: Ryan Macnak <rmacnak@google.com>
Commit-Queue: Zach Anderson <zra@google.com>
This commit is contained in:
Zach Anderson 2018-11-26 16:30:33 +00:00 committed by commit-bot@chromium.org
parent 10dac37103
commit 3ad0571cf9
9 changed files with 83 additions and 65 deletions

View file

@ -7,7 +7,10 @@ import("configs.gni")
import("runtime_args.gni")
config("dart_public_config") {
include_dirs = [ "include" ]
include_dirs = [
".",
"include",
]
}
# Adds PRODUCT define if Flutter has specified "release" for dart_runtime_mode

View file

@ -340,6 +340,9 @@ template("dart_io") {
"..:dart_config",
"..:dart_os_config",
] + extra_configs
public_configs = [
"..:dart_public_config",
]
if (is_fuchsia) {
configs -= [ "//build/config:symbol_visibility_hidden" ]
}

View file

@ -76,12 +76,31 @@ bool File::IsClosed() {
}
MappedMemory* File::Map(MapType type, int64_t position, int64_t length) {
UNIMPLEMENTED();
return NULL;
ASSERT(handle_->fd() >= 0);
ASSERT(length > 0);
int prot = PROT_NONE;
switch (type) {
case kReadOnly:
prot = PROT_READ;
break;
case kReadExecute:
prot = PROT_READ | PROT_EXEC;
break;
default:
return NULL;
}
void* addr = mmap(NULL, length, prot, MAP_PRIVATE, handle_->fd(), position);
if (addr == MAP_FAILED) {
return NULL;
}
return new MappedMemory(addr, length);
}
void MappedMemory::Unmap() {
UNIMPLEMENTED();
int result = munmap(address_, size_);
ASSERT(result == 0);
address_ = 0;
size_ = 0;
}
int64_t File::Read(void* buffer, int64_t num_bytes) {

View file

@ -7,16 +7,18 @@
#include "bin/file_system_watcher.h"
#include <errno.h>
namespace dart {
namespace bin {
Dart_Handle FileSystemWatcher::ReadEvents(intptr_t id, intptr_t path_id) {
UNIMPLEMENTED();
errno = ENOSYS;
return DartUtils::NewDartOSError();
}
intptr_t FileSystemWatcher::GetSocketId(intptr_t id, intptr_t path_id) {
UNIMPLEMENTED();
errno = ENOSYS;
return -1;
}
@ -25,7 +27,6 @@ bool FileSystemWatcher::IsSupported() {
}
void FileSystemWatcher::UnwatchPath(intptr_t id, intptr_t path_id) {
UNIMPLEMENTED();
}
intptr_t FileSystemWatcher::Init() {
@ -33,7 +34,6 @@ intptr_t FileSystemWatcher::Init() {
}
void FileSystemWatcher::Close(intptr_t id) {
UNIMPLEMENTED();
}
intptr_t FileSystemWatcher::WatchPath(intptr_t id,
@ -41,7 +41,7 @@ intptr_t FileSystemWatcher::WatchPath(intptr_t id,
const char* path,
int events,
bool recursive) {
UNIMPLEMENTED();
errno = ENOSYS;
return -1;
}

View file

@ -176,7 +176,7 @@ class ExitCodeHandler {
static zx_status_t Add(zx_handle_t process) {
MonitorLocker locker(monitor_);
LOG_INFO("ExitCodeHandler Adding Process: %ld\n", process);
LOG_INFO("ExitCodeHandler Adding Process: %u\n", process);
return zx_object_wait_async(process, port_, static_cast<uint64_t>(process),
ZX_TASK_TERMINATED, ZX_WAIT_ASYNC_ONCE);
}
@ -230,7 +230,7 @@ class ExitCodeHandler {
zx_handle_t process = static_cast<zx_handle_t>(pkt.key);
zx_signals_t observed = pkt.signal.observed;
if ((observed & ZX_TASK_TERMINATED) == ZX_SIGNAL_NONE) {
LOG_ERR("ExitCodeHandler: Unexpected signals, process %ld: %lx\n",
LOG_ERR("ExitCodeHandler: Unexpected signals, process %u: %ux\n",
process, observed);
}
SendProcessStatus(process);
@ -242,7 +242,7 @@ class ExitCodeHandler {
}
static void SendProcessStatus(zx_handle_t process) {
LOG_INFO("ExitCodeHandler thread getting process status: %ld\n", process);
LOG_INFO("ExitCodeHandler thread getting process status: %u\n", process);
int return_code = -1;
zx_info_process_t proc_info;
zx_status_t status = zx_object_get_info(
@ -254,11 +254,11 @@ class ExitCodeHandler {
return_code = proc_info.return_code;
}
zx_handle_close(process);
LOG_INFO("ExitCodeHandler thread process %ld exited with %d\n", process,
LOG_INFO("ExitCodeHandler thread process %u exited with %d\n", process,
return_code);
const intptr_t exit_code_fd = ProcessInfoList::LookupProcessExitFd(process);
LOG_INFO("ExitCodeHandler thread sending %ld code %d on fd %ld\n", process,
LOG_INFO("ExitCodeHandler thread sending %u code %d on fd %ld\n", process,
return_code, exit_code_fd);
if (exit_code_fd != 0) {
int exit_message[2];
@ -274,11 +274,11 @@ class ExitCodeHandler {
}
LOG_INFO("ExitCodeHandler thread wrote %ld bytes to fd %ld\n", result,
exit_code_fd);
LOG_INFO("ExitCodeHandler thread removing process %ld from list\n",
LOG_INFO("ExitCodeHandler thread removing process %u from list\n",
process);
ProcessInfoList::RemoveProcess(process);
} else {
LOG_ERR("ExitCodeHandler: Process %ld not found\n", process);
LOG_ERR("ExitCodeHandler: Process %u not found\n", process);
}
}
@ -616,7 +616,8 @@ class ProcessStarter {
uint32_t flags = FDIO_SPAWN_CLONE_JOB | FDIO_SPAWN_CLONE_LDSVC |
FDIO_SPAWN_CLONE_NAMESPACE;
status = fdio_spawn_vmo(ZX_HANDLE_INVALID, flags, vmo, program_arguments_,
program_environment_, 4, actions, &process, err_msg);
program_environment_, 4, actions, &process,
err_msg);
if (status != ZX_OK) {
LOG_ERR("ProcessStarter: Start() fdio_spawn_vmo failed\n");
@ -626,7 +627,7 @@ class ProcessStarter {
return status;
}
LOG_INFO("ProcessStarter: Start() adding %ld to list with exit_pipe %d\n",
LOG_INFO("ProcessStarter: Start() adding %u to list with exit_pipe %d\n",
process, exit_pipe_fds[1]);
ProcessInfoList::AddProcess(process, exit_pipe_fds[1]);
ExitCodeHandler::Start();

View file

@ -118,8 +118,7 @@ intptr_t SocketBase::RecvFrom(intptr_t fd,
intptr_t num_bytes,
RawAddr* addr,
SocketOpKind sync) {
LOG_ERR("SocketBase::RecvFrom is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return -1;
}
@ -152,8 +151,7 @@ intptr_t SocketBase::SendTo(intptr_t fd,
intptr_t num_bytes,
const RawAddr& addr,
SocketOpKind sync) {
LOG_ERR("SocketBase::SendTo is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return -1;
}
@ -182,19 +180,16 @@ SocketAddress* SocketBase::GetRemotePeer(intptr_t fd, intptr_t* port) {
}
void SocketBase::GetError(intptr_t fd, OSError* os_error) {
LOG_ERR("SocketBase::GetError is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
os_error->SetCodeAndMessage(OSError::kSystem, errno);
}
int SocketBase::GetType(intptr_t fd) {
LOG_ERR("SocketBase::GetType is unimplemented\n");
UNIMPLEMENTED();
return File::kOther;
errno = ENOSYS;
return -1;
}
intptr_t SocketBase::GetStdioHandle(intptr_t num) {
LOG_ERR("SocketBase::GetStdioHandle is unimplemented\n");
UNIMPLEMENTED();
return num;
}
@ -246,8 +241,7 @@ bool SocketBase::ReverseLookup(const RawAddr& addr,
char* host,
intptr_t host_len,
OSError** os_error) {
LOG_ERR("SocketBase::ReverseLookup is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
@ -335,8 +329,7 @@ void SocketBase::Close(intptr_t fd) {
}
bool SocketBase::GetNoDelay(intptr_t fd, bool* enabled) {
LOG_ERR("SocketBase::GetNoDelay is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
@ -351,40 +344,34 @@ bool SocketBase::SetNoDelay(intptr_t fd, bool enabled) {
bool SocketBase::GetMulticastLoop(intptr_t fd,
intptr_t protocol,
bool* enabled) {
LOG_ERR("SocketBase::GetMulticastLoop is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool SocketBase::SetMulticastLoop(intptr_t fd,
intptr_t protocol,
bool enabled) {
LOG_ERR("SocketBase::SetMulticastLoop is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool SocketBase::GetMulticastHops(intptr_t fd, intptr_t protocol, int* value) {
LOG_ERR("SocketBase::GetMulticastHops is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool SocketBase::SetMulticastHops(intptr_t fd, intptr_t protocol, int value) {
LOG_ERR("SocketBase::SetMulticastHops is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool SocketBase::GetBroadcast(intptr_t fd, bool* enabled) {
LOG_ERR("SocketBase::GetBroadcast is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool SocketBase::SetBroadcast(intptr_t fd, bool enabled) {
LOG_ERR("SocketBase::SetBroadcast is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
@ -392,8 +379,7 @@ bool SocketBase::JoinMulticast(intptr_t fd,
const RawAddr& addr,
const RawAddr&,
int interfaceIndex) {
LOG_ERR("SocketBase::JoinMulticast is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
@ -401,8 +387,7 @@ bool SocketBase::LeaveMulticast(intptr_t fd,
const RawAddr& addr,
const RawAddr&,
int interfaceIndex) {
LOG_ERR("SocketBase::LeaveMulticast is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}

View file

@ -104,8 +104,7 @@ intptr_t Socket::CreateConnect(const RawAddr& addr) {
intptr_t Socket::CreateBindConnect(const RawAddr& addr,
const RawAddr& source_addr) {
LOG_ERR("SocketBase::CreateBindConnect is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return -1;
}
@ -113,8 +112,7 @@ intptr_t Socket::CreateBindDatagram(const RawAddr& addr,
bool reuseAddress,
bool reusePort,
int ttl) {
LOG_ERR("SocketBase::CreateBindDatagram is unimplemented\n");
UNIMPLEMENTED();
errno = ENOSYS;
return -1;
}

View file

@ -7,47 +7,56 @@
#include "bin/stdio.h"
#include <errno.h>
#include "platform/signal_blocker.h"
namespace dart {
namespace bin {
bool Stdin::ReadByte(intptr_t fd, int* byte) {
UNIMPLEMENTED();
return false;
unsigned char b;
ssize_t s = TEMP_FAILURE_RETRY(read(fd, &b, 1));
if (s < 0) {
return false;
}
*byte = (s == 0) ? -1 : b;
return true;
}
bool Stdin::GetEchoMode(intptr_t fd, bool* enabled) {
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool Stdin::SetEchoMode(intptr_t fd, bool enabled) {
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool Stdin::GetLineMode(intptr_t fd, bool* enabled) {
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool Stdin::SetLineMode(intptr_t fd, bool enabled) {
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool Stdin::AnsiSupported(intptr_t fd, bool* supported) {
UNIMPLEMENTED();
return false;
*supported = false;
return true;
}
bool Stdout::GetTerminalSize(intptr_t fd, int size[2]) {
UNIMPLEMENTED();
errno = ENOSYS;
return false;
}
bool Stdout::AnsiSupported(intptr_t fd, bool* supported) {
UNIMPLEMENTED();
return false;
*supported = false;
return true;
}
} // namespace bin

View file

@ -269,7 +269,7 @@ void OS::Abort() {
}
void OS::Exit(int code) {
UNIMPLEMENTED();
exit(code);
}
} // namespace dart