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.
5 #include "native_client/src/public/irt_core.h"
6 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h"
7 #include "native_client/src/untrusted/irt/irt.h"
8 #include "native_client/src/untrusted/irt/irt_private.h"
9 #include "ppapi/nacl_irt/irt_ppapi.h"
10 #include "ppapi/nacl_irt/plugin_main.h"
11 #include "ppapi/nacl_irt/public/irt_ppapi.h"
12 #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/irt_shim_ppapi.h"
14 static struct PP_StartFunctions g_pp_functions
;
16 int irt_ppapi_start(const struct PP_StartFunctions
* funcs
) {
17 // Disable NaCl's open_resource() interface on this thread.
20 g_pp_functions
= *funcs
;
21 return PpapiPluginMain();
24 int32_t PPP_InitializeModule(PP_Module module_id
,
25 PPB_GetInterface get_browser_interface
) {
26 return g_pp_functions
.PPP_InitializeModule(module_id
, get_browser_interface
);
29 void PPP_ShutdownModule(void) {
30 g_pp_functions
.PPP_ShutdownModule();
33 const void* PPP_GetInterface(const char* interface_name
) {
34 return g_pp_functions
.PPP_GetInterface(interface_name
);
37 static const struct nacl_irt_ppapihook nacl_irt_ppapihook
= {
39 PpapiPluginRegisterThreadCreator
,
42 static int ppapihook_pnacl_private_filter(void) {
43 int pnacl_mode
= sysconf(NACL_ABI__SC_NACL_PNACL_MODE
);
49 static const struct nacl_irt_interface irt_interfaces
[] = {
50 { NACL_IRT_PPAPIHOOK_v0_1
, &nacl_irt_ppapihook
, sizeof(nacl_irt_ppapihook
),
52 { NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1
,
53 &nacl_irt_ppapihook_pnacl_private
, sizeof(nacl_irt_ppapihook_pnacl_private
),
54 ppapihook_pnacl_private_filter
},
57 size_t chrome_irt_query(const char* interface_ident
,
58 void* table
, size_t tablesize
) {
59 size_t result
= nacl_irt_query_core(interface_ident
, table
, tablesize
);
62 return nacl_irt_query_list(interface_ident
, table
, tablesize
,
63 irt_interfaces
, sizeof(irt_interfaces
));