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

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

Issue 10826171: Incorporate shimming into the irt (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 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 <string.h> 7 #include <string.h>
8 8
9 #include "native_client/src/include/nacl_macros.h" 9 #include "native_client/src/include/nacl_macros.h"
10 #include "native_client/src/untrusted/irt/irt.h" 10 #include "native_client/src/untrusted/irt/irt.h"
(...skipping 12 matching lines...) Expand all
23 { NACL_IRT_MEMORY_v0_1, &nacl_irt_memory, sizeof(nacl_irt_memory) }, 23 { NACL_IRT_MEMORY_v0_1, &nacl_irt_memory, sizeof(nacl_irt_memory) },
24 { NACL_IRT_DYNCODE_v0_1, &nacl_irt_dyncode, sizeof(nacl_irt_dyncode) }, 24 { NACL_IRT_DYNCODE_v0_1, &nacl_irt_dyncode, sizeof(nacl_irt_dyncode) },
25 { NACL_IRT_THREAD_v0_1, &nacl_irt_thread, sizeof(nacl_irt_thread) }, 25 { NACL_IRT_THREAD_v0_1, &nacl_irt_thread, sizeof(nacl_irt_thread) },
26 { NACL_IRT_MUTEX_v0_1, &nacl_irt_mutex, sizeof(nacl_irt_mutex) }, 26 { NACL_IRT_MUTEX_v0_1, &nacl_irt_mutex, sizeof(nacl_irt_mutex) },
27 { NACL_IRT_COND_v0_1, &nacl_irt_cond, sizeof(nacl_irt_cond) }, 27 { NACL_IRT_COND_v0_1, &nacl_irt_cond, sizeof(nacl_irt_cond) },
28 { NACL_IRT_SEM_v0_1, &nacl_irt_sem, sizeof(nacl_irt_sem) }, 28 { NACL_IRT_SEM_v0_1, &nacl_irt_sem, sizeof(nacl_irt_sem) },
29 { NACL_IRT_TLS_v0_1, &nacl_irt_tls, sizeof(nacl_irt_tls) }, 29 { NACL_IRT_TLS_v0_1, &nacl_irt_tls, sizeof(nacl_irt_tls) },
30 { NACL_IRT_BLOCKHOOK_v0_1, &nacl_irt_blockhook, sizeof(nacl_irt_blockhook) }, 30 { NACL_IRT_BLOCKHOOK_v0_1, &nacl_irt_blockhook, sizeof(nacl_irt_blockhook) },
31 { NACL_IRT_RESOURCE_OPEN_v0_1, &nacl_irt_resource_open, 31 { NACL_IRT_RESOURCE_OPEN_v0_1, &nacl_irt_resource_open,
32 sizeof(nacl_irt_resource_open) }, 32 sizeof(nacl_irt_resource_open) },
33 /* @IGNORE_LINES_FOR_CODE_HYGIENE[1] */
33 #ifdef IRT_PPAPI 34 #ifdef IRT_PPAPI
34 { NACL_IRT_PPAPIHOOK_v0_1, &nacl_irt_ppapihook, sizeof(nacl_irt_ppapihook) }, 35 { NACL_IRT_PPAPIHOOK_v0_1, &nacl_irt_ppapihook, sizeof(nacl_irt_ppapihook) },
35 { NACL_IRT_RANDOM_v0_1, &nacl_irt_random, sizeof(nacl_irt_random) }, 36 { NACL_IRT_RANDOM_v0_1, &nacl_irt_random, sizeof(nacl_irt_random) },
36 #endif 37 #endif
37 { NACL_IRT_CLOCK_v0_1, &nacl_irt_clock, sizeof(nacl_irt_clock) }, 38 { NACL_IRT_CLOCK_v0_1, &nacl_irt_clock, sizeof(nacl_irt_clock) },
38 { NACL_IRT_DEV_EXCEPTION_HANDLING_v0_1, &nacl_irt_dev_exception_handling, 39 { NACL_IRT_DEV_EXCEPTION_HANDLING_v0_1, &nacl_irt_dev_exception_handling,
39 sizeof(nacl_irt_dev_exception_handling) }, 40 sizeof(nacl_irt_dev_exception_handling) },
40 }; 41 };
41 42
43 /* controls whether cc shim'ed tables should be used */
44 int g_use_cc_shim = 0;
45
42 size_t nacl_irt_interface(const char *interface_ident, 46 size_t nacl_irt_interface(const char *interface_ident,
43 void *table, size_t tablesize) { 47 void *table,
44 int i; 48 size_t tablesize) {
45 for (i = 0; i < NACL_ARRAY_SIZE(irt_interfaces); ++i) { 49 /*
50 * fast track for a few hooks indicated by a leading '@'
51 * Other things that could be added here:
52 * * irt verbosity control
53 * * irt strict mode (abort on failure)
54 * * etc.
55 */
56 if (interface_ident[0] == '@') {
Roland McGrath 2012/08/06 23:32:24 I don't see any defensible rationale for this klud
Robert Muth (chromium) 2012/08/07 14:45:40 added a new interface but this will likely complic
57 if (0 == strcmp(interface_ident, "@nacl-cc-shim-mode")) {
58 g_use_cc_shim = 1;
59 }
60 /* TODO(robertm): add better error/success handling */
61 return 0;
62 }
63
64 for (int i = 0; i < NACL_ARRAY_SIZE(irt_interfaces); ++i) {
46 if (0 == strcmp(interface_ident, irt_interfaces[i].name)) { 65 if (0 == strcmp(interface_ident, irt_interfaces[i].name)) {
47 const size_t size = irt_interfaces[i].size; 66 const size_t size = irt_interfaces[i].size;
48 if (size <= tablesize) { 67 if (size <= tablesize) {
49 memcpy(table, irt_interfaces[i].table, size); 68 memcpy(table, irt_interfaces[i].table, size);
50 return size; 69 return size;
51 } 70 }
52 break; 71 break;
53 } 72 }
54 } 73 }
55 return 0; 74 return 0;
56 } 75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698