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

Side by Side Diff: nacl_bindings/mojo_syscall.cc

Issue 1052723003: NaCl: create a separate namespace for Mojo handles. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Edits Created 5 years, 8 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 2014 The Chromium Authors. All rights reserved. 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 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 // WARNING this file was generated by generate_nacl_bindings.py 5 // WARNING this file was generated by generate_nacl_bindings.py
6 // Do not edit by hand. 6 // Do not edit by hand.
7 7
8 #include "nacl_bindings/mojo_syscall.h" 8 #include "nacl_bindings/mojo_syscall.h"
9 9
10 #include <stdio.h> 10 #include <stdio.h>
11 11
12 #include "mojo/public/c/system/core.h" 12 #include "mojo/public/c/system/core.h"
13 #include "mojo/public/platform/native/system_impl_private.h"
13 #include "nacl_bindings/mojo_syscall_internal.h" 14 #include "nacl_bindings/mojo_syscall_internal.h"
14 #include "native_client/src/public/chrome_main.h" 15 #include "native_client/src/public/chrome_main.h"
15 #include "native_client/src/public/nacl_app.h" 16 #include "native_client/src/public/nacl_app.h"
16 #include "native_client/src/trusted/desc/nacl_desc_custom.h" 17 #include "native_client/src/trusted/desc/nacl_desc_custom.h"
17 18
18 MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID; 19 MojoHandle g_mojo_handle = MOJO_HANDLE_INVALID;
20 MojoSystemImpl g_mojo_system = nullptr;
19 21
20 namespace { 22 namespace {
21 23
22 MojoResult _MojoGetInitialHandle(MojoHandle* handle) { 24 MojoResult _MojoGetInitialHandle(MojoHandle* handle) {
23 *handle = g_mojo_handle; 25 *handle = g_mojo_handle;
24 return MOJO_RESULT_OK; 26 return MOJO_RESULT_OK;
25 } 27 }
26 28
27 void MojoDescDestroy(void* handle) { 29 void MojoDescDestroy(void* handle) {
28 } 30 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 if (!ConvertScalarInOut(nap, params[3], false, 68 if (!ConvertScalarInOut(nap, params[3], false,
67 &shared_buffer_handle_value, 69 &shared_buffer_handle_value,
68 &shared_buffer_handle_ptr)) { 70 &shared_buffer_handle_ptr)) {
69 return -1; 71 return -1;
70 } 72 }
71 if (!ConvertScalarOutput(nap, params[4], false, &result_ptr)) { 73 if (!ConvertScalarOutput(nap, params[4], false, &result_ptr)) {
72 return -1; 74 return -1;
73 } 75 }
74 } 76 }
75 77
76 result_value = MojoCreateSharedBuffer(options, num_bytes_value, 78 result_value = MojoSystemImplCreateSharedBuffer(
77 &shared_buffer_handle_value); 79 g_mojo_system, options, num_bytes_value, &shared_buffer_handle_value);
78 80
79 { 81 {
80 ScopedCopyLock copy_lock(nap); 82 ScopedCopyLock copy_lock(nap);
81 *shared_buffer_handle_ptr = shared_buffer_handle_value; 83 *shared_buffer_handle_ptr = shared_buffer_handle_value;
82 *result_ptr = result_value; 84 *result_ptr = result_value;
83 } 85 }
84 86
85 return 0; 87 return 0;
86 } 88 }
87 case 1: { 89 case 1: {
(...skipping 16 matching lines...) Expand all
104 } 106 }
105 if (!ConvertScalarInOut(nap, params[3], false, &new_buffer_handle_value, 107 if (!ConvertScalarInOut(nap, params[3], false, &new_buffer_handle_value,
106 &new_buffer_handle_ptr)) { 108 &new_buffer_handle_ptr)) {
107 return -1; 109 return -1;
108 } 110 }
109 if (!ConvertScalarOutput(nap, params[4], false, &result_ptr)) { 111 if (!ConvertScalarOutput(nap, params[4], false, &result_ptr)) {
110 return -1; 112 return -1;
111 } 113 }
112 } 114 }
113 115
114 result_value = MojoDuplicateBufferHandle(buffer_handle_value, options, 116 result_value = MojoSystemImplDuplicateBufferHandle(
115 &new_buffer_handle_value); 117 g_mojo_system, buffer_handle_value, options,
118 &new_buffer_handle_value);
116 119
117 { 120 {
118 ScopedCopyLock copy_lock(nap); 121 ScopedCopyLock copy_lock(nap);
119 *new_buffer_handle_ptr = new_buffer_handle_value; 122 *new_buffer_handle_ptr = new_buffer_handle_value;
120 *result_ptr = result_value; 123 *result_ptr = result_value;
121 } 124 }
122 125
123 return 0; 126 return 0;
124 } 127 }
125 case 2: 128 case 2:
(...skipping 26 matching lines...) Expand all
152 if (!ConvertScalarInOut(nap, params[3], false, 155 if (!ConvertScalarInOut(nap, params[3], false,
153 &data_pipe_consumer_handle_value, 156 &data_pipe_consumer_handle_value,
154 &data_pipe_consumer_handle_ptr)) { 157 &data_pipe_consumer_handle_ptr)) {
155 return -1; 158 return -1;
156 } 159 }
157 if (!ConvertScalarOutput(nap, params[4], false, &result_ptr)) { 160 if (!ConvertScalarOutput(nap, params[4], false, &result_ptr)) {
158 return -1; 161 return -1;
159 } 162 }
160 } 163 }
161 164
162 result_value = 165 result_value = MojoSystemImplCreateDataPipe(
163 MojoCreateDataPipe(options, &data_pipe_producer_handle_value, 166 g_mojo_system, options, &data_pipe_producer_handle_value,
164 &data_pipe_consumer_handle_value); 167 &data_pipe_consumer_handle_value);
165 168
166 { 169 {
167 ScopedCopyLock copy_lock(nap); 170 ScopedCopyLock copy_lock(nap);
168 *data_pipe_producer_handle_ptr = data_pipe_producer_handle_value; 171 *data_pipe_producer_handle_ptr = data_pipe_producer_handle_value;
169 *data_pipe_consumer_handle_ptr = data_pipe_consumer_handle_value; 172 *data_pipe_consumer_handle_ptr = data_pipe_consumer_handle_value;
170 *result_ptr = result_value; 173 *result_ptr = result_value;
171 } 174 }
172 175
173 return 0; 176 return 0;
174 } 177 }
(...skipping 23 matching lines...) Expand all
198 } 201 }
199 if (!ConvertScalarOutput(nap, params[5], false, &result_ptr)) { 202 if (!ConvertScalarOutput(nap, params[5], false, &result_ptr)) {
200 return -1; 203 return -1;
201 } 204 }
202 if (!ConvertArray(nap, params[2], num_bytes_value, 1, false, 205 if (!ConvertArray(nap, params[2], num_bytes_value, 1, false,
203 &elements)) { 206 &elements)) {
204 return -1; 207 return -1;
205 } 208 }
206 } 209 }
207 210
208 result_value = MojoWriteData(data_pipe_producer_handle_value, elements, 211 result_value = MojoSystemImplWriteData(
209 &num_bytes_value, flags_value); 212 g_mojo_system, data_pipe_producer_handle_value, elements,
213 &num_bytes_value, flags_value);
210 214
211 { 215 {
212 ScopedCopyLock copy_lock(nap); 216 ScopedCopyLock copy_lock(nap);
213 *num_bytes_ptr = num_bytes_value; 217 *num_bytes_ptr = num_bytes_value;
214 *result_ptr = result_value; 218 *result_ptr = result_value;
215 } 219 }
216 220
217 return 0; 221 return 0;
218 } 222 }
219 case 6: 223 case 6:
(...skipping 14 matching lines...) Expand all
234 return -1; 238 return -1;
235 } 239 }
236 if (!ConvertScalarInput(nap, params[2], &num_bytes_written_value)) { 240 if (!ConvertScalarInput(nap, params[2], &num_bytes_written_value)) {
237 return -1; 241 return -1;
238 } 242 }
239 if (!ConvertScalarOutput(nap, params[3], false, &result_ptr)) { 243 if (!ConvertScalarOutput(nap, params[3], false, &result_ptr)) {
240 return -1; 244 return -1;
241 } 245 }
242 } 246 }
243 247
244 result_value = MojoEndWriteData(data_pipe_producer_handle_value, 248 result_value = MojoSystemImplEndWriteData(g_mojo_system,
245 num_bytes_written_value); 249 data_pipe_producer_handle_value,
250 num_bytes_written_value);
246 251
247 { 252 {
248 ScopedCopyLock copy_lock(nap); 253 ScopedCopyLock copy_lock(nap);
249 *result_ptr = result_value; 254 *result_ptr = result_value;
250 } 255 }
251 256
252 return 0; 257 return 0;
253 } 258 }
254 case 8: { 259 case 8: {
255 if (num_params != 6) { 260 if (num_params != 6) {
(...skipping 21 matching lines...) Expand all
277 } 282 }
278 if (!ConvertScalarOutput(nap, params[5], false, &result_ptr)) { 283 if (!ConvertScalarOutput(nap, params[5], false, &result_ptr)) {
279 return -1; 284 return -1;
280 } 285 }
281 if (!ConvertArray(nap, params[2], num_bytes_value, 1, false, 286 if (!ConvertArray(nap, params[2], num_bytes_value, 1, false,
282 &elements)) { 287 &elements)) {
283 return -1; 288 return -1;
284 } 289 }
285 } 290 }
286 291
287 result_value = MojoReadData(data_pipe_consumer_handle_value, elements, 292 result_value =
288 &num_bytes_value, flags_value); 293 MojoSystemImplReadData(g_mojo_system, data_pipe_consumer_handle_value,
294 elements, &num_bytes_value, flags_value);
289 295
290 { 296 {
291 ScopedCopyLock copy_lock(nap); 297 ScopedCopyLock copy_lock(nap);
292 *num_bytes_ptr = num_bytes_value; 298 *num_bytes_ptr = num_bytes_value;
293 *result_ptr = result_value; 299 *result_ptr = result_value;
294 } 300 }
295 301
296 return 0; 302 return 0;
297 } 303 }
298 case 9: 304 case 9:
(...skipping 14 matching lines...) Expand all
313 return -1; 319 return -1;
314 } 320 }
315 if (!ConvertScalarInput(nap, params[2], &num_bytes_read_value)) { 321 if (!ConvertScalarInput(nap, params[2], &num_bytes_read_value)) {
316 return -1; 322 return -1;
317 } 323 }
318 if (!ConvertScalarOutput(nap, params[3], false, &result_ptr)) { 324 if (!ConvertScalarOutput(nap, params[3], false, &result_ptr)) {
319 return -1; 325 return -1;
320 } 326 }
321 } 327 }
322 328
323 result_value = MojoEndReadData(data_pipe_consumer_handle_value, 329 result_value = MojoSystemImplEndReadData(
324 num_bytes_read_value); 330 g_mojo_system, data_pipe_consumer_handle_value, num_bytes_read_value);
325 331
326 { 332 {
327 ScopedCopyLock copy_lock(nap); 333 ScopedCopyLock copy_lock(nap);
328 *result_ptr = result_value; 334 *result_ptr = result_value;
329 } 335 }
330 336
331 return 0; 337 return 0;
332 } 338 }
333 case 11: { 339 case 11: {
334 if (num_params != 2) { 340 if (num_params != 2) {
335 return -1; 341 return -1;
336 } 342 }
337 MojoTimeTicks volatile* result_ptr; 343 MojoTimeTicks volatile* result_ptr;
338 MojoTimeTicks result_value; 344 MojoTimeTicks result_value;
339 { 345 {
340 ScopedCopyLock copy_lock(nap); 346 ScopedCopyLock copy_lock(nap);
341 if (!ConvertScalarOutput(nap, params[1], false, &result_ptr)) { 347 if (!ConvertScalarOutput(nap, params[1], false, &result_ptr)) {
342 return -1; 348 return -1;
343 } 349 }
344 } 350 }
345 351
346 result_value = MojoGetTimeTicksNow(); 352 result_value = MojoSystemImplGetTimeTicksNow(g_mojo_system);
347 353
348 { 354 {
349 ScopedCopyLock copy_lock(nap); 355 ScopedCopyLock copy_lock(nap);
350 *result_ptr = result_value; 356 *result_ptr = result_value;
351 } 357 }
352 358
353 return 0; 359 return 0;
354 } 360 }
355 case 12: { 361 case 12: {
356 if (num_params != 3) { 362 if (num_params != 3) {
357 return -1; 363 return -1;
358 } 364 }
359 MojoHandle handle_value; 365 MojoHandle handle_value;
360 MojoResult volatile* result_ptr; 366 MojoResult volatile* result_ptr;
361 MojoResult result_value; 367 MojoResult result_value;
362 { 368 {
363 ScopedCopyLock copy_lock(nap); 369 ScopedCopyLock copy_lock(nap);
364 if (!ConvertScalarInput(nap, params[1], &handle_value)) { 370 if (!ConvertScalarInput(nap, params[1], &handle_value)) {
365 return -1; 371 return -1;
366 } 372 }
367 if (!ConvertScalarOutput(nap, params[2], false, &result_ptr)) { 373 if (!ConvertScalarOutput(nap, params[2], false, &result_ptr)) {
368 return -1; 374 return -1;
369 } 375 }
370 } 376 }
371 377
372 result_value = MojoClose(handle_value); 378 result_value = MojoSystemImplClose(g_mojo_system, handle_value);
373 379
374 { 380 {
375 ScopedCopyLock copy_lock(nap); 381 ScopedCopyLock copy_lock(nap);
376 *result_ptr = result_value; 382 *result_ptr = result_value;
377 } 383 }
378 384
379 return 0; 385 return 0;
380 } 386 }
381 case 13: { 387 case 13: {
382 if (num_params != 6) { 388 if (num_params != 6) {
(...skipping 18 matching lines...) Expand all
401 return -1; 407 return -1;
402 } 408 }
403 if (!ConvertScalarOutput(nap, params[4], true, &signals_state_ptr)) { 409 if (!ConvertScalarOutput(nap, params[4], true, &signals_state_ptr)) {
404 return -1; 410 return -1;
405 } 411 }
406 if (!ConvertScalarOutput(nap, params[5], false, &result_ptr)) { 412 if (!ConvertScalarOutput(nap, params[5], false, &result_ptr)) {
407 return -1; 413 return -1;
408 } 414 }
409 } 415 }
410 416
411 result_value = MojoWait(handle_value, signals_value, deadline_value, 417 result_value = MojoSystemImplWait(
412 signals_state_ptr ? &signals_state_value : NULL); 418 g_mojo_system, handle_value, signals_value, deadline_value,
419 signals_state_ptr ? &signals_state_value : NULL);
413 420
414 { 421 {
415 ScopedCopyLock copy_lock(nap); 422 ScopedCopyLock copy_lock(nap);
416 if (signals_state_ptr != NULL) { 423 if (signals_state_ptr != NULL) {
417 memcpy_volatile_out(signals_state_ptr, &signals_state_value, 424 memcpy_volatile_out(signals_state_ptr, &signals_state_value,
418 sizeof(MojoHandleSignalsState)); 425 sizeof(MojoHandleSignalsState));
419 } 426 }
420 *result_ptr = result_value; 427 *result_ptr = result_value;
421 } 428 }
422 429
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 if (!ConvertArray(nap, params[2], num_handles_value, sizeof(*signals), 464 if (!ConvertArray(nap, params[2], num_handles_value, sizeof(*signals),
458 false, &signals)) { 465 false, &signals)) {
459 return -1; 466 return -1;
460 } 467 }
461 if (!ConvertArray(nap, params[6], num_handles_value, 468 if (!ConvertArray(nap, params[6], num_handles_value,
462 sizeof(*signals_states), true, &signals_states)) { 469 sizeof(*signals_states), true, &signals_states)) {
463 return -1; 470 return -1;
464 } 471 }
465 } 472 }
466 473
467 result_value = MojoWaitMany( 474 result_value = MojoSystemImplWaitMany(
468 handles, signals, num_handles_value, deadline_value, 475 g_mojo_system, handles, signals, num_handles_value, deadline_value,
469 result_index_ptr ? &result_index_value : NULL, signals_states); 476 result_index_ptr ? &result_index_value : NULL, signals_states);
470 477
471 { 478 {
472 ScopedCopyLock copy_lock(nap); 479 ScopedCopyLock copy_lock(nap);
473 if (result_index_ptr != NULL) { 480 if (result_index_ptr != NULL) {
474 *result_index_ptr = result_index_value; 481 *result_index_ptr = result_index_value;
475 } 482 }
476 *result_ptr = result_value; 483 *result_ptr = result_value;
477 } 484 }
478 485
(...skipping 23 matching lines...) Expand all
502 if (!ConvertScalarInOut(nap, params[3], false, 509 if (!ConvertScalarInOut(nap, params[3], false,
503 &message_pipe_handle1_value, 510 &message_pipe_handle1_value,
504 &message_pipe_handle1_ptr)) { 511 &message_pipe_handle1_ptr)) {
505 return -1; 512 return -1;
506 } 513 }
507 if (!ConvertScalarOutput(nap, params[4], false, &result_ptr)) { 514 if (!ConvertScalarOutput(nap, params[4], false, &result_ptr)) {
508 return -1; 515 return -1;
509 } 516 }
510 } 517 }
511 518
512 result_value = MojoCreateMessagePipe(options, &message_pipe_handle0_value, 519 result_value = MojoSystemImplCreateMessagePipe(
513 &message_pipe_handle1_value); 520 g_mojo_system, options, &message_pipe_handle0_value,
521 &message_pipe_handle1_value);
514 522
515 { 523 {
516 ScopedCopyLock copy_lock(nap); 524 ScopedCopyLock copy_lock(nap);
517 *message_pipe_handle0_ptr = message_pipe_handle0_value; 525 *message_pipe_handle0_ptr = message_pipe_handle0_value;
518 *message_pipe_handle1_ptr = message_pipe_handle1_value; 526 *message_pipe_handle1_ptr = message_pipe_handle1_value;
519 *result_ptr = result_value; 527 *result_ptr = result_value;
520 } 528 }
521 529
522 return 0; 530 return 0;
523 } 531 }
(...skipping 28 matching lines...) Expand all
552 } 560 }
553 if (!ConvertArray(nap, params[2], num_bytes_value, 1, true, &bytes)) { 561 if (!ConvertArray(nap, params[2], num_bytes_value, 1, true, &bytes)) {
554 return -1; 562 return -1;
555 } 563 }
556 if (!ConvertArray(nap, params[4], num_handles_value, sizeof(*handles), 564 if (!ConvertArray(nap, params[4], num_handles_value, sizeof(*handles),
557 true, &handles)) { 565 true, &handles)) {
558 return -1; 566 return -1;
559 } 567 }
560 } 568 }
561 569
562 result_value = 570 result_value = MojoSystemImplWriteMessage(
563 MojoWriteMessage(message_pipe_handle_value, bytes, num_bytes_value, 571 g_mojo_system, message_pipe_handle_value, bytes, num_bytes_value,
564 handles, num_handles_value, flags_value); 572 handles, num_handles_value, flags_value);
565 573
566 { 574 {
567 ScopedCopyLock copy_lock(nap); 575 ScopedCopyLock copy_lock(nap);
568 *result_ptr = result_value; 576 *result_ptr = result_value;
569 } 577 }
570 578
571 return 0; 579 return 0;
572 } 580 }
573 case 17: { 581 case 17: {
574 if (num_params != 8) { 582 if (num_params != 8) {
(...skipping 30 matching lines...) Expand all
605 } 613 }
606 if (!ConvertArray(nap, params[2], num_bytes_value, 1, true, &bytes)) { 614 if (!ConvertArray(nap, params[2], num_bytes_value, 1, true, &bytes)) {
607 return -1; 615 return -1;
608 } 616 }
609 if (!ConvertArray(nap, params[4], num_handles_value, sizeof(*handles), 617 if (!ConvertArray(nap, params[4], num_handles_value, sizeof(*handles),
610 true, &handles)) { 618 true, &handles)) {
611 return -1; 619 return -1;
612 } 620 }
613 } 621 }
614 622
615 result_value = MojoReadMessage( 623 result_value = MojoSystemImplReadMessage(
616 message_pipe_handle_value, bytes, 624 g_mojo_system, message_pipe_handle_value, bytes,
617 num_bytes_ptr ? &num_bytes_value : NULL, handles, 625 num_bytes_ptr ? &num_bytes_value : NULL, handles,
618 num_handles_ptr ? &num_handles_value : NULL, flags_value); 626 num_handles_ptr ? &num_handles_value : NULL, flags_value);
619 627
620 { 628 {
621 ScopedCopyLock copy_lock(nap); 629 ScopedCopyLock copy_lock(nap);
622 if (num_bytes_ptr != NULL) { 630 if (num_bytes_ptr != NULL) {
623 *num_bytes_ptr = num_bytes_value; 631 *num_bytes_ptr = num_bytes_value;
624 } 632 }
625 if (num_handles_ptr != NULL) { 633 if (num_handles_ptr != NULL) {
626 *num_handles_ptr = num_handles_value; 634 *num_handles_ptr = num_handles_value;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 return NaClDescMakeCustomDesc(nap, &funcs); 711 return NaClDescMakeCustomDesc(nap, &funcs);
704 } 712 }
705 713
706 } // namespace 714 } // namespace
707 715
708 // The value for this FD must not conflict with uses inside Chromium. However, 716 // The value for this FD must not conflict with uses inside Chromium. However,
709 // mojo/nacl doesn't depend on any Chromium headers, so we can't use a #define 717 // mojo/nacl doesn't depend on any Chromium headers, so we can't use a #define
710 // from there. 718 // from there.
711 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 3) 719 #define NACL_MOJO_DESC (NACL_CHROME_DESC_BASE + 3)
712 720
713 void InjectMojo(struct NaClApp* nap) {
714 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
715 g_mojo_handle = MOJO_HANDLE_INVALID;
716 }
717
718 void InjectMojo(struct NaClApp* nap, MojoHandle handle) { 721 void InjectMojo(struct NaClApp* nap, MojoHandle handle) {
719 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap)); 722 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap));
720 g_mojo_handle = handle; 723 g_mojo_system = MojoSystemImplCreateImpl();
724 // TODO(ncbray): handle errors?
725 MojoSystemImplTransferHandle(MojoSystemImplGetDefaultImpl(), handle,
726 g_mojo_system, &g_mojo_handle);
721 } 727 }
722 728
723 void InjectDisabledMojo(struct NaClApp* nap) { 729 void InjectDisabledMojo(struct NaClApp* nap) {
724 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeDisabledMojoDesc(nap)); 730 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeDisabledMojoDesc(nap));
725 } 731 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698