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

Side by Side Diff: src/trusted/plugin/shared_memory.cc

Issue 5622003: Restructure the structs/unions involved in SRPC argument passing. This will... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 10 years 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 | Annotate | Revision Log
« no previous file with comments | « src/trusted/plugin/ppapi/var_utils.cc ('k') | src/trusted/plugin/socket_address.cc » ('j') | 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 2008 The Native Client Authors. All rights reserved. 2 * Copyright 2008 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can 3 * Use of this source code is governed by a BSD-style license that can
4 * be found in the LICENSE file. 4 * be found in the LICENSE file.
5 */ 5 */
6 6
7 7
8 #include <errno.h> 8 #include <errno.h>
9 #include <signal.h> 9 #include <signal.h>
10 #include <string.h> 10 #include <string.h>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 out[0] = 0xc0 | (c >> 6); 95 out[0] = 0xc0 | (c >> 6);
96 out[1] = 0x80 | (c & 0x3f); 96 out[1] = 0x80 | (c & 0x3f);
97 out += 2; 97 out += 2;
98 } 98 }
99 ++shm_addr; 99 ++shm_addr;
100 } 100 }
101 // Terminate the result string with 0. 101 // Terminate the result string with 0.
102 *out = 0; 102 *out = 0;
103 103
104 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_STRING; 104 params->outs()[0]->tag = NACL_SRPC_ARG_TYPE_STRING;
105 params->outs()[0]->u.sval.str = ret_string; 105 params->outs()[0]->arrays.str = ret_string;
106 106
107 return true; 107 return true;
108 } 108 }
109 109
110 bool RpcWrite(void* obj, plugin::SrpcParams* params) { 110 bool RpcWrite(void* obj, plugin::SrpcParams* params) {
111 plugin::SharedMemory* shared_memory = 111 plugin::SharedMemory* shared_memory =
112 reinterpret_cast<plugin::SharedMemory*>(obj); 112 reinterpret_cast<plugin::SharedMemory*>(obj);
113 uint32_t offset; 113 uint32_t offset;
114 uint32_t len; 114 uint32_t len;
115 115
(...skipping 24 matching lines...) Expand all
140 if (offset + len > shared_memory->shm_size()) { 140 if (offset + len > shared_memory->shm_size()) {
141 params->set_exception_string( 141 params->set_exception_string(
142 "Offset + length overlaps end of shared memory"); 142 "Offset + length overlaps end of shared memory");
143 return false; 143 return false;
144 } 144 }
145 145
146 // The input is a JavaScript string, which must consist of UFT-8 146 // The input is a JavaScript string, which must consist of UFT-8
147 // characters with character codes between 0 and 255 inclusive. 147 // characters with character codes between 0 and 255 inclusive.
148 NaClSrpcArg* str_param = params->ins()[2]; 148 NaClSrpcArg* str_param = params->ins()[2];
149 const unsigned char* str = 149 const unsigned char* str =
150 reinterpret_cast<unsigned const char*>(str_param->u.sval.str); 150 reinterpret_cast<unsigned const char*>(str_param->arrays.str);
151 uint32_t utf_bytes = 151 uint32_t utf_bytes =
152 nacl::saturate_cast<uint32_t>(strlen(str_param->u.sval.str)); 152 nacl::saturate_cast<uint32_t>(strlen(str_param->arrays.str));
153 unsigned char* shm_addr = 153 unsigned char* shm_addr =
154 reinterpret_cast<unsigned char*>(shared_memory->shm_addr()) + offset; 154 reinterpret_cast<unsigned char*>(shared_memory->shm_addr()) + offset;
155 155
156 // TODO(mseaborn): Change this function to use ByteStringFromUTF8(). 156 // TODO(mseaborn): Change this function to use ByteStringFromUTF8().
157 for (unsigned int i = 0; i < len;) { 157 for (unsigned int i = 0; i < len;) {
158 unsigned char c1 = str[0]; 158 unsigned char c1 = str[0];
159 unsigned char c2 = 0; 159 unsigned char c2 = 0;
160 160
161 // Check that we are still pointing into the JavaScript string we were 161 // Check that we are still pointing into the JavaScript string we were
162 // passed. 162 // passed.
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 // plugin_->effp_, 291 // plugin_->effp_,
292 // addr_, 292 // addr_,
293 // size_); 293 // size_);
294 // } 294 // }
295 // TODO(sehr): is there a missing delete desc() here? 295 // TODO(sehr): is there a missing delete desc() here?
296 // TODO(gregoryd): in addition, should we unref the descriptor if it was 296 // TODO(gregoryd): in addition, should we unref the descriptor if it was
297 // constructed during the initialization of this object? 297 // constructed during the initialization of this object?
298 } 298 }
299 299
300 } // namespace plugin 300 } // namespace plugin
OLDNEW
« no previous file with comments | « src/trusted/plugin/ppapi/var_utils.cc ('k') | src/trusted/plugin/socket_address.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698