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

Side by Side Diff: src/nonsfi/irt/irt_interfaces.c

Issue 686723003: Non-SFI mode: Implement nacl_irt_random only for nacl_helper_nonsfi. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2013 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 #include "native_client/src/nonsfi/irt/irt_interfaces.h" 7 #include "native_client/src/nonsfi/irt/irt_interfaces.h"
8 8
9 #include <assert.h> 9 #include <assert.h>
10 #include <errno.h> 10 #include <errno.h>
(...skipping 19 matching lines...) Expand all
30 #include "native_client/src/nonsfi/linux/irt_exception_handling.h" 30 #include "native_client/src/nonsfi/linux/irt_exception_handling.h"
31 #include "native_client/src/public/irt_core.h" 31 #include "native_client/src/public/irt_core.h"
32 #include "native_client/src/trusted/service_runtime/include/machine/_types.h" 32 #include "native_client/src/trusted/service_runtime/include/machine/_types.h"
33 #include "native_client/src/trusted/service_runtime/include/sys/mman.h" 33 #include "native_client/src/trusted/service_runtime/include/sys/mman.h"
34 #include "native_client/src/trusted/service_runtime/include/sys/stat.h" 34 #include "native_client/src/trusted/service_runtime/include/sys/stat.h"
35 #include "native_client/src/trusted/service_runtime/include/sys/time.h" 35 #include "native_client/src/trusted/service_runtime/include/sys/time.h"
36 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h" 36 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h"
37 #include "native_client/src/untrusted/irt/irt.h" 37 #include "native_client/src/untrusted/irt/irt.h"
38 #include "native_client/src/untrusted/irt/irt_dev.h" 38 #include "native_client/src/untrusted/irt/irt_dev.h"
39 #include "native_client/src/untrusted/irt/irt_interfaces.h" 39 #include "native_client/src/untrusted/irt/irt_interfaces.h"
40 #include "native_client/src/untrusted/nacl/nacl_random.h"
40 41
41 /* 42 /*
42 * This is an implementation of NaCl's IRT interfaces that runs 43 * This is an implementation of NaCl's IRT interfaces that runs
43 * outside of the NaCl sandbox. 44 * outside of the NaCl sandbox.
44 * 45 *
45 * This allows PNaCl to be used as a portability layer without the 46 * This allows PNaCl to be used as a portability layer without the
46 * SFI-based sandboxing. PNaCl pexes can be translated to 47 * SFI-based sandboxing. PNaCl pexes can be translated to
47 * non-SFI-sandboxed native code and linked against this IRT 48 * non-SFI-sandboxed native code and linked against this IRT
48 * implementation. 49 * implementation.
49 */ 50 */
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 static int futex_wake(volatile int *addr, int nwake, int *count) { 425 static int futex_wake(volatile int *addr, int nwake, int *count) {
425 int result = syscall(__NR_futex, addr, FUTEX_WAKE | FUTEX_PRIVATE_FLAG, 426 int result = syscall(__NR_futex, addr, FUTEX_WAKE | FUTEX_PRIVATE_FLAG,
426 nwake, 0, 0, 0); 427 nwake, 0, 0, 0);
427 if (result < 0) 428 if (result < 0)
428 return errno; 429 return errno;
429 *count = result; 430 *count = result;
430 return 0; 431 return 0;
431 } 432 }
432 #endif 433 #endif
433 434
435
Mark Seaborn 2014/11/04 01:19:52 Nit: don't add empty line here
hidehiko 2014/11/04 11:16:58 Oops. Removed.
434 #if defined(__linux__) || defined(__native_client__) 436 #if defined(__linux__) || defined(__native_client__)
435 static int irt_clock_getres(nacl_irt_clockid_t clk_id, 437 static int irt_clock_getres(nacl_irt_clockid_t clk_id,
436 struct timespec *time_nacl) { 438 struct timespec *time_nacl) {
437 struct timespec time; 439 struct timespec time;
438 int result = check_error(clock_getres(clk_id, &time)); 440 int result = check_error(clock_getres(clk_id, &time));
439 /* 441 /*
440 * The timespec pointer is allowed to be NULL for clock_getres() though 442 * The timespec pointer is allowed to be NULL for clock_getres() though
441 * not for clock_gettime(). 443 * not for clock_gettime().
442 */ 444 */
443 if (time_nacl != NULL) 445 if (time_nacl != NULL)
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
592 }; 594 };
593 #elif !defined(__native_client__) 595 #elif !defined(__native_client__)
594 DEFINE_STUB(futex_wait_abs) 596 DEFINE_STUB(futex_wait_abs)
595 DEFINE_STUB(futex_wake) 597 DEFINE_STUB(futex_wake)
596 const struct nacl_irt_futex nacl_irt_futex = { 598 const struct nacl_irt_futex nacl_irt_futex = {
597 USE_STUB(nacl_irt_futex, futex_wait_abs), 599 USE_STUB(nacl_irt_futex, futex_wait_abs),
598 USE_STUB(nacl_irt_futex, futex_wake), 600 USE_STUB(nacl_irt_futex, futex_wake),
599 }; 601 };
600 #endif 602 #endif
601 603
604 const struct nacl_irt_random nacl_irt_random = {
Mark Seaborn 2014/11/04 01:19:52 Please run the PNaCl toolchain trybots to check th
hidehiko 2014/11/04 11:16:59 Good catch! Fixed.
605 nacl_secure_random,
606 };
607
602 #if defined(__linux__) || defined(__native_client__) 608 #if defined(__linux__) || defined(__native_client__)
603 const struct nacl_irt_clock nacl_irt_clock = { 609 const struct nacl_irt_clock nacl_irt_clock = {
604 irt_clock_getres, 610 irt_clock_getres,
605 irt_clock_gettime, 611 irt_clock_gettime,
606 }; 612 };
607 #endif 613 #endif
608 614
609 DEFINE_STUB(utimes) 615 DEFINE_STUB(utimes)
610 const struct nacl_irt_dev_filename nacl_irt_dev_filename = { 616 const struct nacl_irt_dev_filename nacl_irt_dev_filename = {
611 irt_open, 617 irt_open,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 }; 649 };
644 #endif 650 #endif
645 651
646 static const struct nacl_irt_interface irt_interfaces[] = { 652 static const struct nacl_irt_interface irt_interfaces[] = {
647 { NACL_IRT_BASIC_v0_1, &nacl_irt_basic, sizeof(nacl_irt_basic), NULL }, 653 { NACL_IRT_BASIC_v0_1, &nacl_irt_basic, sizeof(nacl_irt_basic), NULL },
648 { NACL_IRT_FDIO_v0_1, &nacl_irt_fdio, sizeof(nacl_irt_fdio), NULL }, 654 { NACL_IRT_FDIO_v0_1, &nacl_irt_fdio, sizeof(nacl_irt_fdio), NULL },
649 { NACL_IRT_MEMORY_v0_3, &nacl_irt_memory, sizeof(nacl_irt_memory), NULL }, 655 { NACL_IRT_MEMORY_v0_3, &nacl_irt_memory, sizeof(nacl_irt_memory), NULL },
650 { NACL_IRT_TLS_v0_1, &nacl_irt_tls, sizeof(nacl_irt_tls), NULL }, 656 { NACL_IRT_TLS_v0_1, &nacl_irt_tls, sizeof(nacl_irt_tls), NULL },
651 { NACL_IRT_THREAD_v0_1, &nacl_irt_thread, sizeof(nacl_irt_thread), NULL }, 657 { NACL_IRT_THREAD_v0_1, &nacl_irt_thread, sizeof(nacl_irt_thread), NULL },
652 { NACL_IRT_FUTEX_v0_1, &nacl_irt_futex, sizeof(nacl_irt_futex), NULL }, 658 { NACL_IRT_FUTEX_v0_1, &nacl_irt_futex, sizeof(nacl_irt_futex), NULL },
659 { NACL_IRT_RANDOM_v0_1, &nacl_irt_random, sizeof(nacl_irt_random), NULL },
653 #if defined(__linux__) || defined(__native_client__) 660 #if defined(__linux__) || defined(__native_client__)
654 { NACL_IRT_CLOCK_v0_1, &nacl_irt_clock, sizeof(nacl_irt_clock), NULL }, 661 { NACL_IRT_CLOCK_v0_1, &nacl_irt_clock, sizeof(nacl_irt_clock), NULL },
655 #endif 662 #endif
656 { NACL_IRT_DEV_FILENAME_v0_3, &nacl_irt_dev_filename, 663 { NACL_IRT_DEV_FILENAME_v0_3, &nacl_irt_dev_filename,
657 sizeof(nacl_irt_dev_filename), NULL }, 664 sizeof(nacl_irt_dev_filename), NULL },
658 { NACL_IRT_DEV_GETPID_v0_1, &nacl_irt_dev_getpid, 665 { NACL_IRT_DEV_GETPID_v0_1, &nacl_irt_dev_getpid,
659 sizeof(nacl_irt_dev_getpid), NULL }, 666 sizeof(nacl_irt_dev_getpid), NULL },
660 #if defined(__native_client__) 667 #if defined(__native_client__)
661 { NACL_IRT_EXCEPTION_HANDLING_v0_1, &nacl_irt_exception_handling, 668 { NACL_IRT_EXCEPTION_HANDLING_v0_1, &nacl_irt_exception_handling,
662 sizeof(nacl_irt_exception_handling), NULL}, 669 sizeof(nacl_irt_exception_handling), NULL},
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 nacl_entry_func_t entry_func = 730 nacl_entry_func_t entry_func =
724 #if defined(__APPLE__) 731 #if defined(__APPLE__)
725 _start; 732 _start;
726 #else 733 #else
727 _user_start; 734 _user_start;
728 #endif 735 #endif
729 736
730 return nacl_irt_nonsfi_entry(argc, argv, environ, entry_func); 737 return nacl_irt_nonsfi_entry(argc, argv, environ, entry_func);
731 } 738 }
732 #endif 739 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698