 Chromium Code Reviews
 Chromium Code Reviews Issue 164373010:
  Split the PNaCl IRT shim into 3 pieces, and include one piece into IRT.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src
    
  
    Issue 164373010:
  Split the PNaCl IRT shim into 3 pieces, and include one piece into IRT.  (Closed) 
  Base URL: svn://svn.chromium.org/chrome/trunk/src| OLD | NEW | 
|---|---|
| 1 /* | 1 /* | 
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium 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 "native_client/src/public/irt_core.h" | 7 #include "native_client/src/public/irt_core.h" | 
| 8 #include "native_client/src/trusted/service_runtime/include/sys/unistd.h" | |
| 8 #include "native_client/src/untrusted/irt/irt.h" | 9 #include "native_client/src/untrusted/irt/irt.h" | 
| 9 #include "native_client/src/untrusted/irt/irt_private.h" | 10 #include "native_client/src/untrusted/irt/irt_private.h" | 
| 10 #include "ppapi/nacl_irt/irt_ppapi.h" | 11 #include "ppapi/nacl_irt/irt_ppapi.h" | 
| 11 #include "ppapi/proxy/plugin_main_irt.h" | 12 #include "ppapi/proxy/plugin_main_irt.h" | 
| 13 #include "ppapi/proxy/irt_shim_ppapi.h" | |
| 12 | 14 | 
| 13 struct PP_StartFunctions g_pp_functions; | 15 static struct PP_StartFunctions g_pp_functions; | 
| 14 | 16 | 
| 15 static int irt_ppapi_start(const struct PP_StartFunctions* funcs) { | 17 int irt_ppapi_start(const struct PP_StartFunctions* funcs) { | 
| 16 /* Disable NaCl's open_resource() interface on this thread. */ | 18 /* Disable NaCl's open_resource() interface on this thread. */ | 
| 17 g_is_main_thread = 1; | 19 g_is_main_thread = 1; | 
| 18 | 20 | 
| 19 g_pp_functions = *funcs; | 21 g_pp_functions = *funcs; | 
| 20 return PpapiPluginMain(); | 22 return PpapiPluginMain(); | 
| 21 } | 23 } | 
| 22 | 24 | 
| 23 int32_t PPP_InitializeModule(PP_Module module_id, | 25 int32_t PPP_InitializeModule(PP_Module module_id, | 
| 24 PPB_GetInterface get_browser_interface) { | 26 PPB_GetInterface get_browser_interface) { | 
| 25 return g_pp_functions.PPP_InitializeModule(module_id, get_browser_interface); | 27 return g_pp_functions.PPP_InitializeModule(module_id, get_browser_interface); | 
| 26 } | 28 } | 
| 27 | 29 | 
| 28 void PPP_ShutdownModule(void) { | 30 void PPP_ShutdownModule(void) { | 
| 29 g_pp_functions.PPP_ShutdownModule(); | 31 g_pp_functions.PPP_ShutdownModule(); | 
| 30 } | 32 } | 
| 31 | 33 | 
| 32 const void* PPP_GetInterface(const char* interface_name) { | 34 const void* PPP_GetInterface(const char* interface_name) { | 
| 33 return g_pp_functions.PPP_GetInterface(interface_name); | 35 return g_pp_functions.PPP_GetInterface(interface_name); | 
| 34 } | 36 } | 
| 35 | 37 | 
| 36 static const struct nacl_irt_ppapihook nacl_irt_ppapihook = { | 38 static const struct nacl_irt_ppapihook nacl_irt_ppapihook = { | 
| 37 irt_ppapi_start, | 39 irt_ppapi_start, | 
| 38 PpapiPluginRegisterThreadCreator, | 40 PpapiPluginRegisterThreadCreator, | 
| 39 }; | 41 }; | 
| 40 | 42 | 
| 43 static int ppapihook_pnacl_private_filter(void) { | |
| 44 static int ppapihook_pnacl_private_enabled = -1; | |
| 
Mark Seaborn
2014/02/26 22:11:03
Since this will only be called once, you can leave
 
jvoung (off chromium)
2014/02/27 01:39:55
True it'll only be called on startup -- done.
 | |
| 45 if (-1 == ppapihook_pnacl_private_enabled) { | |
| 46 ppapihook_pnacl_private_enabled = sysconf(NACL_ABI__SC_NACL_PNACL_MODE); | |
| 47 if (ppapihook_pnacl_private_enabled == -1) | |
| 48 ppapihook_pnacl_private_enabled = 0; | |
| 49 } | |
| 50 return ppapihook_pnacl_private_enabled; | |
| 
Mark Seaborn
2014/02/26 22:11:03
Since this isn't thread safe, this could end up re
 
jvoung (off chromium)
2014/02/27 01:39:55
Changed to not use the static int.
 | |
| 51 } | |
| 52 | |
| 41 static const struct nacl_irt_interface irt_interfaces[] = { | 53 static const struct nacl_irt_interface irt_interfaces[] = { | 
| 42 { NACL_IRT_PPAPIHOOK_v0_1, &nacl_irt_ppapihook, sizeof(nacl_irt_ppapihook), | 54 { NACL_IRT_PPAPIHOOK_v0_1, &nacl_irt_ppapihook, sizeof(nacl_irt_ppapihook), | 
| 43 NULL }, | 55 NULL }, | 
| 56 { NACL_IRT_PPAPIHOOK_PNACL_PRIVATE_v0_1, | |
| 57 &nacl_irt_ppapihook_pnacl_private, sizeof(nacl_irt_ppapihook_pnacl_private), | |
| 58 ppapihook_pnacl_private_filter }, | |
| 44 }; | 59 }; | 
| 45 | 60 | 
| 46 static size_t chrome_irt_query(const char* interface_ident, | 61 static size_t chrome_irt_query(const char* interface_ident, | 
| 47 void* table, size_t tablesize) { | 62 void* table, size_t tablesize) { | 
| 48 size_t result = nacl_irt_query_core(interface_ident, table, tablesize); | 63 size_t result = nacl_irt_query_core(interface_ident, table, tablesize); | 
| 49 if (result != 0) | 64 if (result != 0) | 
| 50 return result; | 65 return result; | 
| 51 return nacl_irt_query_list(interface_ident, table, tablesize, | 66 return nacl_irt_query_list(interface_ident, table, tablesize, | 
| 52 irt_interfaces, sizeof(irt_interfaces)); | 67 irt_interfaces, sizeof(irt_interfaces)); | 
| 53 } | 68 } | 
| 54 | 69 | 
| 55 void nacl_irt_start(uint32_t* info) { | 70 void nacl_irt_start(uint32_t* info) { | 
| 56 nacl_irt_init(info); | 71 nacl_irt_init(info); | 
| 57 nacl_irt_enter_user_code(info, chrome_irt_query); | 72 nacl_irt_enter_user_code(info, chrome_irt_query); | 
| 58 } | 73 } | 
| OLD | NEW |