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

Side by Side Diff: components/nacl/loader/nonsfi/irt/irt_interfaces.cc

Issue 125533004: Initial implementation of IRT for non-SFI mode. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 11 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
(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 #include "components/nacl/loader/nonsfi/irt/irt_interfaces.h"
6
7 #include <cstring>
8
9 namespace nacl {
10 namespace nonsfi {
11
12 extern const struct nacl_irt_basic kIrtBasic;
Mark Seaborn 2014/01/07 09:45:06 This is already declared in the header
hidehiko 2014/01/07 11:52:29 Oops. I misoperated...
13
14 namespace {
15
16 // This table keeps a pair of IRT entry (such as nacl_irt_basic, nacl_irt_fdio
17 // etc.) and its registered name with its version (such as NACL_IRT_BASIC_v0_1,
18 // NACL_IRT_FDIO_v0_1, etc.).
19 struct NaClInterfaceTable {
20 const char* name;
21 const void* table;
22 size_t size;
23
24 template<typename T>
25 NaClInterfaceTable(const char* name, const T& value)
Mark Seaborn 2014/01/07 09:45:06 I'm pretty sure using a constructor like this make
hidehiko 2014/01/07 11:52:29 I see, done.
26 : name(name), table(&value), size(sizeof(value)) {
27 }
28 };
29
30 const NaClInterfaceTable kIrtInterfaces[] = {
31 NaClInterfaceTable(NACL_IRT_BASIC_v0_1, kIrtBasic),
32 };
33
34 } // namespace
35
36 size_t NaClIrtInterface(const char* interface_ident,
37 void* table, size_t tablesize) {
38 for (size_t i = 0; i < arraysize(kIrtInterfaces); ++i) {
39 if (std::strcmp(interface_ident, kIrtInterfaces[i].name) == 0) {
40 const size_t size = kIrtInterfaces[i].size;
41 if (size <= tablesize) {
42 std::memcpy(table, kIrtInterfaces[i].table, size);
43 return size;
44 }
45 break;
46 }
47 }
48 return 0;
49 }
50
51 } // namespace nonsfi
52 } // namespace nacl
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698