OLD | NEW |
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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // options. | 132 // options. |
133 // | 133 // |
134 // On success, |*shared_buffer_handle| will be set to the handle for the new | 134 // On success, |*shared_buffer_handle| will be set to the handle for the new |
135 // buffer handle. (On failure, it is not modified.) | 135 // buffer handle. (On failure, it is not modified.) |
136 // | 136 // |
137 // Returns: | 137 // Returns: |
138 // |MOJO_RESULT_OK| on success. | 138 // |MOJO_RESULT_OK| on success. |
139 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., | 139 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., |
140 // |buffer_handle| is not a valid buffer handle or |*options| is invalid). | 140 // |buffer_handle| is not a valid buffer handle or |*options| is invalid). |
141 // |MOJO_RESULT_UNIMPLEMENTED| if an unsupported flag was set in |*options|. | 141 // |MOJO_RESULT_UNIMPLEMENTED| if an unsupported flag was set in |*options|. |
| 142 // |MOJO_RESULT_BUSY| if |buffer_handle| is currently in use in some |
| 143 // transaction (that, e.g., may result in it being invalidated, such as |
| 144 // being sent in a message). |
142 MojoResult MojoDuplicateBufferHandle( | 145 MojoResult MojoDuplicateBufferHandle( |
143 MojoHandle buffer_handle, // In. | 146 MojoHandle buffer_handle, // In. |
144 const struct MojoDuplicateBufferHandleOptions* MOJO_RESTRICT | 147 const struct MojoDuplicateBufferHandleOptions* MOJO_RESTRICT |
145 options, // Optional in. | 148 options, // Optional in. |
146 MojoHandle* MOJO_RESTRICT new_buffer_handle); // Out. | 149 MojoHandle* MOJO_RESTRICT new_buffer_handle); // Out. |
147 | 150 |
148 // |MojoGetBufferInformation()|: Gets information about the buffer with handle | 151 // |MojoGetBufferInformation()|: Gets information about the buffer with handle |
149 // |buffer_handle|. |info| should be non-null and point to a buffer of size | 152 // |buffer_handle|. |info| should be non-null and point to a buffer of size |
150 // |info_num_bytes|; |info_num_bytes| should be at least 16 (the size of the | 153 // |info_num_bytes|; |info_num_bytes| should be at least 16 (the size of the |
151 // first, and currently only, version of |struct MojoBufferInformation|). | 154 // first, and currently only, version of |struct MojoBufferInformation|). |
152 | 155 |
153 // | 156 // |
154 // On success, |*info| will be filled with information about the given buffer. | 157 // On success, |*info| will be filled with information about the given buffer. |
155 // Note that if additional (larger) versions of |struct MojoBufferInformation| | 158 // Note that if additional (larger) versions of |struct MojoBufferInformation| |
156 // are defined, the largest version permitted by |info_num_bytes| that is | 159 // are defined, the largest version permitted by |info_num_bytes| that is |
157 // supported by the implementation will be filled. Callers expecting more than | 160 // supported by the implementation will be filled. Callers expecting more than |
158 // the first 16-byte version must check the resulting |info->struct_size|. | 161 // the first 16-byte version must check the resulting |info->struct_size|. |
159 // | 162 // |
160 // Returns: | 163 // Returns: |
161 // |MOJO_RESULT_OK| on success. | 164 // |MOJO_RESULT_OK| on success. |
162 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., | 165 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., |
163 // |buffer_handle| is not a valid buffer handle, |*info| is null, or | 166 // |buffer_handle| is not a valid buffer handle, |*info| is null, or |
164 // |info_num_bytes| is too small). | 167 // |info_num_bytes| is too small). |
| 168 // |MOJO_RESULT_BUSY| if |buffer_handle| is currently in use in some |
| 169 // transaction (that, e.g., may result in it being invalidated, such as |
| 170 // being sent in a message). |
165 MojoResult MojoGetBufferInformation(MojoHandle buffer_handle, // In. | 171 MojoResult MojoGetBufferInformation(MojoHandle buffer_handle, // In. |
166 struct MojoBufferInformation* info, // Out. | 172 struct MojoBufferInformation* info, // Out. |
167 uint32_t info_num_bytes); // In. | 173 uint32_t info_num_bytes); // In. |
168 | 174 |
169 // |MojoMapBuffer()|: Maps the part (at offset |offset| of length |num_bytes|) | 175 // |MojoMapBuffer()|: Maps the part (at offset |offset| of length |num_bytes|) |
170 // of the buffer given by |buffer_handle| into memory, with options specified by | 176 // of the buffer given by |buffer_handle| into memory, with options specified by |
171 // |flags|. |offset + num_bytes| must be less than or equal to the size of the | 177 // |flags|. |offset + num_bytes| must be less than or equal to the size of the |
172 // buffer. On success, |*buffer| points to memory with the requested part of the | 178 // buffer. On success, |*buffer| points to memory with the requested part of the |
173 // buffer. (On failure, it is not modified.) | 179 // buffer. (On failure, it is not modified.) |
174 | 180 |
175 // | 181 // |
176 // A single buffer handle may have multiple active mappings (possibly depending | 182 // A single buffer handle may have multiple active mappings (possibly depending |
177 // on the buffer type). The permissions (e.g., writable or executable) of the | 183 // on the buffer type). The permissions (e.g., writable or executable) of the |
178 // returned memory may depend on the properties of the buffer and properties | 184 // returned memory may depend on the properties of the buffer and properties |
179 // attached to the buffer handle as well as |flags|. | 185 // attached to the buffer handle as well as |flags|. |
180 // | 186 // |
181 // Note: Though data outside the specified range may apparently be | 187 // Note: Though data outside the specified range may apparently be |
182 // available/visible/readable/writable, trying to use those extra bytes is | 188 // available/visible/readable/writable, trying to use those extra bytes is |
183 // undefined behavior. | 189 // undefined behavior. |
184 // | 190 // |
185 // Returns: | 191 // Returns: |
186 // |MOJO_RESULT_OK| on success. | 192 // |MOJO_RESULT_OK| on success. |
187 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., | 193 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., |
188 // |buffer_handle| is not a valid buffer handle or the range specified by | 194 // |buffer_handle| is not a valid buffer handle or the range specified by |
189 // |offset| and |num_bytes| is not valid). | 195 // |offset| and |num_bytes| is not valid). |
190 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if the mapping operation itself failed | 196 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if the mapping operation itself failed |
191 // (e.g., due to not having appropriate address space available). | 197 // (e.g., due to not having appropriate address space available). |
| 198 // |MOJO_RESULT_BUSY| if |buffer_handle| is currently in use in some |
| 199 // transaction (that, e.g., may result in it being invalidated, such as |
| 200 // being sent in a message). |
192 MojoResult MojoMapBuffer(MojoHandle buffer_handle, // In. | 201 MojoResult MojoMapBuffer(MojoHandle buffer_handle, // In. |
193 uint64_t offset, // In. | 202 uint64_t offset, // In. |
194 uint64_t num_bytes, // In. | 203 uint64_t num_bytes, // In. |
195 void** buffer, // Out. | 204 void** buffer, // Out. |
196 MojoMapBufferFlags flags); // In. | 205 MojoMapBufferFlags flags); // In. |
197 | 206 |
198 // |MojoUnmapBuffer()|: Unmaps a buffer pointer that was mapped by | 207 // |MojoUnmapBuffer()|: Unmaps a buffer pointer that was mapped by |
199 // |MojoMapBuffer()|. |buffer| must have been the result of |MojoMapBuffer()| | 208 // |MojoMapBuffer()|. |buffer| must have been the result of |MojoMapBuffer()| |
200 // (not some other pointer inside the mapped memory), and the entire mapping | 209 // (not some other pointer inside the mapped memory), and the entire mapping |
201 // will be removed (partial unmapping is not supported). A mapping may only be | 210 // will be removed (partial unmapping is not supported). A mapping may only be |
202 // unmapped once. | 211 // unmapped once. |
203 // | 212 // |
204 // Returns: | 213 // Returns: |
205 // |MOJO_RESULT_OK| on success. | 214 // |MOJO_RESULT_OK| on success. |
206 // |MOJO_RESULT_INVALID_ARGUMENT| if |buffer| is invalid (e.g., is not the | 215 // |MOJO_RESULT_INVALID_ARGUMENT| if |buffer| is invalid (e.g., is not the |
207 // result of |MojoMapBuffer()| or has already been unmapped). | 216 // result of |MojoMapBuffer()| or has already been unmapped). |
208 MojoResult MojoUnmapBuffer(void* buffer); // In. | 217 MojoResult MojoUnmapBuffer(void* buffer); // In. |
209 | 218 |
210 MOJO_END_EXTERN_C | 219 MOJO_END_EXTERN_C |
211 | 220 |
212 #endif // MOJO_PUBLIC_C_SYSTEM_BUFFER_H_ | 221 #endif // MOJO_PUBLIC_C_SYSTEM_BUFFER_H_ |
OLD | NEW |