[mammoth] Return ErrorOr when creating a process

This commit is contained in:
Drew Galbraith 2023-06-21 20:58:08 -07:00
parent 0ec2fa3e76
commit 1f7a15eed4
4 changed files with 12 additions and 6 deletions

View file

@ -10,6 +10,8 @@ class ErrorOr {
ErrorOr() = delete;
ErrorOr(const ErrorOr&) = delete;
ErrorOr(ErrorOr&&) = delete;
// FIXME: Do we have to call ~T manually here.
~ErrorOr() {}
ErrorOr(ErrorCode code) : error_(code), ok_(false) {}
ErrorOr(const T& obj) : obj_(obj), ok_(true) {}

View file

@ -1,7 +1,8 @@
#pragma once
#include <glacier/status/error_or.h>
#include <stdint.h>
#include "mammoth/channel.h"
uint64_t SpawnProcessFromElfRegion(uint64_t program, Channel& local);
glcr::ErrorOr<Channel> SpawnProcessFromElfRegion(uint64_t program);

View file

@ -95,8 +95,8 @@ uint64_t LoadElfProgram(uint64_t base, uint64_t as_cap) {
} // namespace
uint64_t SpawnProcessFromElfRegion(uint64_t program, Channel& local) {
Channel foreign;
glcr::ErrorOr<Channel> SpawnProcessFromElfRegion(uint64_t program) {
Channel local, foreign;
check(CreateChannels(local, foreign));
uint64_t proc_cap;
@ -134,5 +134,5 @@ uint64_t SpawnProcessFromElfRegion(uint64_t program, Channel& local) {
#endif
check(ZThreadStart(thread_cap, entry_point, foreign_port_id, 0));
return glcr::OK;
return local;
}