| 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 // Note: This header should be compilable as C. |
| 6 |
| 5 #ifndef MOJO_PUBLIC_C_SYSTEM_CORE_H_ | 7 #ifndef MOJO_PUBLIC_C_SYSTEM_CORE_H_ |
| 6 #define MOJO_PUBLIC_C_SYSTEM_CORE_H_ | 8 #define MOJO_PUBLIC_C_SYSTEM_CORE_H_ |
| 7 | 9 |
| 8 // Note: This header should be compilable as C. | |
| 9 | |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 | 11 |
| 12 #include "mojo/public/c/system/functions.h" |
| 12 #include "mojo/public/c/system/macros.h" | 13 #include "mojo/public/c/system/macros.h" |
| 13 #include "mojo/public/c/system/system_export.h" | 14 #include "mojo/public/c/system/system_export.h" |
| 14 #include "mojo/public/c/system/types.h" | 15 #include "mojo/public/c/system/types.h" |
| 15 | 16 |
| 16 // Types/constants ------------------------------------------------------------- | 17 // Types/constants ------------------------------------------------------------- |
| 17 | 18 |
| 18 // TODO(vtl): Split these into their own header files. | 19 // TODO(vtl): Split these into their own header files. |
| 19 | 20 |
| 20 // Message pipe: | 21 // Message pipe: |
| 21 | 22 |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 typedef uint32_t MojoMapBufferFlags; | 200 typedef uint32_t MojoMapBufferFlags; |
| 200 | 201 |
| 201 #ifdef __cplusplus | 202 #ifdef __cplusplus |
| 202 const MojoMapBufferFlags MOJO_MAP_BUFFER_FLAG_NONE = 0; | 203 const MojoMapBufferFlags MOJO_MAP_BUFFER_FLAG_NONE = 0; |
| 203 #else | 204 #else |
| 204 #define MOJO_MAP_BUFFER_FLAG_NONE ((MojoMapBufferFlags) 0) | 205 #define MOJO_MAP_BUFFER_FLAG_NONE ((MojoMapBufferFlags) 0) |
| 205 #endif | 206 #endif |
| 206 | 207 |
| 207 // Functions ------------------------------------------------------------------- | 208 // Functions ------------------------------------------------------------------- |
| 208 | 209 |
| 209 // Note: Pointer parameters that are labeled "optional" may be null (at least | 210 // Note: See the comment in functions.h about the meaning of the "optional" |
| 210 // under some circumstances). Non-const pointer parameters are also labelled | 211 // label for pointer parameters. |
| 211 // "in", "out", or "in/out", to indicate how they are used. (Note that how/if | |
| 212 // such a parameter is used may depend on other parameters or the requested | |
| 213 // operation's success/failure. E.g., a separate |flags| parameter may control | |
| 214 // whether a given "in/out" parameter is used for input, output, or both.) | |
| 215 | 212 |
| 216 #ifdef __cplusplus | 213 #ifdef __cplusplus |
| 217 extern "C" { | 214 extern "C" { |
| 218 #endif | 215 #endif |
| 219 | 216 |
| 220 // Platform-dependent monotonically increasing tick count representing "right | |
| 221 // now." The resolution of this clock is ~1-15ms. Resolution varies depending | |
| 222 // on hardware/operating system configuration. | |
| 223 MOJO_SYSTEM_EXPORT MojoTimeTicks MojoGetTimeTicksNow(); | |
| 224 | |
| 225 // Closes the given |handle|. | |
| 226 // | |
| 227 // Returns: | |
| 228 // |MOJO_RESULT_OK| on success. | |
| 229 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle. | |
| 230 // | |
| 231 // Concurrent operations on |handle| may succeed (or fail as usual) if they | |
| 232 // happen before the close, be cancelled with result |MOJO_RESULT_CANCELLED| if | |
| 233 // they properly overlap (this is likely the case with |MojoWait()|, etc.), or | |
| 234 // fail with |MOJO_RESULT_INVALID_ARGUMENT| if they happen after. | |
| 235 MOJO_SYSTEM_EXPORT MojoResult MojoClose(MojoHandle handle); | |
| 236 | |
| 237 // Waits on the given handle until the state indicated by |flags| is satisfied | |
| 238 // or until |deadline| has passed. | |
| 239 // | |
| 240 // Returns: | |
| 241 // |MOJO_RESULT_OK| if some flag in |flags| was satisfied (or is already | |
| 242 // satisfied). | |
| 243 // |MOJO_RESULT_INVALID_ARGUMENT| if |handle| is not a valid handle (e.g., if | |
| 244 // it has already been closed). | |
| 245 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | |
| 246 // the flags being satisfied. | |
| 247 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that any | |
| 248 // flag in |flags| will ever be satisfied. | |
| 249 // | |
| 250 // If there are multiple waiters (on different threads, obviously) waiting on | |
| 251 // the same handle and flag and that flag becomes set, all waiters will be | |
| 252 // awoken. | |
| 253 MOJO_SYSTEM_EXPORT MojoResult MojoWait(MojoHandle handle, | |
| 254 MojoWaitFlags flags, | |
| 255 MojoDeadline deadline); | |
| 256 | |
| 257 // Waits on |handles[0]|, ..., |handles[num_handles-1]| for at least one of them | |
| 258 // to satisfy the state indicated by |flags[0]|, ..., |flags[num_handles-1]|, | |
| 259 // respectively, or until |deadline| has passed. | |
| 260 // | |
| 261 // Returns: | |
| 262 // The index |i| (from 0 to |num_handles-1|) if |handle[i]| satisfies | |
| 263 // |flags[i]|. | |
| 264 // |MOJO_RESULT_INVALID_ARGUMENT| if some |handle[i]| is not a valid handle | |
| 265 // (e.g., if it has already been closed). | |
| 266 // |MOJO_RESULT_DEADLINE_EXCEEDED| if the deadline has passed without any of | |
| 267 // handles satisfying any of its flags. | |
| 268 // |MOJO_RESULT_FAILED_PRECONDITION| if it is or becomes impossible that SOME | |
| 269 // |handle[i]| will ever satisfy any of its flags |flags[i]|. | |
| 270 MOJO_SYSTEM_EXPORT MojoResult MojoWaitMany(const MojoHandle* handles, | |
| 271 const MojoWaitFlags* flags, | |
| 272 uint32_t num_handles, | |
| 273 MojoDeadline deadline); | |
| 274 | |
| 275 // Message pipe: | 217 // Message pipe: |
| 276 | 218 |
| 277 // Creates a message pipe, which is a bidirectional communication channel for | 219 // Creates a message pipe, which is a bidirectional communication channel for |
| 278 // framed data (i.e., messages). Messages can contain plain data and/or Mojo | 220 // framed data (i.e., messages). Messages can contain plain data and/or Mojo |
| 279 // handles. On success, |*message_pipe_handle0| and |*message_pipe_handle1| are | 221 // handles. On success, |*message_pipe_handle0| and |*message_pipe_handle1| are |
| 280 // set to handles for the two endpoints (ports) for the message pipe. | 222 // set to handles for the two endpoints (ports) for the message pipe. |
| 281 // | 223 // |
| 282 // Returns: | 224 // Returns: |
| 283 // |MOJO_RESULT_OK| on success. | 225 // |MOJO_RESULT_OK| on success. |
| 284 // |MOJO_RESULT_INVALID_ARGUMENT| if |message_pipe_handle0| and/or | 226 // |MOJO_RESULT_INVALID_ARGUMENT| if |message_pipe_handle0| and/or |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 | 606 |
| 665 // Unmap a buffer pointer that was mapped by |MojoMapBuffer()|. | 607 // Unmap a buffer pointer that was mapped by |MojoMapBuffer()|. |
| 666 // TODO(vtl): More. | 608 // TODO(vtl): More. |
| 667 MOJO_SYSTEM_EXPORT MojoResult MojoUnmapBuffer(void* buffer); // In. | 609 MOJO_SYSTEM_EXPORT MojoResult MojoUnmapBuffer(void* buffer); // In. |
| 668 | 610 |
| 669 #ifdef __cplusplus | 611 #ifdef __cplusplus |
| 670 } // extern "C" | 612 } // extern "C" |
| 671 #endif | 613 #endif |
| 672 | 614 |
| 673 #endif // MOJO_PUBLIC_C_SYSTEM_CORE_H_ | 615 #endif // MOJO_PUBLIC_C_SYSTEM_CORE_H_ |
| OLD | NEW |