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

Side by Side Diff: mojo/monacl/libmojo.cc

Issue 385983008: Mojo + NaCl prototype. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Better diff Created 6 years, 5 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
(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_monacl_bindings.py
6 // Do not edit by hand.
7
8 #include <errno.h>
9
10 #include "mojo/public/c/system/core.h"
11 #include "native_client/src/public/imc_types.h"
12 #include "native_client/src/untrusted/nacl/syscall_bindings_trampoline.h"
13
14 int imc_sendmsg(int desc, struct NaClAbiNaClImcMsgHdr const *nmhp, int flags) {
15 int retval = NACL_SYSCALL(imc_sendmsg)(desc, nmhp, flags);
16 if (retval < 0) {
17 errno = -retval;
18 }
19 return retval;
20 }
21
22 #define NACL_MOJO_DESC 5
23
24 MojoResult MojoCreateSharedBuffer(
25 const struct MojoCreateSharedBufferOptions* options,
26 uint64_t num_bytes,
27 MojoHandle* shared_buffer_handle){
28 uint32_t params[5];
29 MojoResult result;
30 params[0] = 0;
31 params[1] = reinterpret_cast<uint32_t>(options);
32 params[2] = reinterpret_cast<uint32_t>(&num_bytes);
33 params[3] = reinterpret_cast<uint32_t>(shared_buffer_handle);
34 params[4] = reinterpret_cast<uint32_t>(&result);
35 NaClAbiNaClImcMsgIoVec iov[1] = {
36 {params, sizeof(params)}
37 };
38 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
39 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
40 result = MOJO_RESULT_INVALID_ARGUMENT;
41 }
42 return result;
43 }
44
45 MojoResult MojoDuplicateBufferHandle(
46 MojoHandle buffer_handle,
47 const struct MojoDuplicateBufferHandleOptions* options,
48 MojoHandle* new_buffer_handle){
49 uint32_t params[5];
50 MojoResult result;
51 params[0] = 1;
52 params[1] = reinterpret_cast<uint32_t>(&buffer_handle);
53 params[2] = reinterpret_cast<uint32_t>(options);
54 params[3] = reinterpret_cast<uint32_t>(new_buffer_handle);
55 params[4] = reinterpret_cast<uint32_t>(&result);
56 NaClAbiNaClImcMsgIoVec iov[1] = {
57 {params, sizeof(params)}
58 };
59 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
60 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
61 result = MOJO_RESULT_INVALID_ARGUMENT;
62 }
63 return result;
64 }
65
66 MojoResult MojoMapBuffer(
67 MojoHandle buffer_handle,
68 uint64_t offset,
69 uint64_t num_bytes,
70 void** buffer,
71 MojoMapBufferFlags flags){
72 uint32_t params[7];
73 MojoResult result;
74 params[0] = 2;
75 params[1] = reinterpret_cast<uint32_t>(&buffer_handle);
76 params[2] = reinterpret_cast<uint32_t>(&offset);
77 params[3] = reinterpret_cast<uint32_t>(&num_bytes);
78 params[4] = reinterpret_cast<uint32_t>(buffer);
79 params[5] = reinterpret_cast<uint32_t>(&flags);
80 params[6] = reinterpret_cast<uint32_t>(&result);
81 NaClAbiNaClImcMsgIoVec iov[1] = {
82 {params, sizeof(params)}
83 };
84 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
85 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
86 result = MOJO_RESULT_INVALID_ARGUMENT;
87 }
88 return result;
89 }
90
91 MojoResult MojoUnmapBuffer(void* buffer){
92 uint32_t params[3];
93 MojoResult result;
94 params[0] = 3;
95 params[1] = reinterpret_cast<uint32_t>(&buffer);
96 params[2] = reinterpret_cast<uint32_t>(&result);
97 NaClAbiNaClImcMsgIoVec iov[1] = {
98 {params, sizeof(params)}
99 };
100 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
101 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
102 result = MOJO_RESULT_INVALID_ARGUMENT;
103 }
104 return result;
105 }
106
107 MojoResult MojoCreateDataPipe(
108 const struct MojoCreateDataPipeOptions* options,
109 MojoHandle* data_pipe_producer_handle,
110 MojoHandle* data_pipe_consumer_handle){
111 uint32_t params[5];
112 MojoResult result;
113 params[0] = 4;
114 params[1] = reinterpret_cast<uint32_t>(options);
115 params[2] = reinterpret_cast<uint32_t>(data_pipe_producer_handle);
116 params[3] = reinterpret_cast<uint32_t>(data_pipe_consumer_handle);
117 params[4] = reinterpret_cast<uint32_t>(&result);
118 NaClAbiNaClImcMsgIoVec iov[1] = {
119 {params, sizeof(params)}
120 };
121 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
122 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
123 result = MOJO_RESULT_INVALID_ARGUMENT;
124 }
125 return result;
126 }
127
128 MojoResult MojoWriteData(
129 MojoHandle data_pipe_producer_handle,
130 const void* elements,
131 uint32_t* num_bytes,
132 MojoWriteDataFlags flags){
133 uint32_t params[6];
134 MojoResult result;
135 params[0] = 5;
136 params[1] = reinterpret_cast<uint32_t>(&data_pipe_producer_handle);
137 params[2] = reinterpret_cast<uint32_t>(elements);
138 params[3] = reinterpret_cast<uint32_t>(num_bytes);
139 params[4] = reinterpret_cast<uint32_t>(&flags);
140 params[5] = reinterpret_cast<uint32_t>(&result);
141 NaClAbiNaClImcMsgIoVec iov[1] = {
142 {params, sizeof(params)}
143 };
144 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
145 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
146 result = MOJO_RESULT_INVALID_ARGUMENT;
147 }
148 return result;
149 }
150
151 MojoResult MojoBeginWriteData(
152 MojoHandle data_pipe_producer_handle,
153 void** buffer,
154 uint32_t* buffer_num_bytes,
155 MojoWriteDataFlags flags){
156 uint32_t params[6];
157 MojoResult result;
158 params[0] = 6;
159 params[1] = reinterpret_cast<uint32_t>(&data_pipe_producer_handle);
160 params[2] = reinterpret_cast<uint32_t>(buffer);
161 params[3] = reinterpret_cast<uint32_t>(buffer_num_bytes);
162 params[4] = reinterpret_cast<uint32_t>(&flags);
163 params[5] = reinterpret_cast<uint32_t>(&result);
164 NaClAbiNaClImcMsgIoVec iov[1] = {
165 {params, sizeof(params)}
166 };
167 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
168 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
169 result = MOJO_RESULT_INVALID_ARGUMENT;
170 }
171 return result;
172 }
173
174 MojoResult MojoEndWriteData(
175 MojoHandle data_pipe_producer_handle,
176 uint32_t num_bytes_written){
177 uint32_t params[4];
178 MojoResult result;
179 params[0] = 7;
180 params[1] = reinterpret_cast<uint32_t>(&data_pipe_producer_handle);
181 params[2] = reinterpret_cast<uint32_t>(&num_bytes_written);
182 params[3] = reinterpret_cast<uint32_t>(&result);
183 NaClAbiNaClImcMsgIoVec iov[1] = {
184 {params, sizeof(params)}
185 };
186 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
187 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
188 result = MOJO_RESULT_INVALID_ARGUMENT;
189 }
190 return result;
191 }
192
193 MojoResult MojoReadData(
194 MojoHandle data_pipe_consumer_handle,
195 void* elements,
196 uint32_t* num_bytes,
197 MojoReadDataFlags flags){
198 uint32_t params[6];
199 MojoResult result;
200 params[0] = 8;
201 params[1] = reinterpret_cast<uint32_t>(&data_pipe_consumer_handle);
202 params[2] = reinterpret_cast<uint32_t>(elements);
203 params[3] = reinterpret_cast<uint32_t>(num_bytes);
204 params[4] = reinterpret_cast<uint32_t>(&flags);
205 params[5] = reinterpret_cast<uint32_t>(&result);
206 NaClAbiNaClImcMsgIoVec iov[1] = {
207 {params, sizeof(params)}
208 };
209 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
210 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
211 result = MOJO_RESULT_INVALID_ARGUMENT;
212 }
213 return result;
214 }
215
216 MojoResult MojoBeginReadData(
217 MojoHandle data_pipe_consumer_handle,
218 const void** buffer,
219 uint32_t* buffer_num_bytes,
220 MojoReadDataFlags flags){
221 uint32_t params[6];
222 MojoResult result;
223 params[0] = 9;
224 params[1] = reinterpret_cast<uint32_t>(&data_pipe_consumer_handle);
225 params[2] = reinterpret_cast<uint32_t>(buffer);
226 params[3] = reinterpret_cast<uint32_t>(buffer_num_bytes);
227 params[4] = reinterpret_cast<uint32_t>(&flags);
228 params[5] = reinterpret_cast<uint32_t>(&result);
229 NaClAbiNaClImcMsgIoVec iov[1] = {
230 {params, sizeof(params)}
231 };
232 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
233 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
234 result = MOJO_RESULT_INVALID_ARGUMENT;
235 }
236 return result;
237 }
238
239 MojoResult MojoEndReadData(
240 MojoHandle data_pipe_consumer_handle,
241 uint32_t num_bytes_read){
242 uint32_t params[4];
243 MojoResult result;
244 params[0] = 10;
245 params[1] = reinterpret_cast<uint32_t>(&data_pipe_consumer_handle);
246 params[2] = reinterpret_cast<uint32_t>(&num_bytes_read);
247 params[3] = reinterpret_cast<uint32_t>(&result);
248 NaClAbiNaClImcMsgIoVec iov[1] = {
249 {params, sizeof(params)}
250 };
251 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
252 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
253 result = MOJO_RESULT_INVALID_ARGUMENT;
254 }
255 return result;
256 }
257
258 MojoTimeTicks MojoGetTimeTicksNow(){
259 uint32_t params[2];
260 MojoTimeTicks result;
261 params[0] = 11;
262 params[1] = reinterpret_cast<uint32_t>(&result);
263 NaClAbiNaClImcMsgIoVec iov[1] = {
264 {params, sizeof(params)}
265 };
266 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
267 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
268 result = MOJO_RESULT_INVALID_ARGUMENT;
269 }
270 return result;
271 }
272
273 MojoResult MojoClose(MojoHandle handle){
274 uint32_t params[3];
275 MojoResult result;
276 params[0] = 12;
277 params[1] = reinterpret_cast<uint32_t>(&handle);
278 params[2] = reinterpret_cast<uint32_t>(&result);
279 NaClAbiNaClImcMsgIoVec iov[1] = {
280 {params, sizeof(params)}
281 };
282 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
283 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
284 result = MOJO_RESULT_INVALID_ARGUMENT;
285 }
286 return result;
287 }
288
289 MojoResult MojoWait(
290 MojoHandle handle,
291 MojoHandleSignals signals,
292 MojoDeadline deadline){
293 uint32_t params[5];
294 MojoResult result;
295 params[0] = 13;
296 params[1] = reinterpret_cast<uint32_t>(&handle);
297 params[2] = reinterpret_cast<uint32_t>(&signals);
298 params[3] = reinterpret_cast<uint32_t>(&deadline);
299 params[4] = reinterpret_cast<uint32_t>(&result);
300 NaClAbiNaClImcMsgIoVec iov[1] = {
301 {params, sizeof(params)}
302 };
303 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
304 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
305 result = MOJO_RESULT_INVALID_ARGUMENT;
306 }
307 return result;
308 }
309
310 MojoResult MojoWaitMany(
311 const MojoHandle* handles,
312 const MojoHandleSignals* signals,
313 uint32_t num_handles,
314 MojoDeadline deadline){
315 uint32_t params[6];
316 MojoResult result;
317 params[0] = 14;
318 params[1] = reinterpret_cast<uint32_t>(handles);
319 params[2] = reinterpret_cast<uint32_t>(signals);
320 params[3] = reinterpret_cast<uint32_t>(&num_handles);
321 params[4] = reinterpret_cast<uint32_t>(&deadline);
322 params[5] = reinterpret_cast<uint32_t>(&result);
323 NaClAbiNaClImcMsgIoVec iov[1] = {
324 {params, sizeof(params)}
325 };
326 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
327 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
328 result = MOJO_RESULT_INVALID_ARGUMENT;
329 }
330 return result;
331 }
332
333 MojoResult MojoCreateMessagePipe(
334 const struct MojoCreateMessagePipeOptions* options,
335 MojoHandle* message_pipe_handle0,
336 MojoHandle* message_pipe_handle1){
337 uint32_t params[5];
338 MojoResult result;
339 params[0] = 15;
340 params[1] = reinterpret_cast<uint32_t>(options);
341 params[2] = reinterpret_cast<uint32_t>(message_pipe_handle0);
342 params[3] = reinterpret_cast<uint32_t>(message_pipe_handle1);
343 params[4] = reinterpret_cast<uint32_t>(&result);
344 NaClAbiNaClImcMsgIoVec iov[1] = {
345 {params, sizeof(params)}
346 };
347 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
348 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
349 result = MOJO_RESULT_INVALID_ARGUMENT;
350 }
351 return result;
352 }
353
354 MojoResult MojoWriteMessage(
355 MojoHandle message_pipe_handle,
356 const void* bytes,
357 uint32_t num_bytes,
358 const MojoHandle* handles,
359 uint32_t num_handles,
360 MojoWriteMessageFlags flags){
361 uint32_t params[8];
362 MojoResult result;
363 params[0] = 16;
364 params[1] = reinterpret_cast<uint32_t>(&message_pipe_handle);
365 params[2] = reinterpret_cast<uint32_t>(bytes);
366 params[3] = reinterpret_cast<uint32_t>(&num_bytes);
367 params[4] = reinterpret_cast<uint32_t>(handles);
368 params[5] = reinterpret_cast<uint32_t>(&num_handles);
369 params[6] = reinterpret_cast<uint32_t>(&flags);
370 params[7] = reinterpret_cast<uint32_t>(&result);
371 NaClAbiNaClImcMsgIoVec iov[1] = {
372 {params, sizeof(params)}
373 };
374 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
375 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
376 result = MOJO_RESULT_INVALID_ARGUMENT;
377 }
378 return result;
379 }
380
381 MojoResult MojoReadMessage(
382 MojoHandle message_pipe_handle,
383 void* bytes,
384 uint32_t* num_bytes,
385 MojoHandle* handles,
386 uint32_t* num_handles,
387 MojoReadMessageFlags flags){
388 uint32_t params[8];
389 MojoResult result;
390 params[0] = 17;
391 params[1] = reinterpret_cast<uint32_t>(&message_pipe_handle);
392 params[2] = reinterpret_cast<uint32_t>(bytes);
393 params[3] = reinterpret_cast<uint32_t>(num_bytes);
394 params[4] = reinterpret_cast<uint32_t>(handles);
395 params[5] = reinterpret_cast<uint32_t>(num_handles);
396 params[6] = reinterpret_cast<uint32_t>(&flags);
397 params[7] = reinterpret_cast<uint32_t>(&result);
398 NaClAbiNaClImcMsgIoVec iov[1] = {
399 {params, sizeof(params)}
400 };
401 NaClAbiNaClImcMsgHdr msgh = {iov, 1, NULL, 0};
402 if (imc_sendmsg(NACL_MOJO_DESC, &msgh, 0) < 0) {
403 result = MOJO_RESULT_INVALID_ARGUMENT;
404 }
405 return result;
406 }
407
408
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698