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

Side by Side Diff: src/untrusted/nacl/nacl_ext_supply.c

Issue 511253005: Added irt extension support for supplying the nacl_irt_memory interface. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Moved size declaration down Created 6 years, 3 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
« no previous file with comments | « no previous file | tests/irt_ext/file_desc.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2014 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_dev.h" 10 #include "native_client/src/untrusted/irt/irt_dev.h"
11 #include "native_client/src/untrusted/irt/irt_extension.h" 11 #include "native_client/src/untrusted/irt/irt_extension.h"
12 #include "native_client/src/untrusted/nacl/nacl_irt.h" 12 #include "native_client/src/untrusted/nacl/nacl_irt.h"
13 13
14 static size_t ext_struct_memcpy_init(void *dest_table, const void *src_table,
15 size_t tablesize) {
16 memcpy(dest_table, src_table, tablesize);
17 return tablesize;
18 }
19
20 struct nacl_irt_ext_struct { 14 struct nacl_irt_ext_struct {
21 const char *interface_ident; 15 const char *interface_ident;
22 void *table; 16 void *table;
23 size_t tablesize; 17 size_t tablesize;
24 }; 18 };
25 19
26 static const struct nacl_irt_ext_struct nacl_irt_ext_structs[] = { 20 static const struct nacl_irt_ext_struct nacl_irt_ext_structs[] = {
27 { 21 {
28 .interface_ident = NACL_IRT_DEV_FDIO_v0_3, 22 .interface_ident = NACL_IRT_DEV_FDIO_v0_3,
29 .table = &__libnacl_irt_dev_fdio, 23 .table = &__libnacl_irt_dev_fdio,
30 .tablesize = sizeof(__libnacl_irt_dev_fdio) 24 .tablesize = sizeof(__libnacl_irt_dev_fdio),
31 }, {
32 .interface_ident = NACL_IRT_DEV_FDIO_v0_2,
33 .table = &__libnacl_irt_dev_fdio,
34 .tablesize = sizeof(struct nacl_irt_dev_fdio_v0_2)
35 }, {
36 .interface_ident = NACL_IRT_FDIO_v0_1,
37 .table = &__libnacl_irt_fdio,
38 .tablesize = sizeof(__libnacl_irt_fdio)
39 }, { 25 }, {
40 .interface_ident = NACL_IRT_DEV_FILENAME_v0_3, 26 .interface_ident = NACL_IRT_DEV_FILENAME_v0_3,
41 .table = &__libnacl_irt_dev_filename, 27 .table = &__libnacl_irt_dev_filename,
42 .tablesize = sizeof(__libnacl_irt_dev_filename) 28 .tablesize = sizeof(__libnacl_irt_dev_filename),
43 }, { 29 }, {
44 .interface_ident = NACL_IRT_DEV_FILENAME_v0_2, 30 .interface_ident = NACL_IRT_MEMORY_v0_3,
45 .table = &__libnacl_irt_dev_filename, 31 .table = &__libnacl_irt_memory,
46 .tablesize = sizeof(struct nacl_irt_dev_filename_v0_2) 32 .tablesize = sizeof(struct nacl_irt_memory),
47 }, {
48 .interface_ident = NACL_IRT_FILENAME_v0_1,
49 .table = &__libnacl_irt_dev_filename,
50 .tablesize = sizeof(struct nacl_irt_filename)
51 }, 33 },
52 }; 34 };
53 35
54 size_t nacl_interface_ext_supply(const char *interface_ident, 36 size_t nacl_interface_ext_supply(const char *interface_ident,
55 const void *table, size_t tablesize) { 37 const void *table, size_t tablesize) {
56 for (int i = 0; i < NACL_ARRAY_SIZE(nacl_irt_ext_structs); i++) { 38 for (int i = 0; i < NACL_ARRAY_SIZE(nacl_irt_ext_structs); i++) {
57 if (nacl_irt_ext_structs[i].tablesize == tablesize && 39 if (nacl_irt_ext_structs[i].tablesize == tablesize &&
58 strcmp(nacl_irt_ext_structs[i].interface_ident, interface_ident) == 0) { 40 strcmp(nacl_irt_ext_structs[i].interface_ident, interface_ident) == 0) {
59 return ext_struct_memcpy_init(nacl_irt_ext_structs[i].table, 41 memcpy(nacl_irt_ext_structs[i].table, table, tablesize);
60 table, 42 return tablesize;
61 tablesize);
62 } 43 }
63 } 44 }
64 45
65 return 0; 46 return 0;
66 } 47 }
OLDNEW
« no previous file with comments | « no previous file | tests/irt_ext/file_desc.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698