Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2527)

Unified Diff: ppapi/nacl_irt/irt_pnacl_translator_link.cc

Issue 1240343004: NaCl: Copy PNaCl translator IRT interfaces to the Chromium side (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ppapi/nacl_irt/irt_pnacl_translator_link.cc
diff --git a/ppapi/nacl_irt/irt_pnacl_translator_link.cc b/ppapi/nacl_irt/irt_pnacl_translator_link.cc
new file mode 100644
index 0000000000000000000000000000000000000000..f5569aa54acb25d180a14432fd9f922c4b2c3c57
--- /dev/null
+++ b/ppapi/nacl_irt/irt_pnacl_translator_link.cc
@@ -0,0 +1,61 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "native_client/src/shared/platform/nacl_log.h"
+#include "native_client/src/shared/srpc/nacl_srpc.h"
+#include "native_client/src/untrusted/irt/irt_dev.h"
+#include "ppapi/nacl_irt/irt_interfaces.h"
+
+namespace {
+
+const int kMaxObjectFiles = 16;
+
+int (*g_func)(int nexe_fd,
+ const int* obj_file_fds,
+ int obj_file_fd_count);
+
+void HandleLinkRequest(NaClSrpcRpc* rpc,
+ NaClSrpcArg** in_args,
+ NaClSrpcArg** out_args,
+ NaClSrpcClosure* done) {
+ int obj_file_count = in_args[0]->u.ival;
+ int nexe_fd = in_args[kMaxObjectFiles + 1]->u.hval;
+
+ if (obj_file_count < 1 || obj_file_count > kMaxObjectFiles) {
+ NaClLog(LOG_FATAL, "Bad object file count (%i)\n", obj_file_count);
+ }
+ int obj_file_fds[obj_file_count];
+ for (int i = 0; i < obj_file_count; i++) {
+ obj_file_fds[i] = in_args[i + 1]->u.hval;
+ }
+
+ int result = g_func(nexe_fd, obj_file_fds, obj_file_count);
+
+ rpc->result = result == 0 ? NACL_SRPC_RESULT_OK : NACL_SRPC_RESULT_APP_ERROR;
+ done->Run(done);
+}
+
+const struct NaClSrpcHandlerDesc kSrpcMethods[] = {
+ { "RunWithSplit:ihhhhhhhhhhhhhhhhh:", HandleLinkRequest },
+ { NULL, NULL },
+};
+
+void ServeLinkRequest(int (*func)(int nexe_fd,
+ const int* obj_file_fds,
+ int obj_file_fd_count)) {
+ g_func = func;
+ if (!NaClSrpcModuleInit()) {
+ NaClLog(LOG_FATAL, "NaClSrpcModuleInit() failed\n");
+ }
+ if (!NaClSrpcAcceptClientConnection(kSrpcMethods)) {
+ NaClLog(LOG_FATAL, "NaClSrpcAcceptClientConnection() failed\n");
+ }
+}
+
+}
+
+const struct nacl_irt_private_pnacl_translator_link
+ nacl_irt_private_pnacl_translator_link = {
+ ServeLinkRequest
+};

Powered by Google App Engine
This is Rietveld 408576698