Index: mojo/nacl/irt_mojo_nonsfi.cc |
diff --git a/mojo/nacl/monacl_shell_nonsfi.cc b/mojo/nacl/irt_mojo_nonsfi.cc |
similarity index 56% |
copy from mojo/nacl/monacl_shell_nonsfi.cc |
copy to mojo/nacl/irt_mojo_nonsfi.cc |
index 3bacf9642812107f66112334aa507b69553ae4e2..1379c21958af740d571a67481dffbbd840ee3a7b 100644 |
--- a/mojo/nacl/monacl_shell_nonsfi.cc |
+++ b/mojo/nacl/irt_mojo_nonsfi.cc |
@@ -2,17 +2,27 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include <fcntl.h> |
-#include <iostream> |
+#include "irt_mojo_nonsfi.h" |
Mark Seaborn
2015/09/02 20:27:16
Nit: #includes should use the full path, so add "m
Sean Klein
2015/09/02 22:36:19
Done.
|
-#include "mojo/edk/embedder/embedder.h" |
-#include "mojo/edk/embedder/simple_platform_support.h" |
+#include "mojo/public/c/system/functions.h" |
#include "mojo/public/platform/nacl/mojo_irt.h" |
#include "native_client/src/public/irt_core.h" |
-#include "native_client/src/public/nonsfi/elf_loader.h" |
namespace { |
+MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID; |
+ |
+MojoResult _MojoGetInitialHandle(MojoHandle* handle) { |
+ *handle = g_mojo_handle; |
+ return MOJO_RESULT_OK; |
+} |
+ |
+} // namespace |
+ |
+void MojoSetInitialHandle(MojoHandle handle) { |
+ g_mojo_handle = handle; |
+} |
+ |
const struct nacl_irt_mojo kIrtMojo = { |
Mark Seaborn
2015/09/02 20:27:16
Nit: these two vars can go inside the anon namespa
Sean Klein
2015/09/02 22:36:19
Done.
|
MojoCreateSharedBuffer, |
MojoDuplicateBufferHandle, |
@@ -32,7 +42,7 @@ const struct nacl_irt_mojo kIrtMojo = { |
MojoCreateMessagePipe, |
MojoWriteMessage, |
MojoReadMessage, |
- nullptr, // TODO(smklein): Add _MojoGetInitialHandle. |
+ _MojoGetInitialHandle, |
}; |
const struct nacl_irt_interface kIrtInterfaces[] = { |
@@ -50,28 +60,3 @@ size_t mojo_irt_nonsfi_query(const char* interface_ident, |
return result; |
return nacl_irt_query_core(interface_ident, table, tablesize); |
} |
- |
-} // namespace |
- |
-int main(int argc, char** argv, char** environ) { |
- nacl_irt_nonsfi_allow_dev_interfaces(); |
- if (argc < 2) { |
- std::cerr << "Usage: " << argv[0] << " <executable> <args...>\n"; |
- return 1; |
- } |
- const char* nexe_filename = argv[1]; |
- int fd = open(nexe_filename, O_RDONLY); |
- if (fd < 0) { |
- std::cerr << "Failed to open " << nexe_filename << ": " << |
- strerror(errno) << "\n"; |
- return 1; |
- } |
- uintptr_t entry = NaClLoadElfFile(fd); |
- |
- mojo::embedder::Init(scoped_ptr<mojo::embedder::PlatformSupport>( |
- new mojo::embedder::SimplePlatformSupport())); |
- |
- return nacl_irt_nonsfi_entry(argc - 1, argv + 1, environ, |
- reinterpret_cast<nacl_entry_func_t>(entry), |
- mojo_irt_nonsfi_query); |
-} |