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

Side by Side 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 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.
4
5 #include "native_client/src/shared/platform/nacl_log.h"
6 #include "native_client/src/shared/srpc/nacl_srpc.h"
7 #include "native_client/src/untrusted/irt/irt_dev.h"
8 #include "ppapi/nacl_irt/irt_interfaces.h"
9
10 namespace {
11
12 const int kMaxObjectFiles = 16;
13
14 int (*g_func)(int nexe_fd,
15 const int* obj_file_fds,
16 int obj_file_fd_count);
17
18 void HandleLinkRequest(NaClSrpcRpc* rpc,
19 NaClSrpcArg** in_args,
20 NaClSrpcArg** out_args,
21 NaClSrpcClosure* done) {
22 int obj_file_count = in_args[0]->u.ival;
23 int nexe_fd = in_args[kMaxObjectFiles + 1]->u.hval;
24
25 if (obj_file_count < 1 || obj_file_count > kMaxObjectFiles) {
26 NaClLog(LOG_FATAL, "Bad object file count (%i)\n", obj_file_count);
27 }
28 int obj_file_fds[obj_file_count];
29 for (int i = 0; i < obj_file_count; i++) {
30 obj_file_fds[i] = in_args[i + 1]->u.hval;
31 }
32
33 int result = g_func(nexe_fd, obj_file_fds, obj_file_count);
34
35 rpc->result = result == 0 ? NACL_SRPC_RESULT_OK : NACL_SRPC_RESULT_APP_ERROR;
36 done->Run(done);
37 }
38
39 const struct NaClSrpcHandlerDesc kSrpcMethods[] = {
40 { "RunWithSplit:ihhhhhhhhhhhhhhhhh:", HandleLinkRequest },
41 { NULL, NULL },
42 };
43
44 void ServeLinkRequest(int (*func)(int nexe_fd,
45 const int* obj_file_fds,
46 int obj_file_fd_count)) {
47 g_func = func;
48 if (!NaClSrpcModuleInit()) {
49 NaClLog(LOG_FATAL, "NaClSrpcModuleInit() failed\n");
50 }
51 if (!NaClSrpcAcceptClientConnection(kSrpcMethods)) {
52 NaClLog(LOG_FATAL, "NaClSrpcAcceptClientConnection() failed\n");
53 }
54 }
55
56 }
57
58 const struct nacl_irt_private_pnacl_translator_link
59 nacl_irt_private_pnacl_translator_link = {
60 ServeLinkRequest
61 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698