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. 4 5 #ifndef MOJO_PUBLIC_SYSTEM_CORE_H_ 6 #define MOJO_PUBLIC_SYSTEM_CORE_H_ 7 8 // Note: This header should be compilable as C. 9 10 #include <stdint.h> 11 12 #include "mojo/public/system/macros.h" 13 #include "mojo/public/system/system_export.h" 14 15 // Types/constants ------------------------------------------------------------- 16 17 // TODO(vtl): Notes: Use of undefined flags will lead to undefined behavior 18 // (typically they'll be ignored), not necessarily an error. 19 20 // |MojoTimeTicks|: Used to specify time ticks. Value is in microseconds. 21 22 typedef int64_t MojoTimeTicks; 23 24 // |MojoHandle|: Handles to Mojo objects. 25 // |MOJO_HANDLE_INVALID| - A value that is never a valid handle. 26 27 typedef uint32_t MojoHandle; 28 29 #ifdef __cplusplus 30 const MojoHandle MOJO_HANDLE_INVALID = 0; 31 #else 32 #define MOJO_HANDLE_INVALID ((MojoHandle) 0) 33 #endif 34 35 // |MojoResult|: Result codes for Mojo operations. Non-negative values are 36 // success codes; negative values are error/failure codes. 37 // |MOJO_RESULT_OK| - Not an error; returned on success. Note that positive 38 // |MojoResult|s may also be used to indicate success. 39 // |MOJO_RESULT_CANCELLED| - Operation was cancelled, typically by the caller. 40 // |MOJO_RESULT_UNKNOWN| - Unknown error (e.g., if not enough information is 41 // available for a more specific error). 42 // |MOJO_RESULT_INVALID_ARGUMENT| - Caller specified an invalid argument. This 43 // differs from |MOJO_RESULT_FAILED_PRECONDITION| in that the former 44 // indicates arguments that are invalid regardless of the state of the 45 // system. 46 // |MOJO_RESULT_DEADLINE_EXCEEDED| - Deadline expired before the operation 47 // could complete. 48 // |MOJO_RESULT_NOT_FOUND| - Some requested entity was not found (i.e., does 49 // not exist). 50 // |MOJO_RESULT_ALREADY_EXISTS| - Some entity or condition that we attempted 51 // to create already exists. 52 // |MOJO_RESULT_PERMISSION_DENIED| - The caller does not have permission to 53 // for the operation (use |MOJO_RESULT_RESOURCE_EXHAUSTED| for rejections 54 // caused by exhausting some resource instead). 55 // |MOJO_RESULT_RESOURCE_EXHAUSTED| - Some resource required for the call 56 // (possibly some quota) has been exhausted. 57 // |MOJO_RESULT_FAILED_PRECONDITION| - The system is not in a state required 58 // for the operation (use this if the caller must do something to rectify 59 // the state before retrying). 60 // |MOJO_RESULT_ABORTED| - The operation was aborted by the system, possibly 61 // due to a concurrency issue (use this if the caller may retry at a 62 // higher level). 63 // |MOJO_RESULT_OUT_OF_RANGE| - The operation was attempted past the valid 64 // range. Unlike |MOJO_RESULT_INVALID_ARGUMENT|, this indicates that the 65 // operation may be/become valid depending on the system state. (This 66 // error is similar to |MOJO_RESULT_FAILED_PRECONDITION|, but is more 67 // specific.) 68 // |MOJO_RESULT_UNIMPLEMENTED| - The operation is not implemented, supported, 69 // or enabled. 70 // |MOJO_RESULT_INTERNAL| - Internal error: this should never happen and 71 // indicates that some invariant expected by the system has been broken. 72 // |MOJO_RESULT_UNAVAILABLE| - The operation is (temporarily) currently 73 // unavailable. The caller may simply retry the operation (possibly with a 74 // backoff). 75 // |MOJO_RESULT_DATA_LOSS| - Unrecoverable data loss or corruption. 76 // |MOJO_RESULT_BUSY| - One of the resources involved is currently being used 77 // (possibly on another thread) in a way that prevents the current 78 // operation from proceeding, e.g., if the other operation may result in 79 // the resource being invalidated. 80 // 81 // Note that positive values are also available as success codes. 82 // 83 // The codes from |MOJO_RESULT_OK| to |MOJO_RESULT_DATA_LOSS| come from 84 // Google3's canonical error codes. 85 // 86 // TODO(vtl): Add a |MOJO_RESULT_SHOULD_WAIT|. 87 88 typedef int32_t MojoResult; 89 90 #ifdef __cplusplus 91 const MojoResult MOJO_RESULT_OK = 0; 92 const MojoResult MOJO_RESULT_CANCELLED = -1; 93 const MojoResult MOJO_RESULT_UNKNOWN = -2; 94 const MojoResult MOJO_RESULT_INVALID_ARGUMENT = -3; 95 const MojoResult MOJO_RESULT_DEADLINE_EXCEEDED = -4; 96 const MojoResult MOJO_RESULT_NOT_FOUND = -5; 97 const MojoResult MOJO_RESULT_ALREADY_EXISTS = -6; 98 const MojoResult MOJO_RESULT_PERMISSION_DENIED = -7; 99 const MojoResult MOJO_RESULT_RESOURCE_EXHAUSTED = -8; 100 const MojoResult MOJO_RESULT_FAILED_PRECONDITION = -9; 101 const MojoResult MOJO_RESULT_ABORTED = -10; 102 const MojoResult MOJO_RESULT_OUT_OF_RANGE = -11; 103 const MojoResult MOJO_RESULT_UNIMPLEMENTED = -12; 104 const MojoResult MOJO_RESULT_INTERNAL = -13; 105 const MojoResult MOJO_RESULT_UNAVAILABLE = -14; 106 const MojoResult MOJO_RESULT_DATA_LOSS = -15; 107 const MojoResult MOJO_RESULT_BUSY = -16; 108 #else 109 #define MOJO_RESULT_OK ((MojoResult) 0) 110 #define MOJO_RESULT_CANCELLED ((MojoResult) -1) 111 #define MOJO_RESULT_UNKNOWN ((MojoResult) -2) 112 #define MOJO_RESULT_INVALID_ARGUMENT ((MojoResult) -3) 113 #define MOJO_RESULT_DEADLINE_EXCEEDED ((MojoResult) -4) 114 #define MOJO_RESULT_NOT_FOUND ((MojoResult) -5) 115 #define MOJO_RESULT_ALREADY_EXISTS ((MojoResult) -6) 116 #define MOJO_RESULT_PERMISSION_DENIED ((MojoResult) -7) 117 #define MOJO_RESULT_RESOURCE_EXHAUSTED ((MojoResult) -8) 118 #define MOJO_RESULT_FAILED_PRECONDITION ((MojoResult) -9) 119 #define MOJO_RESULT_ABORTED ((MojoResult) -10) 120 #define MOJO_RESULT_OUT_OF_RANGE ((MojoResult) -11) 121 #define MOJO_RESULT_UNIMPLEMENTED ((MojoResult) -12) 122 #define MOJO_RESULT_INTERNAL ((MojoResult) -13) 123 #define MOJO_RESULT_UNAVAILABLE ((MojoResult) -14) 124 #define MOJO_RESULT_DATA_LOSS ((MojoResult) -15) 125 #define MOJO_RESULT_BUSY ((MojoResult) -16) 126 #endif 127 128 // |MojoDeadline|: Used to specify deadlines (timeouts), in microseconds (except 129 // for |MOJO_DEADLINE_INDEFINITE|). 130 // |MOJO_DEADLINE_INDEFINITE| - Used to indicate "forever". 131 132 typedef uint64_t MojoDeadline; 133 134 #ifdef __cplusplus 135 const MojoDeadline MOJO_DEADLINE_INDEFINITE = static_cast<MojoDeadline>(-1); 136 #else 137 #define MOJO_DEADLINE_INDEFINITE = ((MojoDeadline) -1); 138 #endif 139 140 // |MojoWaitFlags|: Used to specify the state of a handle to wait on (e.g., the 141 // ability to read or write to it). 142 // |MOJO_WAIT_FLAG_NONE| - No flags. |MojoWait()|, etc. will return 143 // |MOJO_RESULT_FAILED_PRECONDITION| if you attempt to wait on this. 144 // |MOJO_WAIT_FLAG_READABLE| - Can read (e.g., a message) from the handle. 145 // |MOJO_WAIT_FLAG_WRITABLE| - Can write (e.g., a message) to the handle. 146 // |MOJO_WAIT_FLAG_EVERYTHING| - All flags. 147 148 typedef uint32_t MojoWaitFlags; 149 150 #ifdef __cplusplus 151 const MojoWaitFlags MOJO_WAIT_FLAG_NONE = 0; 152 const MojoWaitFlags MOJO_WAIT_FLAG_READABLE = 1 << 0; 153 const MojoWaitFlags MOJO_WAIT_FLAG_WRITABLE = 1 << 1; 154 const MojoWaitFlags MOJO_WAIT_FLAG_EVERYTHING = ~0; 155 #else 156 #define MOJO_WAIT_FLAG_NONE ((MojoWaitFlags) 0) 157 #define MOJO_WAIT_FLAG_READABLE ((MojoWaitFlags) 1 << 0) 158 #define MOJO_WAIT_FLAG_WRITABLE ((MojoWaitFlags) 1 << 1) 159 #define MOJO_WAIT_FLAG_EVERYTHING (~((MojoWaitFlags) 0)) 160 #endif 161 162 // Message pipe: 163 164 // |MojoWriteMessageFlags|: Used to specify different modes to 165 // |MojoWriteMessage()|. 166 // |MOJO_WRITE_MESSAGE_FLAG_NONE| - No flags; default mode. 167 168 typedef uint32_t MojoWriteMessageFlags; 169 170 #ifdef __cplusplus 171 const MojoWriteMessageFlags MOJO_WRITE_MESSAGE_FLAG_NONE = 0; 172 #else 173 #define MOJO_WRITE_MESSAGE_FLAG_NONE ((MojoWriteMessageFlags) 0) 174 #endif 175 176 // |MojoReadMessageFlags|: Used to specify different modes to 177 // |MojoReadMessage()|. 178 // |MOJO_READ_MESSAGE_FLAG_NONE| - No flags; default mode. 179 // |MOJO_READ_MESSAGE_FLAG_MAY_DISCARD| - If the message is unable to be read 180 // for whatever reason (e.g., the caller-supplied buffer is too small), 181 // discard the message (i.e., simply dequeue it). 182 183 typedef uint32_t MojoReadMessageFlags; 184 185 #ifdef __cplusplus 186 const MojoReadMessageFlags MOJO_READ_MESSAGE_FLAG_NONE = 0; 187 const MojoReadMessageFlags MOJO_READ_MESSAGE_FLAG_MAY_DISCARD = 1 << 0; 188 #else 189 #define MOJO_READ_MESSAGE_FLAG_NONE ((MojoReadMessageFlags) 0) 190 #define MOJO_READ_MESSAGE_FLAG_MAY_DISCARD ((MojoReadMessageFlags) 1 << 0) 191 #endif 192 193 // Data pipe: 194 195 // |MojoCreateDataPipeOptions|: Used to specify creation parameters for a data 196 // pipe to |MojoCreateDataPipe()|. 197 // |MojoCreateDataPipeOptionsFlags|: Used to specify different modes of 198 // operation. 199 // |MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE|: No flags; default mode. 200 // |MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD|: May discard data for 201 // whatever reason; best-effort delivery. In particular, if the capacity 202 // is reached, old data may be discard to make room for new data. 203 // 204 // |element_size * capacity_num_elements| must be less than 2^32 (i.e., it must 205 // fit into a 32-bit unsigned integer). 206 // TODO(vtl): Finish this. 207 typedef uint32_t MojoCreateDataPipeOptionsFlags; 208 209 #ifdef __cplusplus 210 const MojoCreateDataPipeOptionsFlags 211 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE = 0; 212 const MojoCreateDataPipeOptionsFlags 213 MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD = 1 << 0; 214 #else 215 #define MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_NONE \ 216 ((MojoCreateDataPipeOptionsFlags) 0) 217 #define MOJO_CREATE_DATA_PIPE_OPTIONS_FLAG_MAY_DISCARD \ 218 ((MojoCreateDataPipeOptionsFlags) 1 << 0) 219 #endif 220 221 struct MojoCreateDataPipeOptions { 222 size_t struct_size; // Set to the size of this structure. 223 MojoCreateDataPipeOptionsFlags flags; 224 uint32_t element_size; // Must be nonzero. 225 uint32_t capacity_num_elements; // Zero means "default"/automatic. 226 }; 227 228 // |MojoWriteDataFlags|: Used to specify different modes to |MojoWriteData()| 229 // and |MojoBeginWriteData()|. 230 // |MOJO_WRITE_DATA_FLAG_NONE| - No flags; default mode. 231 // |MOJO_WRITE_DATA_FLAG_ALL_OR_NOTHING| - Write either all the elements 232 // requested or none of them. 233 234 typedef uint32_t MojoWriteDataFlags; 235 236 #ifdef __cplusplus 237 const MojoWriteDataFlags MOJO_WRITE_DATA_FLAG_NONE = 0; 238 const MojoWriteDataFlags MOJO_WRITE_DATA_FLAG_ALL_OR_NONE = 1 << 0; 239 #else 240 #define MOJO_WRITE_DATA_FLAG_NONE ((MojoWriteDataFlags) 0) 241 #define MOJO_WRITE_DATA_FLAG_ALL_OR_NONE ((MojoWriteDataFlags) 1 << 0) 242 #endif 243 244 // |MojoReadDataFlags|: Used to specify different modes to |MojoReadData()| and 245 // |MojoBeginReadData()|. 246 // |MOJO_READ_DATA_FLAG_NONE| - No flags; default mode. 247 // |MOJO_READ_DATA_FLAG_ALL_OR_NONE| - Read (or discard) either the requested 248 // number of elements or none. 249 // |MOJO_READ_DATA_FLAG_DISCARD| - Discard (up to) the requested number of 250 // elements. 251 // |MOJO_READ_DATA_FLAG_QUERY| - Query the number of elements available to 252 // read. For use with |MojoReadData()| only. Mutually exclusive with 253 // |MOJO_READ_DATA_FLAG_DISCARD| and |MOJO_READ_DATA_FLAG_ALL_OR_NONE| is 254 // ignored if this flag is set. 255 256 typedef uint32_t MojoReadDataFlags; 257 258 #ifdef __cplusplus 259 const MojoReadDataFlags MOJO_READ_DATA_FLAG_NONE = 0; 260 const MojoReadDataFlags MOJO_READ_DATA_FLAG_ALL_OR_NONE = 1 << 0; 261 const MojoReadDataFlags MOJO_READ_DATA_FLAG_DISCARD = 1 << 1; 262 const MojoReadDataFlags MOJO_READ_DATA_FLAG_QUERY = 1 << 2; 263 #else 264 #define MOJO_READ_DATA_FLAG_NONE ((MojoReadDataFlags) 0) 265 #define MOJO_READ_DATA_FLAG_ALL_OR_NONE ((MojoReadDataFlags) 1 << 0) 266 #define MOJO_READ_DATA_FLAG_DISCARD ((MojoReadDataFlags) 1 << 1) 267 #define MOJO_READ_DATA_FLAG_QUERY ((MojoReadDataFlags) 1 << 2) 268 #endif 269 270 // Functions ------------------------------------------------------------------- 271 272 #ifdef __cplusplus 273 extern "C" { 274 #endif 275 276 // Platform-dependent monotonically increasing tick count representing "right 277 // now." The resolution of this clock is ~1-15ms. Resolution varies depending 278 // on hardware/operating system configuration. 279 MOJO_SYSTEM_EXPORT MojoTimeTicks MojoGetTimeTicksNow(); 280 281 // Closes the given |handle|. 282 // 283 // Returns: 284 // |MOJO_RESULT_OK| on success. 285 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. 286 // 287 // Concurrent operations on |handle| may succeed (or fail as usual) if they 288 // happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if 289 // they properly overlap (this is likely the case with |MojoWait()|, etc.), or 290 // fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. 291 MOJO_SYSTEM_EXPORT MojoResult MojoClose(MojoHandle handle); 292 293 // Waits on the given handle until the state indicated by |flags| is satisfied 294 // or until |deadline| has passed. 295 // 296 // Returns: 297 // |MOJO_RESULT_OK| if some flag in |flags| was satisfied (or is already 298 // satisfied). 299 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if 300 // it has already been closed). 301 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of 302 // the flags being satisfied. 303 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that any 304 // flag in |flags| will ever be satisfied. 305 // 306 // If there are multiple waiters (on different threads, obviously) waiting on 307 // the same handle and flag and that flag becomes set, all waiters will be 308 // awoken. 309 MOJO_SYSTEM_EXPORT MojoResult MojoWait(MojoHandle handle, 310 MojoWaitFlags flags, 311 MojoDeadline deadline); 312 313 // Waits on |handles[0]|, ..., |handles[num_handles-1]| for at least one of them 314 // to satisfy the state indicated by |flags[0]|, ..., |flags[num_handles-1]|, 315 // respectively, or until |deadline| has passed. 316 // 317 // Returns: 318 // The index |i| (from 0 to |num_handles-1|) if |handle[i]| satisfies 319 // |flags[i]|. 320 // |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle 321 // (e.g., if it has already been closed). 322 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of 323 // handles satisfying any of its flags. 324 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME 325 // |handle[i]| will ever satisfy any of its flags |flags[i]|. 326 MOJO_SYSTEM_EXPORT MojoResult MojoWaitMany(const MojoHandle* handles, 327 const MojoWaitFlags* flags, 328 uint32_t num_handles, 329 MojoDeadline deadline); 330 331 // Message pipe: 332 333 // Creates a message pipe, which is a bidirectional communication channel for 334 // framed data (i.e., messages). Messages can contain plain data and/or Mojo 335 // handles. On success, |*message_pipe_handle_0| and |*message_pipe_1| are set 336 // to handles for the two endpoints (ports) for the message pipe. 337 // 338 // Returns: 339 // |MOJO_RESULT_OK| on success. 340 // |MOJO_RESULT_INVALID_ARGUMENT| if |message_pipe_handle_0| and/or 341 // |message_pipe_handle_1| do not appear to be valid pointers. 342 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has 343 // been reached. 344 // 345 // TODO(vtl): Add an options struct pointer argument. 346 MOJO_SYSTEM_EXPORT MojoResult MojoCreateMessagePipe( 347 MojoHandle* message_pipe_handle_0, 348 MojoHandle* message_pipe_handle_1); 349 350 // Writes a message to the message pipe endpoint given by |message_pipe_handle|, 351 // with message data specified by |bytes| of size |num_bytes| and attached 352 // handles specified by |handles| of count |num_handles|, and options specified 353 // by |flags|. If there is no message data, |bytes| may be null, in which case 354 // |num_bytes| must be zero. If there are no attached handles, |handles| may be 355 // null, in which case |num_handles| must be zero. 356 // 357 // If handles are attached, on success the handles will no longer be valid (the 358 // receiver will receive equivalent, but logically different, handles). Handles 359 // to be sent should not be in simultaneous use (e.g., on another thread). 360 // 361 // Returns: 362 // |MOJO_RESULT_OK| on success (i.e., the message was enqueued). 363 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid (e.g., if 364 // |message_pipe_handle| is not a valid handle, or some of the 365 // requirements above are not satisfied). 366 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if some system limit has been reached, or 367 // the number of handles to send is too large (TODO(vtl): reconsider the 368 // latter case). 369 // |MOJO_RESULT_FAILED_PRECONDITION| if the other endpoint has been closed. 370 // Note that closing an endpoint is not necessarily synchronous (e.g., 371 // across processes), so this function may be succeed even if the other 372 // endpoint has been closed (in which case the message would be dropped). 373 // |MOJO_RESULT_BUSY| if some handle to be sent is currently in use. 374 // 375 // TODO(vtl): Add a notion of capacity for message pipes, and return 376 // |MOJO_RESULT_SHOULD_WAIT| if the message pipe is full. 377 MOJO_SYSTEM_EXPORT MojoResult MojoWriteMessage(MojoHandle message_pipe_handle, 378 const void* bytes, 379 uint32_t num_bytes, 380 const MojoHandle* handles, 381 uint32_t num_handles, 382 MojoWriteMessageFlags flags); 383 384 // Reads a message from the message pipe endpoint given by 385 // |message_pipe_handle|; also usable to query the size of the next message or 386 // discard the next message. |bytes|/|*num_bytes| indicate the buffer/buffer 387 // size to receive the message data (if any) and |handles|/|*num_handles| 388 // indicate the buffer/maximum handle count to receive the attached handles (if 389 // any). 390 // 391 // |num_bytes| and |num_handles| are optional "in-out" parameters. If non-null, 392 // on return |*num_bytes| and |*num_handles| will usually indicate the number 393 // of bytes and number of attached handles in the "next" message, respectively, 394 // whether that message was read or not. (If null, the number of bytes/handles 395 // is treated as zero.) 396 // 397 // If |bytes| is null, then |*num_bytes| must be zero, and similarly for 398 // |handles| and |*num_handles|. 399 // 400 // Partial reads are NEVER done. Either a full read is done and |MOJO_RESULT_OK| 401 // returned, or the read is NOT done and |MOJO_RESULT_RESOURCE_EXHAUSTED| is 402 // returned (if |MOJO_READ_MESSAGE_FLAG_MAY_DISCARD| was set, the message is 403 // also discarded in this case). 404 // 405 // Returns: 406 // |MOJO_RESULT_OK| on success (i.e., a message was actually read). 407 // |MOJO_RESULT_INVALID_ARGUMENT| if some argument was invalid. 408 // |MOJO_RESULT_NOT_FOUND| if no message was available to be read (TODO(vtl): 409 // change this to |MOJO_RESULT_SHOULD_WAIT|). 410 // |MOJO_RESULT_FAILED_PRECONDITION| if the other endpoint has been closed. 411 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if one of the buffers to receive the 412 // message/attached handles (|bytes|/|*num_bytes| or 413 // |handles|/|*num_handles|) was too small. (TODO(vtl): Reconsider this 414 // error code; should distinguish this from the hitting-system-limits 415 // case.) 416 MOJO_SYSTEM_EXPORT MojoResult MojoReadMessage(MojoHandle message_pipe_handle, 417 void* bytes, 418 uint32_t* num_bytes, 419 MojoHandle* handles, 420 uint32_t* num_handles, 421 MojoReadMessageFlags flags); 422 423 // Data pipe: 424 // TODO(vtl): Moar docs. 425 426 MOJO_SYSTEM_EXPORT MojoResult MojoCreateDataPipe( 427 const struct MojoCreateDataPipeOptions* options, 428 MojoHandle* data_pipe_producer_handle, 429 MojoHandle* data_pipe_consumer_handle); 430 431 MOJO_SYSTEM_EXPORT MojoResult MojoWriteData( 432 MojoHandle data_pipe_producer_handle, 433 const void* elements, 434 uint32_t* num_elements, 435 MojoWriteDataFlags flags); 436 437 // TODO(vtl): Note to self: |buffer_num_elements| is an "in-out" parameter: 438 // on the "in" side, |*buffer_num_elements| is the number requested; on success, 439 // on the "out" side, it's the number available (which may be GREATER or LESS 440 // than the number requested; if the "all-or-nothing" flag is set, it's AT LEAST 441 // the number requested). 442 MOJO_SYSTEM_EXPORT MojoResult MojoBeginWriteData( 443 MojoHandle data_pipe_producer_handle, 444 void** buffer, 445 uint32_t* buffer_num_elements, 446 MojoWriteDataFlags flags); 447 448 MOJO_SYSTEM_EXPORT MojoResult MojoEndWriteData( 449 MojoHandle data_pipe_producer_handle, 450 uint32_t num_elements_written); 451 452 // TODO(vtl): Note to self: If |MOJO_READ_DATA_FLAG_QUERY| is set, then 453 // |elements| must be null (and nothing will be read). 454 MOJO_SYSTEM_EXPORT MojoResult MojoReadData( 455 MojoHandle data_pipe_consumer_handle, 456 void* elements, 457 uint32_t* num_elements, 458 MojoReadDataFlags flags); 459 460 MOJO_SYSTEM_EXPORT MojoResult MojoBeginReadData( 461 MojoHandle data_pipe_consumer_handle, 462 const void** buffer, 463 uint32_t* buffer_num_elements, 464 MojoReadDataFlags flags); 465 466 MOJO_SYSTEM_EXPORT MojoResult MojoEndReadData( 467 MojoHandle data_pipe_consumer_handle, 468 uint32_t num_elements_read); 469 470 #ifdef __cplusplus 471 } // extern "C" 472 #endif 473 474 #endif // MOJO_PUBLIC_SYSTEM_CORE_H_ 475