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

Side by Side Diff: src/shared/imc/nacl/nacl_imc.cc

Issue 1210053007: Remove unused untrusted implementations of NaClSendDatagram() and others (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client 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 /* NaCl inter-module communication primitives. */ 7 /* NaCl inter-module communication primitives. */
8 8
9 #include <errno.h> 9 #include <errno.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 #include <string.h> 11 #include <string.h>
12 #include <sys/mman.h> 12 #include <sys/mman.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 14
15 #include <algorithm> 15 #include "native_client/src/public/imc_syscalls.h"
16
17 #include "native_client/src/shared/imc/nacl_imc_c.h" 16 #include "native_client/src/shared/imc/nacl_imc_c.h"
18 17
19 #if defined(__native_client__)
20 #include "native_client/src/public/imc_syscalls.h"
21 typedef NaClAbiNaClImcMsgHdr NaClImcMsgHdr;
22 #endif
23
24 /* Duplicate a NaCl file descriptor. */
25 NaClHandle NaClDuplicateNaClHandle(NaClHandle handle) {
26 return dup(handle);
27 }
28
29 int NaClWouldBlock() {
30 return (errno == EAGAIN) ? 1 : 0;
31 }
32
33 NaClHandle NaClBoundSocket(const NaClSocketAddress* address) {
34 /*
35 * TODO(shiki): Switch to the following once the make_bound_sock() prototype
36 * is cleaned up.
37 * return make_bound_sock(address);
38 */
39 return -1;
40 }
41
42 int NaClSocketPair(NaClHandle pair[2]) { 18 int NaClSocketPair(NaClHandle pair[2]) {
jvoung (off chromium) 2015/07/08 17:20:10 It wasn't clear to me the difference in categoriza
Mark Seaborn 2015/07/08 17:40:13 The difference is that there is some test code tha
43 return imc_socketpair(pair); 19 return imc_socketpair(pair);
44 } 20 }
45 21
46 int NaClClose(NaClHandle handle) { 22 int NaClClose(NaClHandle handle) {
47 return close(handle); 23 return close(handle);
48 } 24 }
49 25
50 int NaClSendDatagram(NaClHandle handle, const NaClMessageHeader* message,
51 int flags) {
52 return imc_sendmsg(handle, (const NaClImcMsgHdr *) message,
53 flags);
54 }
55
56 int NaClSendDatagramTo(const NaClMessageHeader* message, int flags,
57 const NaClSocketAddress* name) {
58 return -1; /* TODO(bsy): how to implement this for NaCl? */
59 }
60
61 int NaClReceiveDatagram(NaClHandle handle, NaClMessageHeader* message,
62 int flags) {
63 return imc_recvmsg(handle, (NaClImcMsgHdr *) message, flags);
64 }
65
66 NaClHandle NaClCreateMemoryObject(size_t length, int executable) { 26 NaClHandle NaClCreateMemoryObject(size_t length, int executable) {
67 if (executable) { 27 if (executable) {
68 return -1; /* Will never work with NaCl and should never be invoked. */ 28 return -1; /* Will never work with NaCl and should never be invoked. */
69 } 29 }
70 return imc_mem_obj_create(length); 30 return imc_mem_obj_create(length);
71 } 31 }
72
73 void* NaClMap(struct NaClDescEffector* effp,
74 void* start, size_t length, int prot, int flags,
75 NaClHandle memory, off_t offset) {
76 static int posix_prot[4] = {
77 PROT_NONE,
78 PROT_READ,
79 PROT_WRITE,
80 PROT_READ | PROT_WRITE
81 };
82 int adjusted = 0;
83
84 if (flags & NACL_MAP_SHARED) {
85 adjusted |= MAP_SHARED;
86 }
87 if (flags & NACL_MAP_PRIVATE) {
88 adjusted |= MAP_PRIVATE;
89 }
90 if (flags & NACL_MAP_FIXED) {
91 adjusted |= MAP_FIXED;
92 }
93 return mmap(start, length, posix_prot[prot & 3], adjusted, memory, offset);
94 }
95
96 int NaClUnmap(void* start, size_t length) {
97 return munmap(start, length);
98 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698