Add an extension override bubble and warning box for proxy extensions. (2nd attempt...
[chromium-blink-merge.git] / mojo / system / memory.h
blob96f800ee15dae7b5b2c59c8c23fb8ca1c008055c
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
3 // found in the LICENSE file.
5 #ifndef MOJO_SYSTEM_MEMORY_H_
6 #define MOJO_SYSTEM_MEMORY_H_
8 #include <stddef.h>
10 #include "mojo/public/c/system/macros.h"
11 #include "mojo/system/system_impl_export.h"
13 namespace mojo {
14 namespace system {
16 namespace internal {
18 template <size_t size, size_t alignment>
19 bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerHelper(const void* pointer);
21 // Note: This is also used by options_validation.h.
22 template <size_t size, size_t alignment>
23 bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerWithCountHelper(
24 const void* pointer,
25 size_t count);
27 } // namespace internal
29 // Verify (insofar as possible/necessary) that a |T| can be read from the user
30 // |pointer|.
31 template <typename T>
32 bool VerifyUserPointer(const T* pointer) {
33 return internal::VerifyUserPointerHelper<sizeof(T), MOJO_ALIGNOF(T)>(pointer);
36 // Verify (insofar as possible/necessary) that |count| |T|s can be read from the
37 // user |pointer|; |count| may be zero. (This is done carefully since |count *
38 // sizeof(T)| may overflow a |size_t|.)
39 template <typename T>
40 bool VerifyUserPointerWithCount(const T* pointer, size_t count) {
41 return internal::VerifyUserPointerWithCountHelper<sizeof(T),
42 MOJO_ALIGNOF(T)>(pointer,
43 count);
46 // Verify that |size| bytes (which may be zero) can be read from the user
47 // |pointer|, and that |pointer| has the specified |alignment| (if |size| is
48 // nonzero).
49 template <size_t alignment>
50 bool MOJO_SYSTEM_IMPL_EXPORT VerifyUserPointerWithSize(const void* pointer,
51 size_t size);
53 } // namespace system
54 } // namespace mojo
56 #endif // MOJO_SYSTEM_MEMORY_H_