size_t __pnacl_irt_interface_wrapper(const char *interface_ident, void *table, size_t tablesize) { if (!is_irt_interface_whitelisted(interface_ident)) return 0; if (0 != mystrcmp(interface_ident, NACL_IRT_PPAPIHOOK_v0_1)) { return (*__pnacl_real_irt_interface)(interface_ident, table, tablesize); } if ((*__pnacl_real_irt_interface)(NACL_IRT_PPAPIHOOK_v0_1, &real_irt_ppapi_hook, sizeof real_irt_ppapi_hook) != sizeof real_irt_ppapi_hook) { return 0; } struct nacl_irt_ppapihook *dest = table; if (sizeof *dest <= tablesize) { dest->ppapi_start = wrap_ppapi_start; dest->ppapi_register_thread_creator = real_irt_ppapi_hook.ppapi_register_thread_creator; return sizeof *dest; } return 0; }
size_t __pnacl_irt_interface_wrapper(const char *interface_ident, void *table, size_t tablesize) { if (!is_irt_interface_whitelisted(interface_ident)) return 0; /* * Note there is a benign race in initializing the wrapper. * We build the "hook" structure by copying from the IRT's hook and then * writing our wrapper for the ppapi method. Two threads may end up * attempting to do this simultaneously, which should not be a problem, * as they are writing the same values. */ if (0 != mystrcmp(interface_ident, NACL_IRT_PPAPIHOOK_v0_1)) { /* * The interface is not wrapped, so use the real interface. */ return (*__pnacl_real_irt_interface)(interface_ident, table, tablesize); } if ((*__pnacl_real_irt_interface)(NACL_IRT_PPAPIHOOK_v0_1, &real_irt_ppapi_hook, sizeof real_irt_ppapi_hook) != sizeof real_irt_ppapi_hook) { return 0; } /* * Copy the interface structure into the client. */ struct nacl_irt_ppapihook *dest = table; if (sizeof *dest <= tablesize) { dest->ppapi_start = wrap_ppapi_start; dest->ppapi_register_thread_creator = real_irt_ppapi_hook.ppapi_register_thread_creator; return sizeof *dest; } return 0; }