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

Side by Side Diff: mojo/public/c/system/buffer.h

Issue 2062323002: Mojo C bindings library pt1: MojomBuffer (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: MojomBuffer_Allocate(0) succeeds Created 4 years, 6 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/tests/buffer_unittest.cc ('k') | mojo/public/c/system/data_pipe.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // This file contains types/constants and functions specific to buffers (and in 5 // This file contains types/constants and functions specific to buffers (and in
6 // particular shared buffers). 6 // particular shared buffers).
7 // TODO(vtl): Reorganize this file (etc.) to separate general buffer functions 7 // TODO(vtl): Reorganize this file (etc.) to separate general buffer functions
8 // from (shared) buffer creation. 8 // from (shared) buffer creation.
9 // 9 //
10 // Note: This header should be compilable as C. 10 // Note: This header should be compilable as C.
(...skipping 20 matching lines...) Expand all
31 typedef uint32_t MojoCreateSharedBufferOptionsFlags; 31 typedef uint32_t MojoCreateSharedBufferOptionsFlags;
32 32
33 #define MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE \ 33 #define MOJO_CREATE_SHARED_BUFFER_OPTIONS_FLAG_NONE \
34 ((MojoCreateSharedBufferOptionsFlags)0) 34 ((MojoCreateSharedBufferOptionsFlags)0)
35 35
36 MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) == 8, "int64_t has weird alignment"); 36 MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) == 8, "int64_t has weird alignment");
37 struct MOJO_ALIGNAS(8) MojoCreateSharedBufferOptions { 37 struct MOJO_ALIGNAS(8) MojoCreateSharedBufferOptions {
38 uint32_t struct_size; 38 uint32_t struct_size;
39 MojoCreateSharedBufferOptionsFlags flags; 39 MojoCreateSharedBufferOptionsFlags flags;
40 }; 40 };
41 MOJO_STATIC_ASSERT(sizeof(MojoCreateSharedBufferOptions) == 8, 41 MOJO_STATIC_ASSERT(sizeof(struct MojoCreateSharedBufferOptions) == 8,
42 "MojoCreateSharedBufferOptions has wrong size"); 42 "MojoCreateSharedBufferOptions has wrong size");
43 43
44 // |MojoDuplicateBufferHandleOptions|: Used to specify parameters in duplicating 44 // |MojoDuplicateBufferHandleOptions|: Used to specify parameters in duplicating
45 // access to a buffer to |MojoDuplicateBufferHandle()|. 45 // access to a buffer to |MojoDuplicateBufferHandle()|.
46 // |uint32_t struct_size|: Set to the size of the 46 // |uint32_t struct_size|: Set to the size of the
47 // |MojoDuplicateBufferHandleOptions| struct. (Used to allow for future 47 // |MojoDuplicateBufferHandleOptions| struct. (Used to allow for future
48 // extensions.) 48 // extensions.)
49 // |MojoDuplicateBufferHandleOptionsFlags flags|: Reserved for future use. 49 // |MojoDuplicateBufferHandleOptionsFlags flags|: Reserved for future use.
50 // |MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE|: No flags; default 50 // |MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE|: No flags; default
51 // mode. 51 // mode.
52 // 52 //
53 // TODO(vtl): Add flags to remove writability (and executability)? Also, COW? 53 // TODO(vtl): Add flags to remove writability (and executability)? Also, COW?
54 54
55 typedef uint32_t MojoDuplicateBufferHandleOptionsFlags; 55 typedef uint32_t MojoDuplicateBufferHandleOptionsFlags;
56 56
57 #define MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE \ 57 #define MOJO_DUPLICATE_BUFFER_HANDLE_OPTIONS_FLAG_NONE \
58 ((MojoDuplicateBufferHandleOptionsFlags)0) 58 ((MojoDuplicateBufferHandleOptionsFlags)0)
59 59
60 struct MOJO_ALIGNAS(8) MojoDuplicateBufferHandleOptions { 60 struct MOJO_ALIGNAS(8) MojoDuplicateBufferHandleOptions {
61 uint32_t struct_size; 61 uint32_t struct_size;
62 MojoDuplicateBufferHandleOptionsFlags flags; 62 MojoDuplicateBufferHandleOptionsFlags flags;
63 }; 63 };
64 MOJO_STATIC_ASSERT(sizeof(MojoDuplicateBufferHandleOptions) == 8, 64 MOJO_STATIC_ASSERT(sizeof(struct MojoDuplicateBufferHandleOptions) == 8,
65 "MojoDuplicateBufferHandleOptions has wrong size"); 65 "MojoDuplicateBufferHandleOptions has wrong size");
66 66
67 // |MojoBufferInformation|: Used to provide information about a buffer (see 67 // |MojoBufferInformation|: Used to provide information about a buffer (see
68 // |MojoGetBufferInformation()|. 68 // |MojoGetBufferInformation()|.
69 // |uint32_t struct_size|: Set to the size of the |MojoBufferInformation| 69 // |uint32_t struct_size|: Set to the size of the |MojoBufferInformation|
70 // struct. (Used to allow for future extensions.) 70 // struct. (Used to allow for future extensions.)
71 // |MojoBufferInformationFlags flags|: Reserved for future use. 71 // |MojoBufferInformationFlags flags|: Reserved for future use.
72 // |uint64_t num_bytes|: Size of the buffer. 72 // |uint64_t num_bytes|: Size of the buffer.
73 // 73 //
74 // TODO(vtl): Add flags to indicate writability, etc.? Also, type of buffer? 74 // TODO(vtl): Add flags to indicate writability, etc.? Also, type of buffer?
75 75
76 typedef uint32_t MojoBufferInformationFlags; 76 typedef uint32_t MojoBufferInformationFlags;
77 77
78 #define MOJO_BUFFER_INFORMATION_FLAG_NONE ((MojoBufferInformationFlags)0) 78 #define MOJO_BUFFER_INFORMATION_FLAG_NONE ((MojoBufferInformationFlags)0)
79 79
80 struct MOJO_ALIGNAS(8) MojoBufferInformation { 80 struct MOJO_ALIGNAS(8) MojoBufferInformation {
81 uint32_t struct_size; 81 uint32_t struct_size;
82 MojoBufferInformationFlags flags; 82 MojoBufferInformationFlags flags;
83 uint64_t num_bytes; 83 uint64_t num_bytes;
84 }; 84 };
85 MOJO_STATIC_ASSERT(sizeof(MojoBufferInformation) == 16, 85 MOJO_STATIC_ASSERT(sizeof(struct MojoBufferInformation) == 16,
86 "MojoBufferInformation has wrong size"); 86 "MojoBufferInformation has wrong size");
87 87
88 // |MojoMapBufferFlags|: Used to specify different modes to |MojoMapBuffer()|. 88 // |MojoMapBufferFlags|: Used to specify different modes to |MojoMapBuffer()|.
89 // |MOJO_MAP_BUFFER_FLAG_NONE| - No flags; default mode. 89 // |MOJO_MAP_BUFFER_FLAG_NONE| - No flags; default mode.
90 90
91 typedef uint32_t MojoMapBufferFlags; 91 typedef uint32_t MojoMapBufferFlags;
92 92
93 #define MOJO_MAP_BUFFER_FLAG_NONE ((MojoMapBufferFlags)0) 93 #define MOJO_MAP_BUFFER_FLAG_NONE ((MojoMapBufferFlags)0)
94 94
95 MOJO_BEGIN_EXTERN_C 95 MOJO_BEGIN_EXTERN_C
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 // 224 //
225 // Returns: 225 // Returns:
226 // |MOJO_RESULT_OK| on success. 226 // |MOJO_RESULT_OK| on success.
227 // |MOJO_RESULT_INVALID_ARGUMENT| if |buffer| is invalid (e.g., is not the 227 // |MOJO_RESULT_INVALID_ARGUMENT| if |buffer| is invalid (e.g., is not the
228 // result of |MojoMapBuffer()| or has already been unmapped). 228 // result of |MojoMapBuffer()| or has already been unmapped).
229 MojoResult MojoUnmapBuffer(void* buffer); // In. 229 MojoResult MojoUnmapBuffer(void* buffer); // In.
230 230
231 MOJO_END_EXTERN_C 231 MOJO_END_EXTERN_C
232 232
233 #endif // MOJO_PUBLIC_C_SYSTEM_BUFFER_H_ 233 #endif // MOJO_PUBLIC_C_SYSTEM_BUFFER_H_
OLDNEW
« no previous file with comments | « mojo/public/c/bindings/tests/buffer_unittest.cc ('k') | mojo/public/c/system/data_pipe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698