Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: mojo/nacl/nonsfi/irt_mojo_nonsfi.cc

Issue 1382713002: Creating a pexe content handler to translate and run pexes. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Tests Added Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/nacl/nonsfi/irt_mojo_nonsfi.h" 5 #include "mojo/nacl/nonsfi/irt_mojo_nonsfi.h"
6 6
7 #include "mojo/public/c/system/functions.h" 7 #include "mojo/public/c/system/functions.h"
8 #include "mojo/public/platform/nacl/mojo_irt.h" 8 #include "mojo/public/platform/nacl/mojo_irt.h"
9 #include "native_client/src/public/irt_core.h" 9 #include "native_client/src/public/irt_core.h"
10 #include "native_client/src/untrusted/irt/irt_dev.h"
10 11
11 namespace { 12 namespace {
12 13
13 MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID; 14 MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID;
14 15
15 MojoResult _MojoGetInitialHandle(MojoHandle* handle) {
16 *handle = g_mojo_handle;
17 return MOJO_RESULT_OK;
18 }
19
20 const struct nacl_irt_mojo kIrtMojo = { 16 const struct nacl_irt_mojo kIrtMojo = {
21 MojoCreateSharedBuffer, 17 MojoCreateSharedBuffer,
22 MojoDuplicateBufferHandle, 18 MojoDuplicateBufferHandle,
23 MojoMapBuffer, 19 MojoMapBuffer,
24 MojoUnmapBuffer, 20 MojoUnmapBuffer,
25 MojoCreateDataPipe, 21 MojoCreateDataPipe,
26 MojoWriteData, 22 MojoWriteData,
27 MojoBeginWriteData, 23 MojoBeginWriteData,
28 MojoEndWriteData, 24 MojoEndWriteData,
29 MojoReadData, 25 MojoReadData,
30 MojoBeginReadData, 26 MojoBeginReadData,
31 MojoEndReadData, 27 MojoEndReadData,
32 MojoGetTimeTicksNow, 28 MojoGetTimeTicksNow,
33 MojoClose, 29 MojoClose,
34 MojoWait, 30 MojoWait,
35 MojoWaitMany, 31 MojoWaitMany,
36 MojoCreateMessagePipe, 32 MojoCreateMessagePipe,
37 MojoWriteMessage, 33 MojoWriteMessage,
38 MojoReadMessage, 34 MojoReadMessage,
39 _MojoGetInitialHandle, 35 nacl::_MojoGetInitialHandle,
40 }; 36 };
41 37
42 const struct nacl_irt_interface kIrtInterfaces[] = { 38 static const struct nacl_irt_interface kIrtInterfaces[] = {
Mark Seaborn 2015/10/20 21:32:40 Nit: 'static' not needed: this is in an anon names
Sean Klein 2015/10/22 21:50:00 Done.
43 {NACL_IRT_MOJO_v0_1, &kIrtMojo, sizeof(kIrtMojo), nullptr}}; 39 /* Interface to call Mojo functions */
Mark Seaborn 2015/10/20 21:32:40 Nit: Use C++-style comments
Sean Klein 2015/10/22 21:50:00 Done.
40 { NACL_IRT_MOJO_v0_1,
41 &kIrtMojo,
42 sizeof(kIrtMojo),
43 nullptr },
44 /* Interface to call PNaCl translation */
45 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1,
46 &nacl_irt_private_pnacl_translator_compile,
47 sizeof(nacl_irt_private_pnacl_translator_compile),
48 nullptr },
Mark Seaborn 2015/10/20 22:28:58 Can you conditionalise the 3 new interfaces so tha
Sean Klein 2015/10/22 21:50:00 Done.
49 /* Interface to call PNaCl linking */
50 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_LINK_v0_1,
51 &nacl_irt_private_pnacl_translator_link,
52 sizeof(nacl_irt_private_pnacl_translator_link),
53 nullptr },
54 /* Adds mechanism for opening object files, like crtbegin.o */
55 { NACL_IRT_RESOURCE_OPEN_v0_1,
56 &nacl_irt_resource_open,
57 sizeof(nacl_irt_resource_open),
58 nullptr },
59 };
44 60
45 } // namespace 61 } // namespace
46 62
47 namespace nacl { 63 namespace nacl {
48 64
65 MojoResult _MojoGetInitialHandle(MojoHandle* handle) {
66 *handle = g_mojo_handle;
67 return MOJO_RESULT_OK;
68 }
69
49 void MojoSetInitialHandle(MojoHandle handle) { 70 void MojoSetInitialHandle(MojoHandle handle) {
50 g_mojo_handle = handle; 71 g_mojo_handle = handle;
51 } 72 }
52 73
53 size_t MojoIrtNonsfiQuery(const char* interface_ident, 74 size_t MojoIrtNonsfiQuery(const char* interface_ident,
54 void* table, 75 void* table,
55 size_t tablesize) { 76 size_t tablesize) {
56 size_t result = nacl_irt_query_list(interface_ident, table, tablesize, 77 size_t result = nacl_irt_query_list(interface_ident, table, tablesize,
57 kIrtInterfaces, sizeof(kIrtInterfaces)); 78 kIrtInterfaces, sizeof(kIrtInterfaces));
58 if (result != 0) 79 if (result != 0)
59 return result; 80 return result;
60 return nacl_irt_query_core(interface_ident, table, tablesize); 81 return nacl_irt_query_core(interface_ident, table, tablesize);
61 } 82 }
62 83
63 } // namespace nacl 84 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698