Add a stub __cxa_demangle to disable LLVM's demangler.
[chromium-blink-merge.git] / ppapi / nacl_irt / irt_ppapi.cc
bloba9c13eb89072a14a4b007c5033b5a41869e8df6d
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 <unistd.h>
7 #include "build/build_config.h"
8 #include "native_client/src/public/irt_core.h"
9 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h"
10 #include "native_client/src/untrusted/irt/irt.h"
11 #include "ppapi/nacl_irt/irt_manifest.h"
12 #include "ppapi/nacl_irt/irt_ppapi.h"
13 #include "ppapi/nacl_irt/plugin_main.h"
14 #include "ppapi/nacl_irt/public/irt_ppapi.h"
15 #include "ppapi/native_client/src/untrusted/pnacl_irt_shim/irt_shim_ppapi.h"
17 static struct PP_StartFunctions g_pp_functions;
19 int irt_ppapi_start(const struct PP_StartFunctions* funcs) {
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 = {
38 irt_ppapi_start,
39 PpapiPluginRegisterThreadCreator,
42 #if defined(OS_NACL_SFI)
43 static int ppapihook_pnacl_private_filter(void) {
44 int pnacl_mode = sysconf(NACL_ABI__SC_NACL_PNACL_MODE);
45 if (pnacl_mode == -1)
46 return 0;
47 return pnacl_mode;
49 #endif
51 static const nacl_irt_resource_open kIrtResourceOpen = {
52 ppapi::IrtOpenResource,
55 #if defined(OS_NACL_SFI)
56 static int not_pnacl_filter(void) {
57 int pnacl_mode = sysconf(NACL_ABI__SC_NACL_PNACL_MODE);
58 if (pnacl_mode == -1)
59 return 0;
60 return !pnacl_mode;
62 #endif
64 static const struct nacl_irt_interface irt_interfaces[] = {
65 { NACL_IRT_PPAPIHOOK_v0_1, &nacl_irt_ppapihook, sizeof(nacl_irt_ppapihook),
66 NULL },
67 #if defined(OS_NACL_SFI)
68 { NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1,
69 &nacl_irt_ppapihook_pnacl_private, sizeof(nacl_irt_ppapihook_pnacl_private),
70 ppapihook_pnacl_private_filter },
71 #endif
72 { NACL_IRT_RESOURCE_OPEN_v0_1, &kIrtResourceOpen,
73 sizeof(kIrtResourceOpen),
74 #if defined(OS_NACL_SFI)
75 not_pnacl_filter,
76 #else
77 // If we change PNaCl to use Non-SFI Mode on the open web,
78 // we should add a filter here.
79 NULL,
80 #endif
84 size_t chrome_irt_query(const char* interface_ident,
85 void* table, size_t tablesize) {
86 size_t result = nacl_irt_query_list(interface_ident,
87 table,
88 tablesize,
89 irt_interfaces,
90 sizeof(irt_interfaces));
91 if (result != 0)
92 return result;
94 return nacl_irt_query_core(interface_ident, table, tablesize);