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 and constants/macros common to different Mojo system | 5 // This file contains types and constants/macros common to different Mojo system |
6 // APIs. | 6 // APIs. |
7 // | 7 // |
8 // Note: This header should be compilable as C. | 8 // Note: This header should be compilable as C. |
9 | 9 |
10 #ifndef MOJO_PUBLIC_C_SYSTEM_TYPES_H_ | 10 #ifndef MOJO_PUBLIC_C_SYSTEM_TYPES_H_ |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 // |MOJO_RESULT_UNAVAILABLE| - The operation is (temporarily) currently | 73 // |MOJO_RESULT_UNAVAILABLE| - The operation is (temporarily) currently |
74 // unavailable. The caller may simply retry the operation (possibly with a | 74 // unavailable. The caller may simply retry the operation (possibly with a |
75 // backoff). | 75 // backoff). |
76 // |MOJO_RESULT_DATA_LOSS| - Unrecoverable data loss or corruption. | 76 // |MOJO_RESULT_DATA_LOSS| - Unrecoverable data loss or corruption. |
77 // |MOJO_RESULT_BUSY| - One of the resources involved is currently being used | 77 // |MOJO_RESULT_BUSY| - One of the resources involved is currently being used |
78 // (possibly on another thread) in a way that prevents the current | 78 // (possibly on another thread) in a way that prevents the current |
79 // operation from proceeding, e.g., if the other operation may result in | 79 // operation from proceeding, e.g., if the other operation may result in |
80 // the resource being invalidated. | 80 // the resource being invalidated. |
81 // |MOJO_RESULT_SHOULD_WAIT| - The request cannot currently be completed | 81 // |MOJO_RESULT_SHOULD_WAIT| - The request cannot currently be completed |
82 // (e.g., if the data requested is not yet available). The caller should | 82 // (e.g., if the data requested is not yet available). The caller should |
83 // wait for it to be feasible using |MojoWait()| or |MojoWaitMany()|. | 83 // wait for it to be feasible using a watcher. |
84 // | 84 // |
85 // The codes from |MOJO_RESULT_OK| to |MOJO_RESULT_DATA_LOSS| come from | 85 // The codes from |MOJO_RESULT_OK| to |MOJO_RESULT_DATA_LOSS| come from |
86 // Google3's canonical error codes. | 86 // Google3's canonical error codes. |
87 // | 87 // |
88 // TODO(vtl): Add a |MOJO_RESULT_UNSATISFIABLE|? | 88 // TODO(vtl): Add a |MOJO_RESULT_UNSATISFIABLE|? |
89 | 89 |
90 typedef uint32_t MojoResult; | 90 typedef uint32_t MojoResult; |
91 | 91 |
92 #ifdef __cplusplus | 92 #ifdef __cplusplus |
93 const MojoResult MOJO_RESULT_OK = 0; | 93 const MojoResult MOJO_RESULT_OK = 0; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 // |MOJO_DEADLINE_INDEFINITE| - Used to indicate "forever". | 134 // |MOJO_DEADLINE_INDEFINITE| - Used to indicate "forever". |
135 | 135 |
136 typedef uint64_t MojoDeadline; | 136 typedef uint64_t MojoDeadline; |
137 | 137 |
138 #ifdef __cplusplus | 138 #ifdef __cplusplus |
139 const MojoDeadline MOJO_DEADLINE_INDEFINITE = static_cast<MojoDeadline>(-1); | 139 const MojoDeadline MOJO_DEADLINE_INDEFINITE = static_cast<MojoDeadline>(-1); |
140 #else | 140 #else |
141 #define MOJO_DEADLINE_INDEFINITE ((MojoDeadline) - 1) | 141 #define MOJO_DEADLINE_INDEFINITE ((MojoDeadline) - 1) |
142 #endif | 142 #endif |
143 | 143 |
144 // |MojoHandleSignals|: Used to specify signals that can be waited on for a | 144 // |MojoHandleSignals|: Used to specify signals that can be watched for on a |
145 // handle (and which can be triggered), e.g., the ability to read or write to | 145 // handle (and which can be triggered), e.g., the ability to read or write to |
146 // the handle. | 146 // the handle. |
147 // |MOJO_HANDLE_SIGNAL_NONE| - No flags. |MojoWait()|, etc. will return | 147 // |MOJO_HANDLE_SIGNAL_NONE| - No flags. A registered watch will always fail |
148 // |MOJO_RESULT_FAILED_PRECONDITION| if you attempt to wait on this. | 148 // to arm with |MOJO_RESULT_FAILED_PRECONDITION| when watching for this. |
149 // |MOJO_HANDLE_SIGNAL_READABLE| - Can read (e.g., a message) from the handle. | 149 // |MOJO_HANDLE_SIGNAL_READABLE| - Can read (e.g., a message) from the handle. |
150 // |MOJO_HANDLE_SIGNAL_WRITABLE| - Can write (e.g., a message) to the handle. | 150 // |MOJO_HANDLE_SIGNAL_WRITABLE| - Can write (e.g., a message) to the handle. |
151 // |MOJO_HANDLE_SIGNAL_PEER_CLOSED| - The peer handle is closed. | 151 // |MOJO_HANDLE_SIGNAL_PEER_CLOSED| - The peer handle is closed. |
152 // |MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE| - Can read data from a data pipe | 152 // |MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE| - Can read data from a data pipe |
153 // consumer handle (implying MOJO_HANDLE_SIGNAL_READABLE is also set), | 153 // consumer handle (implying MOJO_HANDLE_SIGNAL_READABLE is also set), |
154 // AND there is some nonzero quantity of new data available on the pipe | 154 // AND there is some nonzero quantity of new data available on the pipe |
155 // since the last |MojoReadData()| or |MojoBeginReadData()| call on the | 155 // since the last |MojoReadData()| or |MojoBeginReadData()| call on the |
156 // handle. | 156 // handle. |
157 | 157 |
158 typedef uint32_t MojoHandleSignals; | 158 typedef uint32_t MojoHandleSignals; |
159 | 159 |
160 #ifdef __cplusplus | 160 #ifdef __cplusplus |
161 const MojoHandleSignals MOJO_HANDLE_SIGNAL_NONE = 0; | 161 const MojoHandleSignals MOJO_HANDLE_SIGNAL_NONE = 0; |
162 const MojoHandleSignals MOJO_HANDLE_SIGNAL_READABLE = 1 << 0; | 162 const MojoHandleSignals MOJO_HANDLE_SIGNAL_READABLE = 1 << 0; |
163 const MojoHandleSignals MOJO_HANDLE_SIGNAL_WRITABLE = 1 << 1; | 163 const MojoHandleSignals MOJO_HANDLE_SIGNAL_WRITABLE = 1 << 1; |
164 const MojoHandleSignals MOJO_HANDLE_SIGNAL_PEER_CLOSED = 1 << 2; | 164 const MojoHandleSignals MOJO_HANDLE_SIGNAL_PEER_CLOSED = 1 << 2; |
165 const MojoHandleSignals MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE = 1 << 3; | 165 const MojoHandleSignals MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE = 1 << 3; |
166 #else | 166 #else |
167 #define MOJO_HANDLE_SIGNAL_NONE ((MojoHandleSignals)0) | 167 #define MOJO_HANDLE_SIGNAL_NONE ((MojoHandleSignals)0) |
168 #define MOJO_HANDLE_SIGNAL_READABLE ((MojoHandleSignals)1 << 0) | 168 #define MOJO_HANDLE_SIGNAL_READABLE ((MojoHandleSignals)1 << 0) |
169 #define MOJO_HANDLE_SIGNAL_WRITABLE ((MojoHandleSignals)1 << 1) | 169 #define MOJO_HANDLE_SIGNAL_WRITABLE ((MojoHandleSignals)1 << 1) |
170 #define MOJO_HANDLE_SIGNAL_PEER_CLOSED ((MojoHandleSignals)1 << 2) | 170 #define MOJO_HANDLE_SIGNAL_PEER_CLOSED ((MojoHandleSignals)1 << 2) |
171 #define MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE ((MojoHandleSignals)1 << 3); | 171 #define MOJO_HANDLE_SIGNAL_NEW_DATA_READABLE ((MojoHandleSignals)1 << 3); |
172 #endif | 172 #endif |
173 | 173 |
174 // |MojoHandleSignalsState|: Returned by wait functions to indicate the | 174 // |MojoHandleSignalsState|: Returned by watch notification callbacks and |
175 // signaling state of handles. Members are as follows: | 175 // |MojoQueryHandleSignalsState| functions to indicate the signaling state of |
| 176 // handles. Members are as follows: |
176 // - |satisfied signals|: Bitmask of signals that were satisfied at some time | 177 // - |satisfied signals|: Bitmask of signals that were satisfied at some time |
177 // before the call returned. | 178 // before the call returned. |
178 // - |satisfiable signals|: These are the signals that are possible to | 179 // - |satisfiable signals|: These are the signals that are possible to |
179 // satisfy. For example, if the return value was | 180 // satisfy. For example, if the return value was |
180 // |MOJO_RESULT_FAILED_PRECONDITION|, you can use this field to | 181 // |MOJO_RESULT_FAILED_PRECONDITION|, you can use this field to |
181 // determine which, if any, of the signals can still be satisfied. | 182 // determine which, if any, of the signals can still be satisfied. |
182 // Note: This struct is not extensible (and only has 32-bit quantities), so it's | 183 // Note: This struct is not extensible (and only has 32-bit quantities), so it's |
183 // 32-bit-aligned. | 184 // 32-bit-aligned. |
184 MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int32_t) == 4, "int32_t has weird alignment"); | 185 MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int32_t) == 4, "int32_t has weird alignment"); |
185 struct MOJO_ALIGNAS(4) MojoHandleSignalsState { | 186 struct MOJO_ALIGNAS(4) MojoHandleSignalsState { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 // users should refrain from making sync calls. | 219 // users should refrain from making sync calls. |
219 typedef uint32_t MojoPropertyType; | 220 typedef uint32_t MojoPropertyType; |
220 | 221 |
221 #ifdef __cplusplus | 222 #ifdef __cplusplus |
222 const MojoPropertyType MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED = 0; | 223 const MojoPropertyType MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED = 0; |
223 #else | 224 #else |
224 #define MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED ((MojoPropertyType)0) | 225 #define MOJO_PROPERTY_TYPE_SYNC_CALL_ALLOWED ((MojoPropertyType)0) |
225 #endif | 226 #endif |
226 | 227 |
227 #endif // MOJO_PUBLIC_C_SYSTEM_TYPES_H_ | 228 #endif // MOJO_PUBLIC_C_SYSTEM_TYPES_H_ |
OLD | NEW |