OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // WARNING this file was generated by generate_nacl_bindings.py |
| 6 // Do not edit by hand. |
| 7 |
| 8 #include "mojo/public/c/system/core.h" |
| 9 #include "mojo/public/platform/nacl/mojo_irt.h" |
| 10 #include "native_client/src/public/chrome_main.h" |
| 11 #include "native_client/src/public/imc_syscalls.h" |
| 12 #include "native_client/src/public/imc_types.h" |
| 13 #include "native_client/src/untrusted/irt/irt.h" |
| 14 |
| 15 // The value for this FD must not conflict with uses inside Chromium. However, |
| 16 // mojo/nacl doesn't depend on any Chromium headers, so we can't use a #define |
| 17 // from there. |
| 18 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 3) |
| 19 |
| 20 bool g_irt_mojo_valid = false; |
| 21 struct nacl_irt_mojo g_irt_mojo; |
| 22 |
| 23 struct nacl_irt_mojo* get_irt_mojo() { |
| 24 if (!g_irt_mojo_valid) { |
| 25 size_t rc = nacl_interface_query(NACL_IRT_MOJO_v0_1, &g_irt_mojo, |
| 26 sizeof(g_irt_mojo)); |
| 27 if (rc != sizeof(g_irt_mojo)) |
| 28 return NULL; |
| 29 else |
| 30 g_irt_mojo_valid = true; |
| 31 } |
| 32 return &g_irt_mojo; |
| 33 } |
| 34 |
| 35 MojoResult MojoCreateSharedBuffer( |
| 36 const struct MojoCreateSharedBufferOptions* options, |
| 37 uint64_t num_bytes, |
| 38 MojoHandle* shared_buffer_handle) { |
| 39 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 40 if (irt_mojo == NULL) |
| 41 return MOJO_RESULT_INTERNAL; |
| 42 return irt_mojo->MojoCreateSharedBuffer(options, num_bytes, |
| 43 shared_buffer_handle); |
| 44 } |
| 45 |
| 46 MojoResult MojoDuplicateBufferHandle( |
| 47 MojoHandle buffer_handle, |
| 48 const struct MojoDuplicateBufferHandleOptions* options, |
| 49 MojoHandle* new_buffer_handle) { |
| 50 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 51 if (irt_mojo == NULL) |
| 52 return MOJO_RESULT_INTERNAL; |
| 53 return irt_mojo->MojoDuplicateBufferHandle(buffer_handle, options, |
| 54 new_buffer_handle); |
| 55 } |
| 56 |
| 57 MojoResult MojoMapBuffer(MojoHandle buffer_handle, |
| 58 uint64_t offset, |
| 59 uint64_t num_bytes, |
| 60 void** buffer, |
| 61 MojoMapBufferFlags flags) { |
| 62 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 63 if (irt_mojo == NULL) |
| 64 return MOJO_RESULT_INTERNAL; |
| 65 return irt_mojo->MojoMapBuffer(buffer_handle, offset, num_bytes, buffer, |
| 66 flags); |
| 67 } |
| 68 |
| 69 MojoResult MojoUnmapBuffer(void* buffer) { |
| 70 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 71 if (irt_mojo == NULL) |
| 72 return MOJO_RESULT_INTERNAL; |
| 73 return irt_mojo->MojoUnmapBuffer(buffer); |
| 74 } |
| 75 |
| 76 MojoResult MojoCreateDataPipe(const struct MojoCreateDataPipeOptions* options, |
| 77 MojoHandle* data_pipe_producer_handle, |
| 78 MojoHandle* data_pipe_consumer_handle) { |
| 79 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 80 if (irt_mojo == NULL) |
| 81 return MOJO_RESULT_INTERNAL; |
| 82 return irt_mojo->MojoCreateDataPipe(options, data_pipe_producer_handle, |
| 83 data_pipe_consumer_handle); |
| 84 } |
| 85 |
| 86 MojoResult MojoWriteData(MojoHandle data_pipe_producer_handle, |
| 87 const void* elements, |
| 88 uint32_t* num_bytes, |
| 89 MojoWriteDataFlags flags) { |
| 90 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 91 if (irt_mojo == NULL) |
| 92 return MOJO_RESULT_INTERNAL; |
| 93 return irt_mojo->MojoWriteData(data_pipe_producer_handle, elements, num_bytes, |
| 94 flags); |
| 95 } |
| 96 |
| 97 MojoResult MojoBeginWriteData(MojoHandle data_pipe_producer_handle, |
| 98 void** buffer, |
| 99 uint32_t* buffer_num_bytes, |
| 100 MojoWriteDataFlags flags) { |
| 101 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 102 if (irt_mojo == NULL) |
| 103 return MOJO_RESULT_INTERNAL; |
| 104 return irt_mojo->MojoBeginWriteData(data_pipe_producer_handle, buffer, |
| 105 buffer_num_bytes, flags); |
| 106 } |
| 107 |
| 108 MojoResult MojoEndWriteData(MojoHandle data_pipe_producer_handle, |
| 109 uint32_t num_bytes_written) { |
| 110 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 111 if (irt_mojo == NULL) |
| 112 return MOJO_RESULT_INTERNAL; |
| 113 return irt_mojo->MojoEndWriteData(data_pipe_producer_handle, |
| 114 num_bytes_written); |
| 115 } |
| 116 |
| 117 MojoResult MojoReadData(MojoHandle data_pipe_consumer_handle, |
| 118 void* elements, |
| 119 uint32_t* num_bytes, |
| 120 MojoReadDataFlags flags) { |
| 121 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 122 if (irt_mojo == NULL) |
| 123 return MOJO_RESULT_INTERNAL; |
| 124 return irt_mojo->MojoReadData(data_pipe_consumer_handle, elements, num_bytes, |
| 125 flags); |
| 126 } |
| 127 |
| 128 MojoResult MojoBeginReadData(MojoHandle data_pipe_consumer_handle, |
| 129 const void** buffer, |
| 130 uint32_t* buffer_num_bytes, |
| 131 MojoReadDataFlags flags) { |
| 132 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 133 if (irt_mojo == NULL) |
| 134 return MOJO_RESULT_INTERNAL; |
| 135 return irt_mojo->MojoBeginReadData(data_pipe_consumer_handle, buffer, |
| 136 buffer_num_bytes, flags); |
| 137 } |
| 138 |
| 139 MojoResult MojoEndReadData(MojoHandle data_pipe_consumer_handle, |
| 140 uint32_t num_bytes_read) { |
| 141 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 142 if (irt_mojo == NULL) |
| 143 return MOJO_RESULT_INTERNAL; |
| 144 return irt_mojo->MojoEndReadData(data_pipe_consumer_handle, num_bytes_read); |
| 145 } |
| 146 |
| 147 MojoTimeTicks MojoGetTimeTicksNow() { |
| 148 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 149 if (irt_mojo == NULL) |
| 150 return MOJO_RESULT_INTERNAL; |
| 151 return irt_mojo->MojoGetTimeTicksNow(); |
| 152 } |
| 153 |
| 154 MojoResult MojoClose(MojoHandle handle) { |
| 155 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 156 if (irt_mojo == NULL) |
| 157 return MOJO_RESULT_INTERNAL; |
| 158 return irt_mojo->MojoClose(handle); |
| 159 } |
| 160 |
| 161 MojoResult MojoWait(MojoHandle handle, |
| 162 MojoHandleSignals signals, |
| 163 MojoDeadline deadline, |
| 164 struct MojoHandleSignalsState* signals_state) { |
| 165 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 166 if (irt_mojo == NULL) |
| 167 return MOJO_RESULT_INTERNAL; |
| 168 return irt_mojo->MojoWait(handle, signals, deadline, signals_state); |
| 169 } |
| 170 |
| 171 MojoResult MojoWaitMany(const MojoHandle* handles, |
| 172 const MojoHandleSignals* signals, |
| 173 uint32_t num_handles, |
| 174 MojoDeadline deadline, |
| 175 uint32_t* result_index, |
| 176 struct MojoHandleSignalsState* signals_states) { |
| 177 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 178 if (irt_mojo == NULL) |
| 179 return MOJO_RESULT_INTERNAL; |
| 180 return irt_mojo->MojoWaitMany(handles, signals, num_handles, deadline, |
| 181 result_index, signals_states); |
| 182 } |
| 183 |
| 184 MojoResult MojoCreateMessagePipe( |
| 185 const struct MojoCreateMessagePipeOptions* options, |
| 186 MojoHandle* message_pipe_handle0, |
| 187 MojoHandle* message_pipe_handle1) { |
| 188 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 189 if (irt_mojo == NULL) |
| 190 return MOJO_RESULT_INTERNAL; |
| 191 return irt_mojo->MojoCreateMessagePipe(options, message_pipe_handle0, |
| 192 message_pipe_handle1); |
| 193 } |
| 194 |
| 195 MojoResult MojoWriteMessage(MojoHandle message_pipe_handle, |
| 196 const void* bytes, |
| 197 uint32_t num_bytes, |
| 198 const MojoHandle* handles, |
| 199 uint32_t num_handles, |
| 200 MojoWriteMessageFlags flags) { |
| 201 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 202 if (irt_mojo == NULL) |
| 203 return MOJO_RESULT_INTERNAL; |
| 204 return irt_mojo->MojoWriteMessage(message_pipe_handle, bytes, num_bytes, |
| 205 handles, num_handles, flags); |
| 206 } |
| 207 |
| 208 MojoResult MojoReadMessage(MojoHandle message_pipe_handle, |
| 209 void* bytes, |
| 210 uint32_t* num_bytes, |
| 211 MojoHandle* handles, |
| 212 uint32_t* num_handles, |
| 213 MojoReadMessageFlags flags) { |
| 214 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 215 if (irt_mojo == NULL) |
| 216 return MOJO_RESULT_INTERNAL; |
| 217 return irt_mojo->MojoReadMessage(message_pipe_handle, bytes, num_bytes, |
| 218 handles, num_handles, flags); |
| 219 } |
| 220 |
| 221 MojoResult _MojoGetInitialHandle(MojoHandle* handle) { |
| 222 struct nacl_irt_mojo* irt_mojo = get_irt_mojo(); |
| 223 if (irt_mojo == NULL) |
| 224 return MOJO_RESULT_INTERNAL; |
| 225 return irt_mojo->_MojoGetInitialHandle(handle); |
| 226 } |
OLD | NEW |