1 // Copyright 2015 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.
5 #include "ppapi/nacl_irt/irt_interfaces.h"
9 #include "build/build_config.h"
10 #include "native_client/src/public/irt_core.h"
11 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h"
12 #include "native_client/src/untrusted/irt/irt.h"
13 #include "native_client/src/untrusted/irt/irt_dev.h"
14 #include "ppapi/nacl_irt/irt_manifest.h"
15 #include "ppapi/nacl_irt/public/irt_ppapi.h"
16 #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/irt_shim_ppapi.h"
18 #if defined(OS_NACL_SFI)
19 static int ppapihook_pnacl_private_filter(void) {
20 int pnacl_mode
= sysconf(NACL_ABI__SC_NACL_PNACL_MODE
);
27 static const nacl_irt_resource_open kIrtResourceOpen
= {
28 ppapi::IrtOpenResource
,
31 #if defined(OS_NACL_SFI)
32 static int not_pnacl_filter(void) {
33 int pnacl_mode
= sysconf(NACL_ABI__SC_NACL_PNACL_MODE
);
40 static const struct nacl_irt_interface irt_interfaces
[] = {
41 { NACL_IRT_PPAPIHOOK_v0_1
, &nacl_irt_ppapihook
, sizeof(nacl_irt_ppapihook
),
43 #if defined(OS_NACL_SFI)
44 { NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1
,
45 &nacl_irt_ppapihook_pnacl_private
, sizeof(nacl_irt_ppapihook_pnacl_private
),
46 ppapihook_pnacl_private_filter
},
48 { NACL_IRT_RESOURCE_OPEN_v0_1
, &kIrtResourceOpen
,
49 sizeof(kIrtResourceOpen
),
50 #if defined(OS_NACL_SFI)
53 // If we change PNaCl to use Non-SFI Mode on the open web,
54 // we should add a filter here.
58 #if defined(OS_NACL_SFI)
59 // TODO(mseaborn): Ideally these two PNaCl translator interfaces should
60 // be hidden in processes that aren't PNaCl sandboxed translator
61 // processes. However, we haven't yet plumbed though a flag to indicate
62 // when a NaCl process is a PNaCl translator process. The risk of an app
63 // accidentally depending on the presence of this interface is much lower
64 // than for other non-stable IRT interfaces, because this interface is
65 // not useful to apps.
66 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_LINK_v0_1
,
67 &nacl_irt_private_pnacl_translator_link
,
68 sizeof(nacl_irt_private_pnacl_translator_link
), NULL
},
69 { NACL_IRT_PRIVATE_PNACL_TRANSLATOR_COMPILE_v0_1
,
70 &nacl_irt_private_pnacl_translator_compile
,
71 sizeof(nacl_irt_private_pnacl_translator_compile
), NULL
},
75 size_t chrome_irt_query(const char* interface_ident
,
76 void* table
, size_t tablesize
) {
77 size_t result
= nacl_irt_query_list(interface_ident
,
81 sizeof(irt_interfaces
));
85 return nacl_irt_query_core(interface_ident
, table
, tablesize
);