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 message pipes. | 5 // This file contains types/constants and functions specific to message pipes. |
6 // | 6 // |
7 // Note: This header should be compilable as C. | 7 // Note: This header should be compilable as C. |
8 | 8 |
9 #ifndef MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ | 9 #ifndef MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ |
10 #define MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ | 10 #define MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ |
11 | 11 |
| 12 #include "mojo/public/c/system/macros.h" |
12 #include "mojo/public/c/system/system_export.h" | 13 #include "mojo/public/c/system/system_export.h" |
13 #include "mojo/public/c/system/types.h" | 14 #include "mojo/public/c/system/types.h" |
14 | 15 |
| 16 // |MojoCreateMessagePipeOptions|: Used to specify creation parameters for a |
| 17 // message pipe to |MojoCreateMessagePipe()|. |
| 18 // |uint32_t struct_size|: Set to the size of the |
| 19 // |MojoCreateMessagePipeOptions| struct. (Used to allow for future |
| 20 // extensions.) |
| 21 // |MojoCreateMessagePipeOptionsFlags flags|: Reserved for future use. |
| 22 // |MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE|: No flags; default mode. |
| 23 |
| 24 typedef uint32_t MojoCreateMessagePipeOptionsFlags; |
| 25 |
| 26 #ifdef __cplusplus |
| 27 const MojoCreateMessagePipeOptionsFlags |
| 28 MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE = 0; |
| 29 #else |
| 30 #define MOJO_CREATE_MESSAGE_PIPE_OPTIONS_FLAG_NONE \ |
| 31 ((MojoCreateMessagePipeOptionsFlags) 0) |
| 32 #endif |
| 33 |
| 34 MOJO_COMPILE_ASSERT(MOJO_ALIGNOF(int64_t) == 8, int64_t_has_weird_alignment); |
| 35 struct MOJO_ALIGNAS(8) MojoCreateMessagePipeOptions { |
| 36 uint32_t struct_size; |
| 37 MojoCreateMessagePipeOptionsFlags flags; |
| 38 }; |
| 39 MOJO_COMPILE_ASSERT(sizeof(MojoCreateMessagePipeOptions) == 8, |
| 40 MojoCreateMessagePipeOptions_has_wrong_size); |
| 41 |
15 // |MojoWriteMessageFlags|: Used to specify different modes to | 42 // |MojoWriteMessageFlags|: Used to specify different modes to |
16 // |MojoWriteMessage()|. | 43 // |MojoWriteMessage()|. |
17 // |MOJO_WRITE_MESSAGE_FLAG_NONE| - No flags; default mode. | 44 // |MOJO_WRITE_MESSAGE_FLAG_NONE| - No flags; default mode. |
18 | 45 |
19 typedef uint32_t MojoWriteMessageFlags; | 46 typedef uint32_t MojoWriteMessageFlags; |
20 | 47 |
21 #ifdef __cplusplus | 48 #ifdef __cplusplus |
22 const MojoWriteMessageFlags MOJO_WRITE_MESSAGE_FLAG_NONE = 0; | 49 const MojoWriteMessageFlags MOJO_WRITE_MESSAGE_FLAG_NONE = 0; |
23 #else | 50 #else |
24 #define MOJO_WRITE_MESSAGE_FLAG_NONE ((MojoWriteMessageFlags) 0) | 51 #define MOJO_WRITE_MESSAGE_FLAG_NONE ((MojoWriteMessageFlags) 0) |
(...skipping 18 matching lines...) Expand all Loading... |
43 | 70 |
44 #ifdef __cplusplus | 71 #ifdef __cplusplus |
45 extern "C" { | 72 extern "C" { |
46 #endif | 73 #endif |
47 | 74 |
48 // Note: See the comment in functions.h about the meaning of the "optional" | 75 // Note: See the comment in functions.h about the meaning of the "optional" |
49 // label for pointer parameters. | 76 // label for pointer parameters. |
50 | 77 |
51 // Creates a message pipe, which is a bidirectional communication channel for | 78 // Creates a message pipe, which is a bidirectional communication channel for |
52 // framed data (i.e., messages). Messages can contain plain data and/or Mojo | 79 // framed data (i.e., messages). Messages can contain plain data and/or Mojo |
53 // handles. On success, |*message_pipe_handle0| and |*message_pipe_handle1| are | 80 // handles. |
54 // set to handles for the two endpoints (ports) for the message pipe. | 81 // |
| 82 // |options| may be set to null for a message pipe with the default options. |
| 83 // |
| 84 // On success, |*message_pipe_handle0| and |*message_pipe_handle1| are set to |
| 85 // handles for the two endpoints (ports) for the message pipe. |
55 // | 86 // |
56 // Returns: | 87 // Returns: |
57 // |MOJO_RESULT_OK| on success. | 88 // |MOJO_RESULT_OK| on success. |
58 // |MOJO_RESULT_INVALID_ARGUMENT| if |message_pipe_handle0| and/or | 89 // |MOJO_RESULT_INVALID_ARGUMENT| if |message_pipe_handle0| and/or |
59 // |message_pipe_handle1| do not appear to be valid pointers. | 90 // |message_pipe_handle1| do not appear to be valid pointers. |
60 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has | 91 // |MOJO_RESULT_RESOURCE_EXHAUSTED| if a process/system/quota/etc. limit has |
61 // been reached. | 92 // been reached. |
62 // | 93 // |
63 // TODO(vtl): Add an options struct pointer argument. | 94 // TODO(vtl): Add an options struct pointer argument. |
64 MOJO_SYSTEM_EXPORT MojoResult MojoCreateMessagePipe( | 95 MOJO_SYSTEM_EXPORT MojoResult MojoCreateMessagePipe( |
| 96 const struct MojoCreateMessagePipeOptions* options, // Optional. |
65 MojoHandle* message_pipe_handle0, // Out. | 97 MojoHandle* message_pipe_handle0, // Out. |
66 MojoHandle* message_pipe_handle1); // Out. | 98 MojoHandle* message_pipe_handle1); // Out. |
67 | 99 |
68 // Writes a message to the message pipe endpoint given by |message_pipe_handle|, | 100 // Writes a message to the message pipe endpoint given by |message_pipe_handle|, |
69 // with message data specified by |bytes| of size |num_bytes| and attached | 101 // with message data specified by |bytes| of size |num_bytes| and attached |
70 // handles specified by |handles| of count |num_handles|, and options specified | 102 // handles specified by |handles| of count |num_handles|, and options specified |
71 // by |flags|. If there is no message data, |bytes| may be null, in which case | 103 // by |flags|. If there is no message data, |bytes| may be null, in which case |
72 // |num_bytes| must be zero. If there are no attached handles, |handles| may be | 104 // |num_bytes| must be zero. If there are no attached handles, |handles| may be |
73 // null, in which case |num_handles| must be zero. | 105 // null, in which case |num_handles| must be zero. |
74 // | 106 // |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 uint32_t* num_bytes, // Optional in/out. | 169 uint32_t* num_bytes, // Optional in/out. |
138 MojoHandle* handles, // Optional out. | 170 MojoHandle* handles, // Optional out. |
139 uint32_t* num_handles, // Optional in/out. | 171 uint32_t* num_handles, // Optional in/out. |
140 MojoReadMessageFlags flags); | 172 MojoReadMessageFlags flags); |
141 | 173 |
142 #ifdef __cplusplus | 174 #ifdef __cplusplus |
143 } // extern "C" | 175 } // extern "C" |
144 #endif | 176 #endif |
145 | 177 |
146 #endif // MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ | 178 #endif // MOJO_PUBLIC_C_SYSTEM_MESSAGE_PIPE_H_ |
OLD | NEW |