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

Side by Side Diff: mojo/public/c/bindings/lib/util.h

Issue 2232833003: Change the canonical way to include the C bindings headers to <mojo/bindings/*.h>. (Closed) Base URL: https://github.com/domokit/mojo.git@work791_mojo_tests
Patch Set: rebased Created 4 years, 4 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 | « mojo/public/c/bindings/lib/union.c ('k') | mojo/public/c/bindings/map.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 #ifndef MOJO_PUBLIC_C_BINDINGS_LIB_UTIL_H_
6 #define MOJO_PUBLIC_C_BINDINGS_LIB_UTIL_H_
7
8 #include <mojo/macros.h>
9
10 // Rounds-up |num| to 8. The result is undefined if this results in an overflow.
11 #define MOJOM_INTERNAL_ROUND_TO_8(num) (((num) + 7) & ~7)
12
13 // Represents the memory layout of a mojom pointer; it is a |ptr| (pointer to
14 // some memory) when unencoded, and refers to a relative |offset| when encoded.
15 union MojomPointer {
16 void* ptr;
17 uint64_t offset;
18 };
19 MOJO_STATIC_ASSERT(sizeof(union MojomPointer) == 8,
20 "union MojomPointer must be 8 bytes");
21
22 // This struct represents the state we need to keep when validating an encoded
23 // mojom type.
24 struct MojomValidationContext {
25 // |next_handle_index| is a counter that represents the next-available index
26 // into the handle array. Previous indices have already been used up. This
27 // counter is non-decreasing as it is used throughout validation.
28 uint32_t next_handle_index;
29
30 // As we validate, we keep track of the point where pointers can point to,
31 // since two pointers may not point to the same memory region.
32 char* next_pointer;
33
34 // TODO(vardhan): Include an error string? How big should it be?
35 };
36
37 #endif // MOJO_PUBLIC_C_BINDINGS_LIB_UTIL_H_
OLDNEW
« no previous file with comments | « mojo/public/c/bindings/lib/union.c ('k') | mojo/public/c/bindings/map.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698