Rename Magenta to Zircon, along with related abbreviations
Change-Id: Ic4215ceb00f5a60d21ec1398fd398a9f78a9eb94 Reviewed-on: https://dart-review.googlesource.com/6100 Reviewed-by: Zach Anderson <zra@google.com>
This commit is contained in:
committed by
Zach Anderson
parent
303e06be4c
commit
7800d2a995
@@ -166,22 +166,22 @@ if (is_fuchsia) {
|
||||
mkbootfs_gen = get_label_info("//packages/gn:mkbootfs", "target_gen_dir")
|
||||
boot_manifest = "$mkbootfs_gen/boot.bootfs.manifest"
|
||||
|
||||
# Compute path to magenta bootdata.bin
|
||||
# Compute path to zircon bootdata.bin
|
||||
if (current_cpu == "arm64") {
|
||||
magenta_bootdata =
|
||||
"//out/build-magenta/build-magenta-qemu-arm64/bootdata.bin"
|
||||
zircon_bootdata =
|
||||
"//out/build-zircon/build-zircon-qemu-arm64/bootdata.bin"
|
||||
} else if (current_cpu == "x64") {
|
||||
magenta_bootdata =
|
||||
"//out/build-magenta/build-magenta-pc-x86-64/bootdata.bin"
|
||||
zircon_bootdata =
|
||||
"//out/build-zircon/build-zircon-pc-x86-64/bootdata.bin"
|
||||
} else {
|
||||
assert(false, "unable to determine path to magenta's bootdata.bin")
|
||||
assert(false, "unable to determine path to zircon's bootdata.bin")
|
||||
}
|
||||
|
||||
packages_file = "$mkbootfs_gen/packages"
|
||||
|
||||
input = "$target_gen_dir/dart_test_tree.manifest"
|
||||
inputs = [
|
||||
magenta_bootdata,
|
||||
zircon_bootdata,
|
||||
input,
|
||||
]
|
||||
|
||||
@@ -201,7 +201,7 @@ if (is_fuchsia) {
|
||||
"--build-id-map",
|
||||
rebase_path("$target_gen_dir/build_id_map"),
|
||||
"--pre-binaries",
|
||||
rebase_path(magenta_bootdata),
|
||||
rebase_path(zircon_bootdata),
|
||||
]
|
||||
args += read_file(packages_file, "list lines")
|
||||
}
|
||||
|
||||
+2
-2
@@ -110,8 +110,8 @@ config("dart_config") {
|
||||
if (is_fuchsia) {
|
||||
defines += [ "DART_USE_JEMALLOC" ]
|
||||
include_dirs += [
|
||||
"//magenta/system/ulib/mx/include",
|
||||
"//magenta/third_party/ulib/jemalloc/include",
|
||||
"//zircon/system/ulib/zx/include",
|
||||
"//zircon/third_party/ulib/jemalloc/include",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "bin/crypto.h"
|
||||
|
||||
#include <magenta/syscalls.h>
|
||||
#include <zircon/syscalls.h>
|
||||
|
||||
namespace dart {
|
||||
namespace bin {
|
||||
@@ -17,10 +17,10 @@ bool Crypto::GetRandomBytes(intptr_t count, uint8_t* buffer) {
|
||||
while (read < count) {
|
||||
const intptr_t remaining = count - read;
|
||||
const intptr_t len =
|
||||
(MX_CPRNG_DRAW_MAX_LEN < remaining) ? MX_CPRNG_DRAW_MAX_LEN : remaining;
|
||||
(ZX_CPRNG_DRAW_MAX_LEN < remaining) ? ZX_CPRNG_DRAW_MAX_LEN : remaining;
|
||||
size_t res = 0;
|
||||
const mx_status_t status = mx_cprng_draw(buffer + read, len, &res);
|
||||
if (status != MX_OK) {
|
||||
const zx_status_t status = zx_cprng_draw(buffer + read, len, &res);
|
||||
if (status != ZX_OK) {
|
||||
return false;
|
||||
}
|
||||
read += res;
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <dirent.h> // NOLINT
|
||||
#include <errno.h> // NOLINT
|
||||
#include <fcntl.h> // NOLINT
|
||||
#include <mxio/namespace.h> // NOLINT
|
||||
#include <fdio/namespace.h> // NOLINT
|
||||
#include <stdlib.h> // NOLINT
|
||||
#include <string.h> // NOLINT
|
||||
#include <sys/param.h> // NOLINT
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <magenta/status.h>
|
||||
#include <magenta/syscalls.h>
|
||||
#include <magenta/syscalls/object.h>
|
||||
#include <magenta/syscalls/port.h>
|
||||
#include <mxio/private.h>
|
||||
#include <zircon/status.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <zircon/syscalls/object.h>
|
||||
#include <zircon/syscalls/port.h>
|
||||
#include <fdio/private.h>
|
||||
#include <poll.h>
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
@@ -33,20 +33,20 @@
|
||||
#include "platform/utils.h"
|
||||
|
||||
// The EventHandler for Fuchsia uses its "ports v2" API:
|
||||
// https://fuchsia.googlesource.com/magenta/+/HEAD/docs/syscalls/port_create.md
|
||||
// https://fuchsia.googlesource.com/zircon/+/HEAD/docs/syscalls/port_create.md
|
||||
// This API does not have epoll()-like edge triggering (EPOLLET). Since clients
|
||||
// of the EventHandler expect edge-triggered notifications, we must simulate it.
|
||||
// When a packet from mx_port_wait() indicates that a signal is asserted for a
|
||||
// When a packet from zx_port_wait() indicates that a signal is asserted for a
|
||||
// handle, we unsubscribe from that signal until the event that asserted the
|
||||
// signal can be processed. For example:
|
||||
//
|
||||
// 1. We get MX_SOCKET_WRITABLE from mx_port_wait() for a handle.
|
||||
// 1. We get ZX_SOCKET_WRITABLE from zx_port_wait() for a handle.
|
||||
// 2. We send kOutEvent to the Dart thread.
|
||||
// 3. We unsubscribe from further MX_SOCKET_WRITABLE signals for the handle.
|
||||
// 3. We unsubscribe from further ZX_SOCKET_WRITABLE signals for the handle.
|
||||
// 4. Some time later the Dart thread actually does a write().
|
||||
// 5. After writing, the Dart thread resubscribes to write events.
|
||||
//
|
||||
// We use he same procedure for MX_SOCKET_READABLE, and read()/accept().
|
||||
// We use he same procedure for ZX_SOCKET_READABLE, and read()/accept().
|
||||
|
||||
// define EVENTHANDLER_LOG_ERROR to get log messages only for errors.
|
||||
// define EVENTHANDLER_LOG_INFO to get log messages for both information and
|
||||
@@ -87,7 +87,7 @@ intptr_t IOHandle::Read(void* buffer, intptr_t num_bytes) {
|
||||
// re-subscription is necessary. Logic in the caller decides which errors are
|
||||
// real, and which are ignore-and-continue.
|
||||
read_events_enabled_ = true;
|
||||
if (!AsyncWaitLocked(MX_HANDLE_INVALID, POLLIN, wait_key_)) {
|
||||
if (!AsyncWaitLocked(ZX_HANDLE_INVALID, POLLIN, wait_key_)) {
|
||||
LOG_ERR("IOHandle::AsyncWait failed for fd = %ld\n", fd_);
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ intptr_t IOHandle::Write(const void* buffer, intptr_t num_bytes) {
|
||||
|
||||
// Resubscribe to write events.
|
||||
write_events_enabled_ = true;
|
||||
if (!AsyncWaitLocked(MX_HANDLE_INVALID, POLLOUT, wait_key_)) {
|
||||
if (!AsyncWaitLocked(ZX_HANDLE_INVALID, POLLOUT, wait_key_)) {
|
||||
LOG_ERR("IOHandle::AsyncWait failed for fd = %ld\n", fd_);
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ intptr_t IOHandle::Accept(struct sockaddr* addr, socklen_t* addrlen) {
|
||||
|
||||
// Re-subscribe to read events.
|
||||
read_events_enabled_ = true;
|
||||
if (!AsyncWaitLocked(MX_HANDLE_INVALID, POLLIN, wait_key_)) {
|
||||
if (!AsyncWaitLocked(ZX_HANDLE_INVALID, POLLIN, wait_key_)) {
|
||||
LOG_ERR("IOHandle::AsyncWait failed for fd = %ld\n", fd_);
|
||||
}
|
||||
|
||||
@@ -165,65 +165,65 @@ intptr_t IOHandle::EpollEventsToMask(intptr_t events) {
|
||||
return event_mask;
|
||||
}
|
||||
|
||||
bool IOHandle::AsyncWaitLocked(mx_handle_t port,
|
||||
bool IOHandle::AsyncWaitLocked(zx_handle_t port,
|
||||
uint32_t events,
|
||||
uint64_t key) {
|
||||
LOG_INFO("IOHandle::AsyncWait: fd = %ld\n", fd_);
|
||||
// The call to __mxio_fd_to_io() in the DescriptorInfo constructor may have
|
||||
// The call to __fdio_fd_to_io() in the DescriptorInfo constructor may have
|
||||
// returned NULL. If it did, propagate the problem up to Dart.
|
||||
if (mxio_ == NULL) {
|
||||
LOG_ERR("__mxio_fd_to_io(%d) returned NULL\n", fd_);
|
||||
if (fdio_ == NULL) {
|
||||
LOG_ERR("__fdio_fd_to_io(%d) returned NULL\n", fd_);
|
||||
return false;
|
||||
}
|
||||
|
||||
mx_handle_t handle;
|
||||
mx_signals_t signals;
|
||||
__mxio_wait_begin(mxio_, events, &handle, &signals);
|
||||
if (handle == MX_HANDLE_INVALID) {
|
||||
LOG_ERR("fd = %ld __mxio_wait_begin returned an invalid handle\n", fd_);
|
||||
zx_handle_t handle;
|
||||
zx_signals_t signals;
|
||||
__fdio_wait_begin(fdio_, events, &handle, &signals);
|
||||
if (handle == ZX_HANDLE_INVALID) {
|
||||
LOG_ERR("fd = %ld __fdio_wait_begin returned an invalid handle\n", fd_);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remember the port. Use the remembered port if the argument "port" is
|
||||
// MX_HANDLE_INVALID.
|
||||
ASSERT((port != MX_HANDLE_INVALID) || (port_ != MX_HANDLE_INVALID));
|
||||
if ((port_ == MX_HANDLE_INVALID) || (port != MX_HANDLE_INVALID)) {
|
||||
// ZX_HANDLE_INVALID.
|
||||
ASSERT((port != ZX_HANDLE_INVALID) || (port_ != ZX_HANDLE_INVALID));
|
||||
if ((port_ == ZX_HANDLE_INVALID) || (port != ZX_HANDLE_INVALID)) {
|
||||
port_ = port;
|
||||
}
|
||||
|
||||
handle_ = handle;
|
||||
wait_key_ = key;
|
||||
LOG_INFO("mx_object_wait_async(fd = %ld, signals = %x)\n", fd_, signals);
|
||||
mx_status_t status =
|
||||
mx_object_wait_async(handle_, port_, key, signals, MX_WAIT_ASYNC_ONCE);
|
||||
if (status != MX_OK) {
|
||||
LOG_ERR("mx_object_wait_async failed: %s\n", mx_status_get_string(status));
|
||||
LOG_INFO("zx_object_wait_async(fd = %ld, signals = %x)\n", fd_, signals);
|
||||
zx_status_t status =
|
||||
zx_object_wait_async(handle_, port_, key, signals, ZX_WAIT_ASYNC_ONCE);
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("zx_object_wait_async failed: %s\n", zx_status_get_string(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool IOHandle::AsyncWait(mx_handle_t port, uint32_t events, uint64_t key) {
|
||||
bool IOHandle::AsyncWait(zx_handle_t port, uint32_t events, uint64_t key) {
|
||||
MutexLocker ml(mutex_);
|
||||
return AsyncWaitLocked(port, events, key);
|
||||
}
|
||||
|
||||
void IOHandle::CancelWait(mx_handle_t port, uint64_t key) {
|
||||
void IOHandle::CancelWait(zx_handle_t port, uint64_t key) {
|
||||
MutexLocker ml(mutex_);
|
||||
LOG_INFO("IOHandle::CancelWait: fd = %ld\n", fd_);
|
||||
ASSERT(port != MX_HANDLE_INVALID);
|
||||
ASSERT(handle_ != MX_HANDLE_INVALID);
|
||||
mx_status_t status = mx_port_cancel(port, handle_, key);
|
||||
if ((status != MX_OK) && (status != MX_ERR_NOT_FOUND)) {
|
||||
LOG_ERR("mx_port_cancel failed: %s\n", mx_status_get_string(status));
|
||||
ASSERT(port != ZX_HANDLE_INVALID);
|
||||
ASSERT(handle_ != ZX_HANDLE_INVALID);
|
||||
zx_status_t status = zx_port_cancel(port, handle_, key);
|
||||
if ((status != ZX_OK) && (status != ZX_ERR_NOT_FOUND)) {
|
||||
LOG_ERR("zx_port_cancel failed: %s\n", zx_status_get_string(status));
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t IOHandle::WaitEnd(mx_signals_t observed) {
|
||||
uint32_t IOHandle::WaitEnd(zx_signals_t observed) {
|
||||
MutexLocker ml(mutex_);
|
||||
uint32_t events = 0;
|
||||
__mxio_wait_end(mxio_, observed, &events);
|
||||
__fdio_wait_end(fdio_, observed, &events);
|
||||
return events;
|
||||
}
|
||||
|
||||
@@ -250,7 +250,7 @@ intptr_t IOHandle::ToggleEvents(intptr_t event_mask) {
|
||||
return event_mask;
|
||||
}
|
||||
|
||||
void EventHandlerImplementation::AddToPort(mx_handle_t port_handle,
|
||||
void EventHandlerImplementation::AddToPort(zx_handle_t port_handle,
|
||||
DescriptorInfo* di) {
|
||||
const uint32_t events = di->io_handle()->MaskToEpollEvents(di->Mask());
|
||||
const uint64_t key = reinterpret_cast<uint64_t>(di);
|
||||
@@ -259,7 +259,7 @@ void EventHandlerImplementation::AddToPort(mx_handle_t port_handle,
|
||||
}
|
||||
}
|
||||
|
||||
void EventHandlerImplementation::RemoveFromPort(mx_handle_t port_handle,
|
||||
void EventHandlerImplementation::RemoveFromPort(zx_handle_t port_handle,
|
||||
DescriptorInfo* di) {
|
||||
const uint64_t key = reinterpret_cast<uint64_t>(di);
|
||||
di->io_handle()->CancelWait(port_handle, key);
|
||||
@@ -269,14 +269,14 @@ EventHandlerImplementation::EventHandlerImplementation()
|
||||
: socket_map_(&HashMap::SamePointerValue, 16) {
|
||||
shutdown_ = false;
|
||||
// Create the port.
|
||||
port_handle_ = MX_HANDLE_INVALID;
|
||||
mx_status_t status = mx_port_create(0, &port_handle_);
|
||||
if (status != MX_OK) {
|
||||
port_handle_ = ZX_HANDLE_INVALID;
|
||||
zx_status_t status = zx_port_create(0, &port_handle_);
|
||||
if (status != ZX_OK) {
|
||||
// This is a FATAL because the VM won't work at all if we can't create this
|
||||
// port.
|
||||
FATAL1("mx_port_create failed: %s\n", mx_status_get_string(status));
|
||||
FATAL1("zx_port_create failed: %s\n", zx_status_get_string(status));
|
||||
}
|
||||
ASSERT(port_handle_ != MX_HANDLE_INVALID);
|
||||
ASSERT(port_handle_ != ZX_HANDLE_INVALID);
|
||||
}
|
||||
|
||||
static void DeleteDescriptorInfo(void* info) {
|
||||
@@ -288,8 +288,8 @@ static void DeleteDescriptorInfo(void* info) {
|
||||
|
||||
EventHandlerImplementation::~EventHandlerImplementation() {
|
||||
socket_map_.Clear(DeleteDescriptorInfo);
|
||||
mx_handle_close(port_handle_);
|
||||
port_handle_ = MX_HANDLE_INVALID;
|
||||
zx_handle_close(port_handle_);
|
||||
port_handle_ = ZX_HANDLE_INVALID;
|
||||
}
|
||||
|
||||
void EventHandlerImplementation::UpdatePort(intptr_t old_mask,
|
||||
@@ -333,19 +333,19 @@ DescriptorInfo* EventHandlerImplementation::GetDescriptorInfo(
|
||||
void EventHandlerImplementation::WakeupHandler(intptr_t id,
|
||||
Dart_Port dart_port,
|
||||
int64_t data) {
|
||||
COMPILE_ASSERT(sizeof(InterruptMessage) <= sizeof(mx_packet_user_t));
|
||||
mx_port_packet_t pkt;
|
||||
COMPILE_ASSERT(sizeof(InterruptMessage) <= sizeof(zx_packet_user_t));
|
||||
zx_port_packet_t pkt;
|
||||
InterruptMessage* msg = reinterpret_cast<InterruptMessage*>(&pkt.user);
|
||||
pkt.key = kInterruptPacketKey;
|
||||
msg->id = id;
|
||||
msg->dart_port = dart_port;
|
||||
msg->data = data;
|
||||
mx_status_t status =
|
||||
mx_port_queue(port_handle_, reinterpret_cast<void*>(&pkt), 0);
|
||||
if (status != MX_OK) {
|
||||
zx_status_t status =
|
||||
zx_port_queue(port_handle_, reinterpret_cast<void*>(&pkt), 0);
|
||||
if (status != ZX_OK) {
|
||||
// This is a FATAL because the VM won't work at all if we can't send any
|
||||
// messages to the EventHandler thread.
|
||||
FATAL1("mx_port_queue failed: %s\n", mx_status_get_string(status));
|
||||
FATAL1("zx_port_queue failed: %s\n", zx_status_get_string(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -440,11 +440,11 @@ void EventHandlerImplementation::HandleInterrupt(InterruptMessage* msg) {
|
||||
}
|
||||
}
|
||||
|
||||
void EventHandlerImplementation::HandlePacket(mx_port_packet_t* pkt) {
|
||||
void EventHandlerImplementation::HandlePacket(zx_port_packet_t* pkt) {
|
||||
LOG_INFO("HandlePacket: Got event packet: key=%lx\n", pkt->key);
|
||||
LOG_INFO("HandlePacket: Got event packet: type=%lx\n", pkt->type);
|
||||
LOG_INFO("HandlePacket: Got event packet: status=%ld\n", pkt->status);
|
||||
if (pkt->type == MX_PKT_TYPE_USER) {
|
||||
if (pkt->type == ZX_PKT_TYPE_USER) {
|
||||
ASSERT(pkt->key == kInterruptPacketKey);
|
||||
InterruptMessage* msg = reinterpret_cast<InterruptMessage*>(&pkt->user);
|
||||
HandleInterrupt(msg);
|
||||
@@ -455,7 +455,7 @@ void EventHandlerImplementation::HandlePacket(mx_port_packet_t* pkt) {
|
||||
LOG_INFO("HandlePacket: Got event packet: count = %ld\n", pkt->signal.count);
|
||||
|
||||
DescriptorInfo* di = reinterpret_cast<DescriptorInfo*>(pkt->key);
|
||||
mx_signals_t observed = pkt->signal.observed;
|
||||
zx_signals_t observed = pkt->signal.observed;
|
||||
const intptr_t old_mask = di->Mask();
|
||||
const uint32_t epoll_event = di->io_handle()->WaitEnd(observed);
|
||||
intptr_t event_mask = IOHandle::EpollEventsToMask(epoll_event);
|
||||
@@ -502,21 +502,21 @@ void EventHandlerImplementation::Poll(uword args) {
|
||||
EventHandlerImplementation* handler_impl = &handler->delegate_;
|
||||
ASSERT(handler_impl != NULL);
|
||||
|
||||
mx_port_packet_t pkt;
|
||||
zx_port_packet_t pkt;
|
||||
while (!handler_impl->shutdown_) {
|
||||
int64_t millis = handler_impl->GetTimeout();
|
||||
ASSERT((millis == kInfinityTimeout) || (millis >= 0));
|
||||
|
||||
LOG_INFO("mx_port_wait(millis = %ld)\n", millis);
|
||||
mx_status_t status = mx_port_wait(handler_impl->port_handle_,
|
||||
LOG_INFO("zx_port_wait(millis = %ld)\n", millis);
|
||||
zx_status_t status = zx_port_wait(handler_impl->port_handle_,
|
||||
millis == kInfinityTimeout
|
||||
? MX_TIME_INFINITE
|
||||
: mx_deadline_after(MX_MSEC(millis)),
|
||||
? ZX_TIME_INFINITE
|
||||
: zx_deadline_after(ZX_MSEC(millis)),
|
||||
reinterpret_cast<void*>(&pkt), 0);
|
||||
if (status == MX_ERR_TIMED_OUT) {
|
||||
if (status == ZX_ERR_TIMED_OUT) {
|
||||
handler_impl->HandleTimeout();
|
||||
} else if (status != MX_OK) {
|
||||
FATAL1("mx_port_wait failed: %s\n", mx_status_get_string(status));
|
||||
} else if (status != ZX_OK) {
|
||||
FATAL1("zx_port_wait failed: %s\n", zx_status_get_string(status));
|
||||
} else {
|
||||
handler_impl->HandleTimeout();
|
||||
handler_impl->HandlePacket(&pkt);
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#endif
|
||||
|
||||
#include <errno.h>
|
||||
#include <magenta/status.h>
|
||||
#include <magenta/syscalls.h>
|
||||
#include <magenta/syscalls/object.h>
|
||||
#include <magenta/syscalls/port.h>
|
||||
#include <mxio/private.h>
|
||||
#include <zircon/status.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <zircon/syscalls/object.h>
|
||||
#include <zircon/syscalls/port.h>
|
||||
#include <fdio/private.h>
|
||||
#include <sys/socket.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -35,9 +35,9 @@ class IOHandle : public ReferenceCounted<IOHandle> {
|
||||
write_events_enabled_(true),
|
||||
read_events_enabled_(true),
|
||||
fd_(fd),
|
||||
handle_(MX_HANDLE_INVALID),
|
||||
handle_(ZX_HANDLE_INVALID),
|
||||
wait_key_(0),
|
||||
mxio_(__mxio_fd_to_io(fd)) {}
|
||||
fdio_(__fdio_fd_to_io(fd)) {}
|
||||
|
||||
intptr_t fd() const { return fd_; }
|
||||
|
||||
@@ -50,24 +50,24 @@ class IOHandle : public ReferenceCounted<IOHandle> {
|
||||
// Called from the EventHandler thread.
|
||||
void Close();
|
||||
uint32_t MaskToEpollEvents(intptr_t mask);
|
||||
// If port is MX_HANDLE_INVALID, AsyncWait uses the port from the previous
|
||||
// If port is ZX_HANDLE_INVALID, AsyncWait uses the port from the previous
|
||||
// call with a valid port handle.
|
||||
bool AsyncWait(mx_handle_t port, uint32_t events, uint64_t key);
|
||||
void CancelWait(mx_handle_t port, uint64_t key);
|
||||
uint32_t WaitEnd(mx_signals_t observed);
|
||||
bool AsyncWait(zx_handle_t port, uint32_t events, uint64_t key);
|
||||
void CancelWait(zx_handle_t port, uint64_t key);
|
||||
uint32_t WaitEnd(zx_signals_t observed);
|
||||
intptr_t ToggleEvents(intptr_t event_mask);
|
||||
|
||||
static intptr_t EpollEventsToMask(intptr_t events);
|
||||
|
||||
private:
|
||||
~IOHandle() {
|
||||
if (mxio_ != NULL) {
|
||||
__mxio_release(mxio_);
|
||||
if (fdio_ != NULL) {
|
||||
__fdio_release(fdio_);
|
||||
}
|
||||
delete mutex_;
|
||||
}
|
||||
|
||||
bool AsyncWaitLocked(mx_handle_t port, uint32_t events, uint64_t key);
|
||||
bool AsyncWaitLocked(zx_handle_t port, uint32_t events, uint64_t key);
|
||||
|
||||
// Mutex that protects the state here.
|
||||
Mutex* mutex_;
|
||||
@@ -75,10 +75,10 @@ class IOHandle : public ReferenceCounted<IOHandle> {
|
||||
bool read_events_enabled_;
|
||||
// TODO(zra): Add flag to enable/disable peer closed signal?
|
||||
intptr_t fd_;
|
||||
mx_handle_t handle_;
|
||||
mx_handle_t port_;
|
||||
zx_handle_t handle_;
|
||||
zx_handle_t port_;
|
||||
uint64_t wait_key_;
|
||||
mxio_t* mxio_;
|
||||
fdio_t* fdio_;
|
||||
|
||||
friend class ReferenceCounted<IOHandle>;
|
||||
DISALLOW_COPY_AND_ASSIGN(IOHandle);
|
||||
@@ -148,11 +148,11 @@ class EventHandlerImplementation {
|
||||
static void Poll(uword args);
|
||||
static void* GetHashmapKeyFromFd(intptr_t fd);
|
||||
static uint32_t GetHashmapHashFromFd(intptr_t fd);
|
||||
static void AddToPort(mx_handle_t port_handle, DescriptorInfo* di);
|
||||
static void RemoveFromPort(mx_handle_t port_handle, DescriptorInfo* di);
|
||||
static void AddToPort(zx_handle_t port_handle, DescriptorInfo* di);
|
||||
static void RemoveFromPort(zx_handle_t port_handle, DescriptorInfo* di);
|
||||
|
||||
int64_t GetTimeout() const;
|
||||
void HandlePacket(mx_port_packet_t* pkt);
|
||||
void HandlePacket(zx_port_packet_t* pkt);
|
||||
void HandleTimeout();
|
||||
void WakeupHandler(intptr_t id, Dart_Port dart_port, int64_t data);
|
||||
intptr_t GetPollEvents(intptr_t events);
|
||||
@@ -161,7 +161,7 @@ class EventHandlerImplementation {
|
||||
HashMap socket_map_;
|
||||
TimeoutQueue timeout_queue_;
|
||||
bool shutdown_;
|
||||
mx_handle_t port_handle_;
|
||||
zx_handle_t port_handle_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(EventHandlerImplementation);
|
||||
};
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include <dlfcn.h>
|
||||
#include <fcntl.h>
|
||||
#include <launchpad/vmo.h>
|
||||
#include <magenta/dlfcn.h>
|
||||
#include <mxio/io.h>
|
||||
#include <zircon/dlfcn.h>
|
||||
#include <fdio/io.h>
|
||||
|
||||
#include "platform/assert.h"
|
||||
|
||||
@@ -29,10 +29,10 @@ void* Extensions::LoadExtensionLibrary(const char* library_file) {
|
||||
if (fd < 0) {
|
||||
return NULL;
|
||||
}
|
||||
mx_handle_t vmo;
|
||||
mx_status_t status = mxio_get_vmo(fd, &vmo);
|
||||
zx_handle_t vmo;
|
||||
zx_status_t status = fdio_get_vmo(fd, &vmo);
|
||||
close(fd);
|
||||
if (status != MX_OK) {
|
||||
if (status != ZX_OK) {
|
||||
return NULL;
|
||||
}
|
||||
return dlopen_vmo(vmo, RTLD_LAZY);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <errno.h> // NOLINT
|
||||
#include <fcntl.h> // NOLINT
|
||||
#include <libgen.h> // NOLINT
|
||||
#include <mxio/namespace.h> // NOLINT
|
||||
#include <fdio/namespace.h> // NOLINT
|
||||
#include <sys/mman.h> // NOLINT
|
||||
#include <sys/stat.h> // NOLINT
|
||||
#include <sys/types.h> // NOLINT
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <mxio/namespace.h>
|
||||
#include <fdio/namespace.h>
|
||||
|
||||
#include "bin/fdutils.h"
|
||||
#include "bin/file.h"
|
||||
@@ -25,9 +25,9 @@ Namespace* Namespace::Create(const char* path) {
|
||||
|
||||
Namespace::~Namespace() {
|
||||
if (namespc_ != kNone) {
|
||||
mxio_ns_t* ns = reinterpret_cast<mxio_ns_t*>(namespc_);
|
||||
mx_status_t status = mxio_ns_destroy(ns);
|
||||
ASSERT(status == MX_OK);
|
||||
fdio_ns_t* ns = reinterpret_cast<fdio_ns_t*>(namespc_);
|
||||
zx_status_t status = fdio_ns_destroy(ns);
|
||||
ASSERT(status == ZX_OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,8 @@ bool Namespace::ResolvePath(Namespace* namespc,
|
||||
*resolved_path = path;
|
||||
return false;
|
||||
}
|
||||
mxio_ns_t* ns = reinterpret_cast<mxio_ns_t*>(namespc->namespc());
|
||||
*dirfd = mxio_ns_opendir(ns);
|
||||
fdio_ns_t* ns = reinterpret_cast<fdio_ns_t*>(namespc->namespc());
|
||||
*dirfd = fdio_ns_opendir(ns);
|
||||
ASSERT(*dirfd >= 0);
|
||||
if (File::IsAbsolutePath(path)) {
|
||||
if (strcmp(path, File::PathSeparator()) == 0) {
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
#include "bin/platform.h"
|
||||
|
||||
#include <magenta/process.h>
|
||||
#include <magenta/status.h>
|
||||
#include <magenta/syscalls.h>
|
||||
#include <zircon/process.h>
|
||||
#include <zircon/status.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <string.h>
|
||||
#include <sys/utsname.h>
|
||||
#include <unistd.h>
|
||||
@@ -101,10 +101,10 @@ const char* Platform::GetExecutableName() {
|
||||
if (executable_name_ != NULL) {
|
||||
return executable_name_;
|
||||
}
|
||||
char* name = DartUtils::ScopedCString(MX_MAX_NAME_LEN);
|
||||
mx_status_t status = mx_object_get_property(mx_process_self(), MX_PROP_NAME,
|
||||
name, MX_MAX_NAME_LEN);
|
||||
if (status != MX_OK) {
|
||||
char* name = DartUtils::ScopedCString(ZX_MAX_NAME_LEN);
|
||||
zx_status_t status = zx_object_get_property(zx_process_self(), ZX_PROP_NAME,
|
||||
name, ZX_MAX_NAME_LEN);
|
||||
if (status != ZX_OK) {
|
||||
return NULL;
|
||||
}
|
||||
return name;
|
||||
|
||||
@@ -11,15 +11,15 @@
|
||||
#include <fcntl.h>
|
||||
#include <launchpad/launchpad.h>
|
||||
#include <launchpad/vmo.h>
|
||||
#include <magenta/process.h>
|
||||
#include <magenta/status.h>
|
||||
#include <magenta/syscalls.h>
|
||||
#include <magenta/syscalls/object.h>
|
||||
#include <magenta/types.h>
|
||||
#include <mxio/io.h>
|
||||
#include <mxio/namespace.h>
|
||||
#include <mxio/private.h>
|
||||
#include <mxio/util.h>
|
||||
#include <zircon/process.h>
|
||||
#include <zircon/status.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <zircon/syscalls/object.h>
|
||||
#include <zircon/types.h>
|
||||
#include <fdio/io.h>
|
||||
#include <fdio/namespace.h>
|
||||
#include <fdio/private.h>
|
||||
#include <fdio/util.h>
|
||||
#include <poll.h>
|
||||
#include <pthread.h>
|
||||
#include <stdbool.h>
|
||||
@@ -60,22 +60,22 @@ Process::ExitHook Process::exit_hook_ = NULL;
|
||||
// ProcessInfoList.
|
||||
class ProcessInfo {
|
||||
public:
|
||||
ProcessInfo(mx_handle_t process, intptr_t fd)
|
||||
ProcessInfo(zx_handle_t process, intptr_t fd)
|
||||
: process_(process), exit_pipe_fd_(fd) {}
|
||||
~ProcessInfo() {
|
||||
int closed = NO_RETRY_EXPECTED(close(exit_pipe_fd_));
|
||||
if (closed != 0) {
|
||||
LOG_ERR("Failed to close process exit code pipe");
|
||||
}
|
||||
mx_handle_close(process_);
|
||||
zx_handle_close(process_);
|
||||
}
|
||||
mx_handle_t process() const { return process_; }
|
||||
zx_handle_t process() const { return process_; }
|
||||
intptr_t exit_pipe_fd() const { return exit_pipe_fd_; }
|
||||
ProcessInfo* next() const { return next_; }
|
||||
void set_next(ProcessInfo* info) { next_ = info; }
|
||||
|
||||
private:
|
||||
mx_handle_t process_;
|
||||
zx_handle_t process_;
|
||||
intptr_t exit_pipe_fd_;
|
||||
ProcessInfo* next_;
|
||||
|
||||
@@ -86,14 +86,14 @@ class ProcessInfo {
|
||||
// started from Dart.
|
||||
class ProcessInfoList {
|
||||
public:
|
||||
static void AddProcess(mx_handle_t process, intptr_t fd) {
|
||||
static void AddProcess(zx_handle_t process, intptr_t fd) {
|
||||
MutexLocker locker(mutex_);
|
||||
ProcessInfo* info = new ProcessInfo(process, fd);
|
||||
info->set_next(active_processes_);
|
||||
active_processes_ = info;
|
||||
}
|
||||
|
||||
static intptr_t LookupProcessExitFd(mx_handle_t process) {
|
||||
static intptr_t LookupProcessExitFd(zx_handle_t process) {
|
||||
MutexLocker locker(mutex_);
|
||||
ProcessInfo* current = active_processes_;
|
||||
while (current != NULL) {
|
||||
@@ -105,11 +105,11 @@ class ProcessInfoList {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static bool Exists(mx_handle_t process) {
|
||||
static bool Exists(zx_handle_t process) {
|
||||
return LookupProcessExitFd(process) != 0;
|
||||
}
|
||||
|
||||
static void RemoveProcess(mx_handle_t process) {
|
||||
static void RemoveProcess(zx_handle_t process) {
|
||||
MutexLocker locker(mutex_);
|
||||
ProcessInfo* prev = NULL;
|
||||
ProcessInfo* current = active_processes_;
|
||||
@@ -159,10 +159,10 @@ class ExitCodeHandler {
|
||||
}
|
||||
LOG_INFO("ExitCodeHandler Starting\n");
|
||||
|
||||
mx_status_t status = mx_port_create(0, &port_);
|
||||
if (status != MX_OK) {
|
||||
FATAL1("ExitCodeHandler: mx_port_create failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
zx_status_t status = zx_port_create(0, &port_);
|
||||
if (status != ZX_OK) {
|
||||
FATAL1("ExitCodeHandler: zx_port_create failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -175,11 +175,11 @@ class ExitCodeHandler {
|
||||
running_ = true;
|
||||
}
|
||||
|
||||
static mx_status_t Add(mx_handle_t process) {
|
||||
static zx_status_t Add(zx_handle_t process) {
|
||||
MonitorLocker locker(monitor_);
|
||||
LOG_INFO("ExitCodeHandler Adding Process: %ld\n", process);
|
||||
return mx_object_wait_async(process, port_, static_cast<uint64_t>(process),
|
||||
MX_TASK_TERMINATED, MX_WAIT_ASYNC_ONCE);
|
||||
return zx_object_wait_async(process, port_, static_cast<uint64_t>(process),
|
||||
ZX_TASK_TERMINATED, ZX_WAIT_ASYNC_ONCE);
|
||||
}
|
||||
|
||||
static void Terminate() {
|
||||
@@ -195,7 +195,7 @@ class ExitCodeHandler {
|
||||
while (!terminate_done_) {
|
||||
monitor_->Wait(Monitor::kNoTimeout);
|
||||
}
|
||||
mx_handle_close(port_);
|
||||
zx_handle_close(port_);
|
||||
LOG_INFO("ExitCodeHandler Terminated\n");
|
||||
}
|
||||
|
||||
@@ -203,12 +203,12 @@ class ExitCodeHandler {
|
||||
static const uint64_t kShutdownPacketKey = 1;
|
||||
|
||||
static void SendShutdownMessage() {
|
||||
mx_port_packet_t pkt;
|
||||
zx_port_packet_t pkt;
|
||||
pkt.key = kShutdownPacketKey;
|
||||
mx_status_t status = mx_port_queue(port_, reinterpret_cast<void*>(&pkt), 0);
|
||||
if (status != MX_OK) {
|
||||
Log::PrintErr("ExitCodeHandler: mx_port_queue failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
zx_status_t status = zx_port_queue(port_, reinterpret_cast<void*>(&pkt), 0);
|
||||
if (status != ZX_OK) {
|
||||
Log::PrintErr("ExitCodeHandler: zx_port_queue failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,21 +217,21 @@ class ExitCodeHandler {
|
||||
static void ExitCodeHandlerEntry(uword param) {
|
||||
LOG_INFO("ExitCodeHandler Entering ExitCodeHandler thread\n");
|
||||
|
||||
mx_port_packet_t pkt;
|
||||
zx_port_packet_t pkt;
|
||||
while (true) {
|
||||
mx_status_t status = mx_port_wait(port_, MX_TIME_INFINITE,
|
||||
zx_status_t status = zx_port_wait(port_, ZX_TIME_INFINITE,
|
||||
reinterpret_cast<void*>(&pkt), 0);
|
||||
if (status != MX_OK) {
|
||||
FATAL1("ExitCodeHandler: mx_port_wait failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
if (status != ZX_OK) {
|
||||
FATAL1("ExitCodeHandler: zx_port_wait failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
}
|
||||
if (pkt.type == MX_PKT_TYPE_USER) {
|
||||
if (pkt.type == ZX_PKT_TYPE_USER) {
|
||||
ASSERT(pkt.key == kShutdownPacketKey);
|
||||
break;
|
||||
}
|
||||
mx_handle_t process = static_cast<mx_handle_t>(pkt.key);
|
||||
mx_signals_t observed = pkt.signal.observed;
|
||||
if ((observed & MX_TASK_TERMINATED) == MX_SIGNAL_NONE) {
|
||||
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",
|
||||
process, observed);
|
||||
}
|
||||
@@ -243,19 +243,19 @@ class ExitCodeHandler {
|
||||
monitor_->Notify();
|
||||
}
|
||||
|
||||
static void SendProcessStatus(mx_handle_t process) {
|
||||
static void SendProcessStatus(zx_handle_t process) {
|
||||
LOG_INFO("ExitCodeHandler thread getting process status: %ld\n", process);
|
||||
int return_code = -1;
|
||||
mx_info_process_t proc_info;
|
||||
mx_status_t status = mx_object_get_info(
|
||||
process, MX_INFO_PROCESS, &proc_info, sizeof(proc_info), NULL, NULL);
|
||||
if (status != MX_OK) {
|
||||
Log::PrintErr("ExitCodeHandler: mx_object_get_info failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
zx_info_process_t proc_info;
|
||||
zx_status_t status = zx_object_get_info(
|
||||
process, ZX_INFO_PROCESS, &proc_info, sizeof(proc_info), NULL, NULL);
|
||||
if (status != ZX_OK) {
|
||||
Log::PrintErr("ExitCodeHandler: zx_object_get_info failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
} else {
|
||||
return_code = proc_info.return_code;
|
||||
}
|
||||
mx_handle_close(process);
|
||||
zx_handle_close(process);
|
||||
LOG_INFO("ExitCodeHandler thread process %ld exited with %d\n", process,
|
||||
return_code);
|
||||
|
||||
@@ -284,7 +284,7 @@ class ExitCodeHandler {
|
||||
}
|
||||
}
|
||||
|
||||
static mx_handle_t port_;
|
||||
static zx_handle_t port_;
|
||||
|
||||
// Protected by monitor_.
|
||||
static bool terminate_done_;
|
||||
@@ -295,7 +295,7 @@ class ExitCodeHandler {
|
||||
DISALLOW_IMPLICIT_CONSTRUCTORS(ExitCodeHandler);
|
||||
};
|
||||
|
||||
mx_handle_t ExitCodeHandler::port_ = MX_HANDLE_INVALID;
|
||||
zx_handle_t ExitCodeHandler::port_ = ZX_HANDLE_INVALID;
|
||||
bool ExitCodeHandler::running_ = false;
|
||||
bool ExitCodeHandler::terminate_done_ = false;
|
||||
Monitor* ExitCodeHandler::monitor_ = new Monitor();
|
||||
@@ -309,11 +309,11 @@ intptr_t Process::CurrentProcessId() {
|
||||
}
|
||||
|
||||
int64_t Process::CurrentRSS() {
|
||||
mx_info_task_stats_t task_stats;
|
||||
mx_handle_t process = mx_process_self();
|
||||
mx_status_t status = mx_object_get_info(
|
||||
process, MX_INFO_TASK_STATS, &task_stats, sizeof(task_stats), NULL, NULL);
|
||||
if (status != MX_OK) {
|
||||
zx_info_task_stats_t task_stats;
|
||||
zx_handle_t process = zx_process_self();
|
||||
zx_status_t status = zx_object_get_info(
|
||||
process, ZX_INFO_TASK_STATS, &task_stats, sizeof(task_stats), NULL, NULL);
|
||||
if (status != ZX_OK) {
|
||||
// TODO(zra): Translate this to a Unix errno.
|
||||
errno = status;
|
||||
return -1;
|
||||
@@ -372,11 +372,11 @@ bool Process::Wait(intptr_t pid,
|
||||
} exit_code_data;
|
||||
|
||||
// Create a port, which is like an epoll() fd on Linux.
|
||||
mx_handle_t port;
|
||||
mx_status_t status = mx_port_create(0, &port);
|
||||
if (status != MX_OK) {
|
||||
Log::PrintErr("Process::Wait: mx_port_create failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
zx_handle_t port;
|
||||
zx_status_t status = zx_port_create(0, &port);
|
||||
if (status != ZX_OK) {
|
||||
Log::PrintErr("Process::Wait: zx_port_create failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -397,12 +397,12 @@ bool Process::Wait(intptr_t pid,
|
||||
return false;
|
||||
}
|
||||
while ((out_tmp != NULL) || (err_tmp != NULL) || (exit_tmp != NULL)) {
|
||||
mx_port_packet_t pkt;
|
||||
zx_port_packet_t pkt;
|
||||
status =
|
||||
mx_port_wait(port, MX_TIME_INFINITE, reinterpret_cast<void*>(&pkt), 0);
|
||||
if (status != MX_OK) {
|
||||
Log::PrintErr("Process::Wait: mx_port_wait failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
zx_port_wait(port, ZX_TIME_INFINITE, reinterpret_cast<void*>(&pkt), 0);
|
||||
if (status != ZX_OK) {
|
||||
Log::PrintErr("Process::Wait: zx_port_wait failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
return false;
|
||||
}
|
||||
IOHandle* event_handle = reinterpret_cast<IOHandle*>(pkt.key);
|
||||
@@ -479,30 +479,30 @@ bool Process::Wait(intptr_t pid,
|
||||
result->set_exit_code(exit_code);
|
||||
|
||||
// Close the process handle.
|
||||
mx_handle_t process = static_cast<mx_handle_t>(pid);
|
||||
mx_handle_close(process);
|
||||
zx_handle_t process = static_cast<zx_handle_t>(pid);
|
||||
zx_handle_close(process);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Process::Kill(intptr_t id, int signal) {
|
||||
LOG_INFO("Sending signal %d to process with id %ld\n", signal, id);
|
||||
// mx_task_kill is definitely going to kill the process.
|
||||
// zx_task_kill is definitely going to kill the process.
|
||||
if ((signal != SIGTERM) && (signal != SIGKILL)) {
|
||||
LOG_ERR("Signal %d not supported\n", signal);
|
||||
errno = ENOSYS;
|
||||
return false;
|
||||
}
|
||||
// We can only use mx_task_kill if we know id is a process handle, and we only
|
||||
// We can only use zx_task_kill if we know id is a process handle, and we only
|
||||
// know that for sure if it's in our list.
|
||||
mx_handle_t process = static_cast<mx_handle_t>(id);
|
||||
zx_handle_t process = static_cast<zx_handle_t>(id);
|
||||
if (!ProcessInfoList::Exists(process)) {
|
||||
LOG_ERR("Process %ld wasn't in the ProcessInfoList\n", id);
|
||||
errno = ESRCH; // No such process.
|
||||
return false;
|
||||
}
|
||||
mx_status_t status = mx_task_kill(process);
|
||||
if (status != MX_OK) {
|
||||
LOG_ERR("mx_task_kill failed: %s\n", mx_status_get_string(status));
|
||||
zx_status_t status = zx_task_kill(process);
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("zx_task_kill failed: %s\n", zx_status_get_string(status));
|
||||
errno = EPERM; // TODO(zra): Figure out what it really should be.
|
||||
return false;
|
||||
}
|
||||
@@ -589,8 +589,8 @@ class ProcessStarter {
|
||||
|
||||
// Set up a launchpad.
|
||||
launchpad_t* lp = NULL;
|
||||
mx_status_t status = SetupLaunchpad(&lp);
|
||||
if (status != MX_OK) {
|
||||
zx_status_t status = SetupLaunchpad(&lp);
|
||||
if (status != ZX_OK) {
|
||||
close(exit_pipe_fds[0]);
|
||||
close(exit_pipe_fds[1]);
|
||||
return status;
|
||||
@@ -599,11 +599,11 @@ class ProcessStarter {
|
||||
|
||||
// Launch it.
|
||||
LOG_INFO("ProcessStarter: Start() Calling launchpad_start\n");
|
||||
mx_handle_t process = MX_HANDLE_INVALID;
|
||||
zx_handle_t process = ZX_HANDLE_INVALID;
|
||||
const char* errormsg = NULL;
|
||||
status = launchpad_go(lp, &process, &errormsg);
|
||||
lp = NULL; // launchpad_go() calls launchpad_destroy() on the launchpad.
|
||||
if (status != MX_OK) {
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("ProcessStarter: Start() launchpad_start failed\n");
|
||||
close(exit_pipe_fds[0]);
|
||||
close(exit_pipe_fds[1]);
|
||||
@@ -616,14 +616,14 @@ class ProcessStarter {
|
||||
ProcessInfoList::AddProcess(process, exit_pipe_fds[1]);
|
||||
ExitCodeHandler::Start();
|
||||
status = ExitCodeHandler::Add(process);
|
||||
if (status != MX_OK) {
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("ProcessStarter: ExitCodeHandler: Add failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
zx_status_get_string(status));
|
||||
close(exit_pipe_fds[0]);
|
||||
close(exit_pipe_fds[1]);
|
||||
mx_task_kill(process);
|
||||
zx_task_kill(process);
|
||||
ProcessInfoList::RemoveProcess(process);
|
||||
ReportStartError(mx_status_get_string(status));
|
||||
ReportStartError(zx_status_get_string(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -654,15 +654,15 @@ class ProcessStarter {
|
||||
*os_error_message_ = message;
|
||||
}
|
||||
|
||||
mx_status_t SetupLaunchpad(launchpad_t** launchpad) {
|
||||
zx_status_t SetupLaunchpad(launchpad_t** launchpad) {
|
||||
// TODO(zra): Use the supplied working directory when launchpad adds an
|
||||
// API to set it.
|
||||
ASSERT(launchpad != NULL);
|
||||
launchpad_t* lp = NULL;
|
||||
launchpad_create(MX_HANDLE_INVALID, program_arguments_[0], &lp);
|
||||
launchpad_create(ZX_HANDLE_INVALID, program_arguments_[0], &lp);
|
||||
launchpad_set_args(lp, program_arguments_count_, program_arguments_);
|
||||
launchpad_set_environ(lp, program_environment_);
|
||||
launchpad_clone(lp, LP_CLONE_MXIO_NAMESPACE | LP_CLONE_MXIO_CWD);
|
||||
launchpad_clone(lp, LP_CLONE_FDIO_NAMESPACE | LP_CLONE_FDIO_CWD);
|
||||
launchpad_add_pipe(lp, &write_out_, 0);
|
||||
launchpad_add_pipe(lp, &read_in_, 1);
|
||||
launchpad_add_pipe(lp, &read_err_, 2);
|
||||
@@ -676,18 +676,18 @@ class ProcessStarter {
|
||||
|
||||
// If there were any errors, grab launchpad's error message and put it in
|
||||
// the os_error_message_ field.
|
||||
mx_status_t status = launchpad_get_status(lp);
|
||||
if (status != MX_OK) {
|
||||
zx_status_t status = launchpad_get_status(lp);
|
||||
if (status != ZX_OK) {
|
||||
const intptr_t kMaxMessageSize = 256;
|
||||
char* message = DartUtils::ScopedCString(kMaxMessageSize);
|
||||
snprintf(message, kMaxMessageSize, "launchpad failed: %s, %s",
|
||||
mx_status_get_string(status), launchpad_error_message(lp));
|
||||
zx_status_get_string(status), launchpad_error_message(lp));
|
||||
*os_error_message_ = message;
|
||||
return status;
|
||||
}
|
||||
|
||||
*launchpad = lp;
|
||||
return MX_OK;
|
||||
return ZX_OK;
|
||||
}
|
||||
|
||||
int read_in_; // Pipe for stdout to child process.
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
#if defined(HOST_OS_FUCHSIA)
|
||||
|
||||
#include <errno.h>
|
||||
#include <magenta/syscalls.h>
|
||||
#include <magenta/types.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <zircon/types.h>
|
||||
|
||||
#include "bin/utils.h"
|
||||
#include "platform/assert.h"
|
||||
@@ -81,12 +81,12 @@ int64_t TimerUtils::GetCurrentMonotonicMillis() {
|
||||
}
|
||||
|
||||
int64_t TimerUtils::GetCurrentMonotonicMicros() {
|
||||
int64_t ticks = mx_time_get(MX_CLOCK_MONOTONIC);
|
||||
int64_t ticks = zx_time_get(ZX_CLOCK_MONOTONIC);
|
||||
return ticks / kNanosecondsPerMicrosecond;
|
||||
}
|
||||
|
||||
void TimerUtils::Sleep(int64_t millis) {
|
||||
mx_nanosleep(mx_deadline_after(millis * kMicrosecondsPerMillisecond *
|
||||
zx_nanosleep(zx_deadline_after(millis * kMicrosecondsPerMillisecond *
|
||||
kNanosecondsPerMicrosecond));
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ import("vm_sources.gni")
|
||||
config("libdart_vm_config") {
|
||||
if (is_fuchsia) {
|
||||
libs = [
|
||||
"magenta",
|
||||
"zircon",
|
||||
"trace-engine",
|
||||
]
|
||||
} else if (is_win) {
|
||||
@@ -69,7 +69,7 @@ template("build_libdart_vm") {
|
||||
deps = [
|
||||
# TODO(zra): When the platform-specific timeline code is moved out to
|
||||
# the embedder, this can go away.
|
||||
"//magenta/system/ulib/fbl",
|
||||
"//zircon/system/ulib/fbl",
|
||||
]
|
||||
}
|
||||
public_configs = [ ":libdart_vm_config" ]
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#if !defined(HOST_OS_FUCHSIA)
|
||||
#include <sys/syscall.h>
|
||||
#else
|
||||
#include <magenta/syscalls.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
@@ -42,9 +42,9 @@ void CPU::FlushICache(uword start, uword size) {
|
||||
char* end = reinterpret_cast<char*>(start + size);
|
||||
::__clear_cache(beg, end);
|
||||
#elif defined(HOST_OS_FUCHSIA)
|
||||
mx_status_t result = mx_cache_flush(reinterpret_cast<const void*>(start),
|
||||
size, MX_CACHE_FLUSH_INSN);
|
||||
ASSERT(result == MX_OK);
|
||||
zx_status_t result = zx_cache_flush(reinterpret_cast<const void*>(start),
|
||||
size, ZX_CACHE_FLUSH_INSN);
|
||||
ASSERT(result == ZX_OK);
|
||||
#else
|
||||
#error FlushICache only tested/supported on Android, Fuchsia, and Linux
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
#include "vm/os.h"
|
||||
|
||||
#include <errno.h>
|
||||
#include <magenta/process.h>
|
||||
#include <magenta/syscalls.h>
|
||||
#include <magenta/syscalls/object.h>
|
||||
#include <magenta/types.h>
|
||||
#include <zircon/process.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <zircon/syscalls/object.h>
|
||||
#include <zircon/types.h>
|
||||
|
||||
#include "platform/assert.h"
|
||||
#include "vm/zone.h"
|
||||
@@ -72,11 +72,11 @@ int64_t OS::GetCurrentTimeMillis() {
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentTimeMicros() {
|
||||
return mx_time_get(MX_CLOCK_UTC) / kNanosecondsPerMicrosecond;
|
||||
return zx_time_get(ZX_CLOCK_UTC) / kNanosecondsPerMicrosecond;
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentMonotonicTicks() {
|
||||
return mx_time_get(MX_CLOCK_MONOTONIC);
|
||||
return zx_time_get(ZX_CLOCK_MONOTONIC);
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentMonotonicFrequency() {
|
||||
@@ -90,7 +90,7 @@ int64_t OS::GetCurrentMonotonicMicros() {
|
||||
}
|
||||
|
||||
int64_t OS::GetCurrentThreadCPUMicros() {
|
||||
return mx_time_get(MX_CLOCK_THREAD) / kNanosecondsPerMicrosecond;
|
||||
return zx_time_get(ZX_CLOCK_THREAD) / kNanosecondsPerMicrosecond;
|
||||
}
|
||||
|
||||
// TODO(5411554): May need to hoist these architecture dependent code
|
||||
@@ -141,7 +141,7 @@ void OS::Sleep(int64_t millis) {
|
||||
}
|
||||
|
||||
void OS::SleepMicros(int64_t micros) {
|
||||
mx_nanosleep(mx_deadline_after(micros * kNanosecondsPerMicrosecond));
|
||||
zx_nanosleep(zx_deadline_after(micros * kNanosecondsPerMicrosecond));
|
||||
}
|
||||
|
||||
void OS::DebugBreak() {
|
||||
|
||||
@@ -10,11 +10,11 @@
|
||||
#include "vm/os_thread_fuchsia.h"
|
||||
|
||||
#include <errno.h> // NOLINT
|
||||
#include <magenta/status.h>
|
||||
#include <magenta/syscalls.h>
|
||||
#include <magenta/syscalls/object.h>
|
||||
#include <magenta/threads.h>
|
||||
#include <magenta/types.h>
|
||||
#include <zircon/status.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <zircon/syscalls/object.h>
|
||||
#include <zircon/threads.h>
|
||||
#include <zircon/types.h>
|
||||
|
||||
#include "platform/assert.h"
|
||||
|
||||
@@ -54,8 +54,8 @@ namespace dart {
|
||||
|
||||
static void ComputeTimeSpecMicros(struct timespec* ts, int64_t micros) {
|
||||
// time in nanoseconds.
|
||||
mx_time_t now = mx_time_get(MX_CLOCK_MONOTONIC);
|
||||
mx_time_t target = now + (micros * kNanosecondsPerMicrosecond);
|
||||
zx_time_t now = zx_time_get(ZX_CLOCK_MONOTONIC);
|
||||
zx_time_t target = now + (micros * kNanosecondsPerMicrosecond);
|
||||
int64_t secs = target / kNanosecondsPerSecond;
|
||||
int64_t nanos = target - (secs * kNanosecondsPerSecond);
|
||||
|
||||
@@ -127,7 +127,7 @@ int OSThread::Start(const char* name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
const ThreadId OSThread::kInvalidThreadId = MX_KOID_INVALID;
|
||||
const ThreadId OSThread::kInvalidThreadId = ZX_KOID_INVALID;
|
||||
const ThreadJoinId OSThread::kInvalidThreadJoinId =
|
||||
static_cast<ThreadJoinId>(0);
|
||||
|
||||
@@ -157,13 +157,13 @@ intptr_t OSThread::GetMaxStackSize() {
|
||||
}
|
||||
|
||||
ThreadId OSThread::GetCurrentThreadId() {
|
||||
mx_info_handle_basic_t info;
|
||||
mx_handle_t thread_handle = thrd_get_mx_handle(thrd_current());
|
||||
mx_status_t status =
|
||||
mx_object_get_info(thread_handle, MX_INFO_HANDLE_BASIC, &info,
|
||||
zx_info_handle_basic_t info;
|
||||
zx_handle_t thread_handle = thrd_get_zx_handle(thrd_current());
|
||||
zx_status_t status =
|
||||
zx_object_get_info(thread_handle, ZX_INFO_HANDLE_BASIC, &info,
|
||||
sizeof(info), nullptr, nullptr);
|
||||
if (status != MX_OK) {
|
||||
FATAL1("Failed to get thread koid: %s\n", mx_status_get_string(status));
|
||||
if (status != ZX_OK) {
|
||||
FATAL1("Failed to get thread koid: %s\n", zx_status_get_string(status));
|
||||
}
|
||||
return info.koid;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#error Do not include os_thread_fuchsia.h directly; use os_thread.h instead.
|
||||
#endif
|
||||
|
||||
#include <magenta/syscalls/object.h>
|
||||
#include <zircon/syscalls/object.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include "platform/assert.h"
|
||||
@@ -18,7 +18,7 @@
|
||||
namespace dart {
|
||||
|
||||
typedef pthread_key_t ThreadLocalKey;
|
||||
typedef mx_koid_t ThreadId;
|
||||
typedef zx_koid_t ThreadId;
|
||||
typedef pthread_t ThreadJoinId;
|
||||
|
||||
static const ThreadLocalKey kUnsetThreadLocalKey =
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
#include "vm/thread_interrupter.h"
|
||||
|
||||
#include <magenta/process.h>
|
||||
#include <magenta/status.h>
|
||||
#include <magenta/syscalls.h>
|
||||
#include <magenta/syscalls/debug.h>
|
||||
#include <magenta/syscalls/object.h>
|
||||
#include <magenta/types.h>
|
||||
#include <zircon/process.h>
|
||||
#include <zircon/status.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <zircon/syscalls/debug.h>
|
||||
#include <zircon/syscalls/object.h>
|
||||
#include <zircon/types.h>
|
||||
|
||||
#include "vm/flags.h"
|
||||
#include "vm/instructions.h"
|
||||
@@ -36,15 +36,15 @@ DECLARE_FLAG(bool, trace_thread_interrupter);
|
||||
// the thread is resumed and its handle is closed.
|
||||
class ThreadSuspendScope {
|
||||
public:
|
||||
explicit ThreadSuspendScope(mx_handle_t thread_handle)
|
||||
explicit ThreadSuspendScope(zx_handle_t thread_handle)
|
||||
: thread_handle_(thread_handle), suspended_(true) {
|
||||
mx_status_t status = mx_task_suspend(thread_handle);
|
||||
// If a thread is somewhere where suspend is impossible, mx_task_suspend()
|
||||
// can return MX_ERR_NOT_SUPPORTED.
|
||||
if (status != MX_OK) {
|
||||
zx_status_t status = zx_task_suspend(thread_handle);
|
||||
// If a thread is somewhere where suspend is impossible, zx_task_suspend()
|
||||
// can return ZX_ERR_NOT_SUPPORTED.
|
||||
if (status != ZX_OK) {
|
||||
if (FLAG_trace_thread_interrupter) {
|
||||
OS::PrintErr("ThreadInterrupter: mx_task_suspend failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
OS::PrintErr("ThreadInterrupter: zx_task_suspend failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
}
|
||||
suspended_ = false;
|
||||
}
|
||||
@@ -52,20 +52,20 @@ class ThreadSuspendScope {
|
||||
|
||||
~ThreadSuspendScope() {
|
||||
if (suspended_) {
|
||||
mx_status_t status = mx_task_resume(thread_handle_, 0);
|
||||
if (status != MX_OK) {
|
||||
zx_status_t status = zx_task_resume(thread_handle_, 0);
|
||||
if (status != ZX_OK) {
|
||||
// If we fail to resume a thread, then it's likely the program will
|
||||
// hang. Crash instead.
|
||||
FATAL1("mx_task_resume failed: %s", mx_status_get_string(status));
|
||||
FATAL1("zx_task_resume failed: %s", zx_status_get_string(status));
|
||||
}
|
||||
}
|
||||
mx_handle_close(thread_handle_);
|
||||
zx_handle_close(thread_handle_);
|
||||
}
|
||||
|
||||
bool suspended() const { return suspended_; }
|
||||
|
||||
private:
|
||||
mx_handle_t thread_handle_;
|
||||
zx_handle_t thread_handle_;
|
||||
bool suspended_;
|
||||
|
||||
DISALLOW_ALLOCATION();
|
||||
@@ -75,15 +75,15 @@ class ThreadSuspendScope {
|
||||
class ThreadInterrupterFuchsia : public AllStatic {
|
||||
public:
|
||||
#if defined(TARGET_ARCH_X64)
|
||||
static bool GrabRegisters(mx_handle_t thread, InterruptedThreadState* state) {
|
||||
mx_x86_64_general_regs_t regs;
|
||||
static bool GrabRegisters(zx_handle_t thread, InterruptedThreadState* state) {
|
||||
zx_x86_64_general_regs_t regs;
|
||||
uint32_t regset_size;
|
||||
mx_status_t status = mx_thread_read_state(
|
||||
thread, MX_THREAD_STATE_REGSET0, ®s, sizeof(regs), ®set_size);
|
||||
if (status != MX_OK) {
|
||||
zx_status_t status = zx_thread_read_state(
|
||||
thread, ZX_THREAD_STATE_REGSET0, ®s, sizeof(regs), ®set_size);
|
||||
if (status != ZX_OK) {
|
||||
if (FLAG_trace_thread_interrupter) {
|
||||
OS::PrintErr("ThreadInterrupter failed to get registers: %s\n",
|
||||
mx_status_get_string(status));
|
||||
zx_status_get_string(status));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -94,15 +94,15 @@ class ThreadInterrupterFuchsia : public AllStatic {
|
||||
return true;
|
||||
}
|
||||
#elif defined(TARGET_ARCH_ARM64)
|
||||
static bool GrabRegisters(mx_handle_t thread, InterruptedThreadState* state) {
|
||||
mx_arm64_general_regs_t regs;
|
||||
static bool GrabRegisters(zx_handle_t thread, InterruptedThreadState* state) {
|
||||
zx_arm64_general_regs_t regs;
|
||||
uint32_t regset_size;
|
||||
mx_status_t status = mx_thread_read_state(
|
||||
thread, MX_THREAD_STATE_REGSET0, ®s, sizeof(regs), ®set_size);
|
||||
if (status != MX_OK) {
|
||||
zx_status_t status = zx_thread_read_state(
|
||||
thread, ZX_THREAD_STATE_REGSET0, ®s, sizeof(regs), ®set_size);
|
||||
if (status != ZX_OK) {
|
||||
if (FLAG_trace_thread_interrupter) {
|
||||
OS::PrintErr("ThreadInterrupter failed to get registers: %s\n",
|
||||
mx_status_get_string(status));
|
||||
zx_status_get_string(status));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -118,30 +118,30 @@ class ThreadInterrupterFuchsia : public AllStatic {
|
||||
#endif
|
||||
|
||||
static void Interrupt(OSThread* os_thread) {
|
||||
ASSERT(os_thread->id() != MX_KOID_INVALID);
|
||||
ASSERT(os_thread->id() != ZX_KOID_INVALID);
|
||||
ASSERT(!OSThread::Compare(OSThread::GetCurrentThreadId(), os_thread->id()));
|
||||
mx_status_t status;
|
||||
zx_status_t status;
|
||||
|
||||
// Get a handle on the target thread.
|
||||
const mx_koid_t target_thread_koid = os_thread->id();
|
||||
const zx_koid_t target_thread_koid = os_thread->id();
|
||||
if (FLAG_trace_thread_interrupter) {
|
||||
OS::PrintErr("ThreadInterrupter: interrupting thread with koid=%d\n",
|
||||
target_thread_koid);
|
||||
}
|
||||
mx_handle_t target_thread_handle;
|
||||
status = mx_object_get_child(mx_process_self(), target_thread_koid,
|
||||
MX_RIGHT_SAME_RIGHTS, &target_thread_handle);
|
||||
if (status != MX_OK) {
|
||||
zx_handle_t target_thread_handle;
|
||||
status = zx_object_get_child(zx_process_self(), target_thread_koid,
|
||||
ZX_RIGHT_SAME_RIGHTS, &target_thread_handle);
|
||||
if (status != ZX_OK) {
|
||||
if (FLAG_trace_thread_interrupter) {
|
||||
OS::PrintErr("ThreadInterrupter: mx_object_get_child failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
OS::PrintErr("ThreadInterrupter: zx_object_get_child failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (target_thread_handle == MX_HANDLE_INVALID) {
|
||||
if (target_thread_handle == ZX_HANDLE_INVALID) {
|
||||
if (FLAG_trace_thread_interrupter) {
|
||||
OS::PrintErr(
|
||||
"ThreadInterrupter: mx_object_get_child gave an invalid "
|
||||
"ThreadInterrupter: zx_object_get_child gave an invalid "
|
||||
"thread handle!");
|
||||
}
|
||||
return;
|
||||
@@ -156,7 +156,7 @@ class ThreadInterrupterFuchsia : public AllStatic {
|
||||
|
||||
// Check that the thread is suspended.
|
||||
status = PollThreadUntilSuspended(target_thread_handle);
|
||||
if (status != MX_OK) {
|
||||
if (status != ZX_OK) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,44 +177,44 @@ class ThreadInterrupterFuchsia : public AllStatic {
|
||||
private:
|
||||
static const char* ThreadStateGetString(uint32_t state) {
|
||||
switch (state) {
|
||||
case MX_THREAD_STATE_NEW:
|
||||
return "MX_THREAD_STATE_NEW";
|
||||
case MX_THREAD_STATE_RUNNING:
|
||||
return "MX_THREAD_STATE_RUNNING";
|
||||
case MX_THREAD_STATE_SUSPENDED:
|
||||
return "MX_THREAD_STATE_SUSPENDED";
|
||||
case MX_THREAD_STATE_BLOCKED:
|
||||
return "MX_THREAD_STATE_BLOCKED";
|
||||
case MX_THREAD_STATE_DYING:
|
||||
return "MX_THREAD_STATE_DYING";
|
||||
case MX_THREAD_STATE_DEAD:
|
||||
return "MX_THREAD_STATE_DEAD";
|
||||
case ZX_THREAD_STATE_NEW:
|
||||
return "ZX_THREAD_STATE_NEW";
|
||||
case ZX_THREAD_STATE_RUNNING:
|
||||
return "ZX_THREAD_STATE_RUNNING";
|
||||
case ZX_THREAD_STATE_SUSPENDED:
|
||||
return "ZX_THREAD_STATE_SUSPENDED";
|
||||
case ZX_THREAD_STATE_BLOCKED:
|
||||
return "ZX_THREAD_STATE_BLOCKED";
|
||||
case ZX_THREAD_STATE_DYING:
|
||||
return "ZX_THREAD_STATE_DYING";
|
||||
case ZX_THREAD_STATE_DEAD:
|
||||
return "ZX_THREAD_STATE_DEAD";
|
||||
default:
|
||||
return "<Unknown>";
|
||||
}
|
||||
}
|
||||
|
||||
static mx_status_t PollThreadUntilSuspended(mx_handle_t thread_handle) {
|
||||
static zx_status_t PollThreadUntilSuspended(zx_handle_t thread_handle) {
|
||||
const intptr_t kMaxPollAttempts = 10;
|
||||
intptr_t poll_tries = 0;
|
||||
while (poll_tries < kMaxPollAttempts) {
|
||||
mx_info_thread_t thread_info;
|
||||
mx_status_t status =
|
||||
mx_object_get_info(thread_handle, MX_INFO_THREAD, &thread_info,
|
||||
zx_info_thread_t thread_info;
|
||||
zx_status_t status =
|
||||
zx_object_get_info(thread_handle, ZX_INFO_THREAD, &thread_info,
|
||||
sizeof(thread_info), NULL, NULL);
|
||||
poll_tries++;
|
||||
if (status != MX_OK) {
|
||||
if (status != ZX_OK) {
|
||||
if (FLAG_trace_thread_interrupter) {
|
||||
OS::PrintErr("ThreadInterrupter: mx_object_get_info failed: %s\n",
|
||||
mx_status_get_string(status));
|
||||
OS::PrintErr("ThreadInterrupter: zx_object_get_info failed: %s\n",
|
||||
zx_status_get_string(status));
|
||||
}
|
||||
return status;
|
||||
}
|
||||
if (thread_info.state == MX_THREAD_STATE_SUSPENDED) {
|
||||
if (thread_info.state == ZX_THREAD_STATE_SUSPENDED) {
|
||||
// Success.
|
||||
return MX_OK;
|
||||
return ZX_OK;
|
||||
}
|
||||
if (thread_info.state == MX_THREAD_STATE_RUNNING) {
|
||||
if (thread_info.state == ZX_THREAD_STATE_RUNNING) {
|
||||
// Poll.
|
||||
continue;
|
||||
}
|
||||
@@ -222,12 +222,12 @@ class ThreadInterrupterFuchsia : public AllStatic {
|
||||
OS::PrintErr("ThreadInterrupter: Thread is not suspended: %s\n",
|
||||
ThreadStateGetString(thread_info.state));
|
||||
}
|
||||
return MX_ERR_BAD_STATE;
|
||||
return ZX_ERR_BAD_STATE;
|
||||
}
|
||||
if (FLAG_trace_thread_interrupter) {
|
||||
OS::PrintErr("ThreadInterrupter: Exceeded max suspend poll tries\n");
|
||||
}
|
||||
return MX_ERR_BAD_STATE;
|
||||
return ZX_ERR_BAD_STATE;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "platform/globals.h"
|
||||
#if defined(HOST_OS_FUCHSIA) && !defined(PRODUCT)
|
||||
|
||||
#include <magenta/syscalls.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <trace-engine/context.h>
|
||||
#include <trace-engine/instrumentation.h>
|
||||
|
||||
@@ -78,7 +78,7 @@ void TimelineEventPlatformRecorder::CompleteEvent(TimelineEvent* event) {
|
||||
args[i] = trace_make_arg(arg_name, trace_make_string_arg_value(arg_value));
|
||||
}
|
||||
|
||||
const uint64_t time_scale = mx_ticks_per_second() / kMicrosecondsPerSecond;
|
||||
const uint64_t time_scale = zx_ticks_per_second() / kMicrosecondsPerSecond;
|
||||
const uint64_t start_time = event->LowTime() * time_scale;
|
||||
const uint64_t end_time = event->HighTime() * time_scale;
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
|
||||
#include "vm/virtual_memory.h"
|
||||
|
||||
#include <magenta/process.h>
|
||||
#include <magenta/status.h>
|
||||
#include <magenta/syscalls.h>
|
||||
#include <zircon/process.h>
|
||||
#include <zircon/status.h>
|
||||
#include <zircon/syscalls.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -35,24 +35,24 @@
|
||||
|
||||
namespace dart {
|
||||
|
||||
// The Magenta system call to protect memory regions (mx_vmar_protect) takes a
|
||||
// The Zircon system call to protect memory regions (zx_vmar_protect) takes a
|
||||
// VM area (vmar) handle as first argument. We call VirtualMemory::Protect()
|
||||
// from the memory freelist code in vm/freelist.cc where the vmar handle is not
|
||||
// available. Additionally, there is no mx_vmar system call to retrieve a handle
|
||||
// available. Additionally, there is no zx_vmar system call to retrieve a handle
|
||||
// for the leaf vmar given an address. Thus, when memory protections are
|
||||
// enabled, we maintain a sorted list of our leaf vmar handles that we can
|
||||
// query by address in calls to VirtualMemory::Protect().
|
||||
class VmarList : public AllStatic {
|
||||
public:
|
||||
static void AddVmar(mx_handle_t vmar, uword addr, intptr_t size);
|
||||
static void AddVmar(zx_handle_t vmar, uword addr, intptr_t size);
|
||||
static void RemoveVmar(uword addr);
|
||||
static mx_handle_t LookupVmar(uword addr);
|
||||
static zx_handle_t LookupVmar(uword addr);
|
||||
|
||||
private:
|
||||
static intptr_t LookupVmarIndexLocked(uword addr);
|
||||
|
||||
struct VmarListElement {
|
||||
mx_handle_t vmar;
|
||||
zx_handle_t vmar;
|
||||
uword addr;
|
||||
intptr_t size;
|
||||
};
|
||||
@@ -64,7 +64,7 @@ class VmarList : public AllStatic {
|
||||
Mutex* VmarList::vmar_array_lock_ = new Mutex();
|
||||
MallocGrowableArray<VmarList::VmarListElement> VmarList::vmar_array_;
|
||||
|
||||
void VmarList::AddVmar(mx_handle_t vmar, uword addr, intptr_t size) {
|
||||
void VmarList::AddVmar(zx_handle_t vmar, uword addr, intptr_t size) {
|
||||
MutexLocker ml(vmar_array_lock_);
|
||||
LOG_INFO("AddVmar(%d, %lx, %ld)\n", vmar, addr, size);
|
||||
// Sorted insert in increasing order.
|
||||
@@ -108,13 +108,13 @@ intptr_t VmarList::LookupVmarIndexLocked(uword addr) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
mx_handle_t VmarList::LookupVmar(uword addr) {
|
||||
zx_handle_t VmarList::LookupVmar(uword addr) {
|
||||
MutexLocker ml(vmar_array_lock_);
|
||||
LOG_INFO("LookupVmar(%lx)\n", addr);
|
||||
const intptr_t idx = LookupVmarIndexLocked(addr);
|
||||
if (idx == -1) {
|
||||
LOG_ERR("LookupVmar(%lx) NOT FOUND\n", addr);
|
||||
return MX_HANDLE_INVALID;
|
||||
return ZX_HANDLE_INVALID;
|
||||
}
|
||||
LOG_INFO("LookupVmar(%lx) found at %ld\n", addr, idx);
|
||||
return vmar_array_[idx].vmar;
|
||||
@@ -126,7 +126,7 @@ void VmarList::RemoveVmar(uword addr) {
|
||||
const intptr_t idx = LookupVmarIndexLocked(addr);
|
||||
ASSERT(idx != -1);
|
||||
#if defined(DEBUG)
|
||||
mx_handle_t vmar = vmar_array_[idx].vmar;
|
||||
zx_handle_t vmar = vmar_array_[idx].vmar;
|
||||
#endif
|
||||
// Swap idx to the end, and then RemoveLast()
|
||||
const intptr_t length = vmar_array_.length();
|
||||
@@ -148,16 +148,16 @@ void VirtualMemory::InitOnce() {
|
||||
|
||||
VirtualMemory* VirtualMemory::ReserveInternal(intptr_t size) {
|
||||
ASSERT(Utils::IsAligned(size, page_size_));
|
||||
mx_handle_t vmar = MX_HANDLE_INVALID;
|
||||
zx_handle_t vmar = ZX_HANDLE_INVALID;
|
||||
uword addr = 0;
|
||||
const uint32_t flags = MX_VM_FLAG_COMPACT | MX_VM_FLAG_CAN_MAP_SPECIFIC |
|
||||
MX_VM_FLAG_CAN_MAP_READ | MX_VM_FLAG_CAN_MAP_WRITE |
|
||||
MX_VM_FLAG_CAN_MAP_EXECUTE;
|
||||
mx_status_t status =
|
||||
mx_vmar_allocate(mx_vmar_root_self(), 0, size, flags, &vmar, &addr);
|
||||
if (status != MX_OK) {
|
||||
LOG_ERR("mx_vmar_allocate(size = %ld) failed: %s\n", size,
|
||||
mx_status_get_string(status));
|
||||
const uint32_t flags = ZX_VM_FLAG_COMPACT | ZX_VM_FLAG_CAN_MAP_SPECIFIC |
|
||||
ZX_VM_FLAG_CAN_MAP_READ | ZX_VM_FLAG_CAN_MAP_WRITE |
|
||||
ZX_VM_FLAG_CAN_MAP_EXECUTE;
|
||||
zx_status_t status =
|
||||
zx_vmar_allocate(zx_vmar_root_self(), 0, size, flags, &vmar, &addr);
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("zx_vmar_allocate(size = %ld) failed: %s\n", size,
|
||||
zx_status_get_string(status));
|
||||
return NULL;
|
||||
}
|
||||
VmarList::AddVmar(vmar, addr, size);
|
||||
@@ -167,14 +167,14 @@ VirtualMemory* VirtualMemory::ReserveInternal(intptr_t size) {
|
||||
|
||||
VirtualMemory::~VirtualMemory() {
|
||||
if (vm_owns_region()) {
|
||||
mx_handle_t vmar = static_cast<mx_handle_t>(handle());
|
||||
mx_status_t status = mx_vmar_destroy(vmar);
|
||||
if (status != MX_OK) {
|
||||
LOG_ERR("mx_vmar_destroy failed: %s\n", mx_status_get_string(status));
|
||||
zx_handle_t vmar = static_cast<zx_handle_t>(handle());
|
||||
zx_status_t status = zx_vmar_destroy(vmar);
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("zx_vmar_destroy failed: %s\n", zx_status_get_string(status));
|
||||
}
|
||||
status = mx_handle_close(vmar);
|
||||
if (status != MX_OK) {
|
||||
LOG_ERR("mx_handle_close failed: %s\n", mx_status_get_string(status));
|
||||
status = zx_handle_close(vmar);
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("zx_handle_close failed: %s\n", zx_status_get_string(status));
|
||||
}
|
||||
VmarList::RemoveVmar(start());
|
||||
}
|
||||
@@ -183,11 +183,11 @@ VirtualMemory::~VirtualMemory() {
|
||||
bool VirtualMemory::FreeSubSegment(int32_t handle,
|
||||
void* address,
|
||||
intptr_t size) {
|
||||
mx_handle_t vmar = static_cast<mx_handle_t>(handle);
|
||||
mx_status_t status =
|
||||
mx_vmar_unmap(vmar, reinterpret_cast<uintptr_t>(address), size);
|
||||
if (status != MX_OK) {
|
||||
LOG_ERR("mx_vmar_unmap failed: %s\n", mx_status_get_string(status));
|
||||
zx_handle_t vmar = static_cast<zx_handle_t>(handle);
|
||||
zx_status_t status =
|
||||
zx_vmar_unmap(vmar, reinterpret_cast<uintptr_t>(address), size);
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("zx_vmar_unmap failed: %s\n", zx_status_get_string(status));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -199,38 +199,38 @@ bool VirtualMemory::Commit(uword addr,
|
||||
const char* name) {
|
||||
ASSERT(Contains(addr));
|
||||
ASSERT(Contains(addr + size) || (addr + size == end()));
|
||||
mx_handle_t vmo = MX_HANDLE_INVALID;
|
||||
mx_status_t status = mx_vmo_create(size, 0u, &vmo);
|
||||
if (status != MX_OK) {
|
||||
LOG_ERR("mx_vmo_create(%ld) failed: %s\n", size,
|
||||
mx_status_get_string(status));
|
||||
zx_handle_t vmo = ZX_HANDLE_INVALID;
|
||||
zx_status_t status = zx_vmo_create(size, 0u, &vmo);
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("zx_vmo_create(%ld) failed: %s\n", size,
|
||||
zx_status_get_string(status));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (name != NULL) {
|
||||
mx_object_set_property(vmo, MX_PROP_NAME, name, strlen(name));
|
||||
zx_object_set_property(vmo, ZX_PROP_NAME, name, strlen(name));
|
||||
}
|
||||
|
||||
mx_handle_t vmar = static_cast<mx_handle_t>(handle());
|
||||
zx_handle_t vmar = static_cast<zx_handle_t>(handle());
|
||||
const size_t offset = addr - start();
|
||||
const uint32_t flags = MX_VM_FLAG_SPECIFIC | MX_VM_FLAG_PERM_READ |
|
||||
MX_VM_FLAG_PERM_WRITE |
|
||||
(executable ? MX_VM_FLAG_PERM_EXECUTE : 0);
|
||||
const uint32_t flags = ZX_VM_FLAG_SPECIFIC | ZX_VM_FLAG_PERM_READ |
|
||||
ZX_VM_FLAG_PERM_WRITE |
|
||||
(executable ? ZX_VM_FLAG_PERM_EXECUTE : 0);
|
||||
uintptr_t mapped_addr;
|
||||
status = mx_vmar_map(vmar, offset, vmo, 0, size, flags, &mapped_addr);
|
||||
if (status != MX_OK) {
|
||||
mx_handle_close(vmo);
|
||||
LOG_ERR("mx_vmar_map(%ld, %ld, %u) failed: %s\n", offset, size, flags,
|
||||
mx_status_get_string(status));
|
||||
status = zx_vmar_map(vmar, offset, vmo, 0, size, flags, &mapped_addr);
|
||||
if (status != ZX_OK) {
|
||||
zx_handle_close(vmo);
|
||||
LOG_ERR("zx_vmar_map(%ld, %ld, %u) failed: %s\n", offset, size, flags,
|
||||
zx_status_get_string(status));
|
||||
return false;
|
||||
}
|
||||
if (addr != mapped_addr) {
|
||||
mx_handle_close(vmo);
|
||||
LOG_ERR("mx_vmar_map: addr != mapped_addr: %lx != %lx\n", addr,
|
||||
zx_handle_close(vmo);
|
||||
LOG_ERR("zx_vmar_map: addr != mapped_addr: %lx != %lx\n", addr,
|
||||
mapped_addr);
|
||||
return false;
|
||||
}
|
||||
mx_handle_close(vmo);
|
||||
zx_handle_close(vmo);
|
||||
LOG_INFO("Commit(%lx, %ld, %s): success\n", addr, size,
|
||||
executable ? "executable" : "");
|
||||
return true;
|
||||
@@ -242,36 +242,36 @@ bool VirtualMemory::Protect(void* address, intptr_t size, Protection mode) {
|
||||
const uword start_address = reinterpret_cast<uword>(address);
|
||||
const uword end_address = start_address + size;
|
||||
const uword page_address = Utils::RoundDown(start_address, PageSize());
|
||||
mx_handle_t vmar = VmarList::LookupVmar(page_address);
|
||||
ASSERT(vmar != MX_HANDLE_INVALID);
|
||||
zx_handle_t vmar = VmarList::LookupVmar(page_address);
|
||||
ASSERT(vmar != ZX_HANDLE_INVALID);
|
||||
uint32_t prot = 0;
|
||||
switch (mode) {
|
||||
case kNoAccess:
|
||||
// ZX-426: mx_vmar_protect() requires at least on permission.
|
||||
prot = MX_VM_FLAG_PERM_READ;
|
||||
// ZX-426: zx_vmar_protect() requires at least on permission.
|
||||
prot = ZX_VM_FLAG_PERM_READ;
|
||||
break;
|
||||
case kReadOnly:
|
||||
prot = MX_VM_FLAG_PERM_READ;
|
||||
prot = ZX_VM_FLAG_PERM_READ;
|
||||
break;
|
||||
case kReadWrite:
|
||||
prot = MX_VM_FLAG_PERM_READ | MX_VM_FLAG_PERM_WRITE;
|
||||
prot = ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE;
|
||||
break;
|
||||
case kReadExecute:
|
||||
prot = MX_VM_FLAG_PERM_READ | MX_VM_FLAG_PERM_EXECUTE;
|
||||
prot = ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_EXECUTE;
|
||||
break;
|
||||
case kReadWriteExecute:
|
||||
prot = MX_VM_FLAG_PERM_READ | MX_VM_FLAG_PERM_WRITE |
|
||||
MX_VM_FLAG_PERM_EXECUTE;
|
||||
prot = ZX_VM_FLAG_PERM_READ | ZX_VM_FLAG_PERM_WRITE |
|
||||
ZX_VM_FLAG_PERM_EXECUTE;
|
||||
break;
|
||||
}
|
||||
mx_status_t status =
|
||||
mx_vmar_protect(vmar, page_address, end_address - page_address, prot);
|
||||
if (status != MX_OK) {
|
||||
LOG_ERR("mx_vmar_protect(%lx, %lx, %x) success: %s\n", page_address,
|
||||
end_address - page_address, prot, mx_status_get_string(status));
|
||||
zx_status_t status =
|
||||
zx_vmar_protect(vmar, page_address, end_address - page_address, prot);
|
||||
if (status != ZX_OK) {
|
||||
LOG_ERR("zx_vmar_protect(%lx, %lx, %x) success: %s\n", page_address,
|
||||
end_address - page_address, prot, zx_status_get_string(status));
|
||||
return false;
|
||||
}
|
||||
LOG_INFO("mx_vmar_protect(%lx, %lx, %x) success\n", page_address,
|
||||
LOG_INFO("zx_vmar_protect(%lx, %lx, %x) success\n", page_address,
|
||||
end_address - page_address, prot);
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user