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

Side by Side Diff: mojo/system/memory.cc

Issue 25895002: Simple shell that loads a dll and calls an entrypoint function passing in a handle to a pipe create… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: exports to template instantiations Created 7 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "mojo/system/memory.h" 5 #include "mojo/system/memory.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 10
11 namespace mojo { 11 namespace mojo {
12 namespace system { 12 namespace system {
13 13
14 template <size_t size> 14 template <size_t size>
15 bool VerifyUserPointerForSize(const void* pointer, size_t count) { 15 bool VerifyUserPointerForSize(const void* pointer, size_t count) {
16 if (count > std::numeric_limits<size_t>::max() / size) 16 if (count > std::numeric_limits<size_t>::max() / size)
17 return false; 17 return false;
18 18
19 // TODO(vtl): If running in kernel mode, do a full verification. For now, just 19 // TODO(vtl): If running in kernel mode, do a full verification. For now, just
20 // check that it's non-null if |size| is nonzero. (A faster user mode 20 // check that it's non-null if |size| is nonzero. (A faster user mode
21 // implementation is also possible if this check is skipped.) 21 // implementation is also possible if this check is skipped.)
22 return count == 0 || !!pointer; 22 return count == 0 || !!pointer;
23 } 23 }
24 24
25 // Explicitly instantiate the sizes we need. Add instantiations as needed. 25 // Explicitly instantiate the sizes we need. Add instantiations as needed.
26 template bool VerifyUserPointerForSize<1>(const void*, size_t); 26 template MOJO_SYSTEM_EXPORT bool VerifyUserPointerForSize<1>(
27 template bool VerifyUserPointerForSize<4>(const void*, size_t); 27 const void*, size_t);
28 template MOJO_SYSTEM_EXPORT bool VerifyUserPointerForSize<4>(
29 const void*, size_t);
28 30
29 } // namespace system 31 } // namespace system
30 } // namespace mojo 32 } // namespace mojo
OLDNEW
« build/all.gyp ('K') | « mojo/system/memory.h ('k') | mojo/system/message_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698