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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 | 138 |
139 #ifdef __cplusplus | 139 #ifdef __cplusplus |
140 const MojoDeadline MOJO_DEADLINE_INDEFINITE = static_cast<MojoDeadline>(-1); | 140 const MojoDeadline MOJO_DEADLINE_INDEFINITE = static_cast<MojoDeadline>(-1); |
141 #else | 141 #else |
142 #define MOJO_DEADLINE_INDEFINITE ((MojoDeadline) -1) | 142 #define MOJO_DEADLINE_INDEFINITE ((MojoDeadline) -1) |
143 #endif | 143 #endif |
144 | 144 |
145 // |MojoHandleSignals|: Used to specify signals that can be waited on for a | 145 // |MojoHandleSignals|: Used to specify signals that can be waited on for a |
146 // handle (and which can be triggered), e.g., the ability to read or write to | 146 // handle (and which can be triggered), e.g., the ability to read or write to |
147 // the handle. | 147 // the handle. |
148 // |MOJO_WAIT_FLAG_NONE| - No flags. |MojoWait()|, etc. will return | 148 // |MOJO_HANDLE_SIGNAL_NONE| - No flags. |MojoWait()|, etc. will return |
149 // |MOJO_RESULT_FAILED_PRECONDITION| if you attempt to wait on this. | 149 // |MOJO_RESULT_FAILED_PRECONDITION| if you attempt to wait on this. |
150 // |MOJO_WAIT_FLAG_READABLE| - Can read (e.g., a message) from the handle. | 150 // |MOJO_HANDLE_SIGNAL_READABLE| - Can read (e.g., a message) from the handle. |
151 // |MOJO_WAIT_FLAG_WRITABLE| - Can write (e.g., a message) to the handle. | 151 // |MOJO_HANDLE_SIGNAL_WRITABLE| - Can write (e.g., a message) to the handle. |
152 // |MOJO_WAIT_FLAG_EVERYTHING| - All flags. | |
153 | 152 |
154 typedef uint32_t MojoHandleSignals; | 153 typedef uint32_t MojoHandleSignals; |
155 | 154 |
156 // TODO(vtl): Rename these to MOJO_HANDLE_SIGNAL_.... | |
157 #ifdef __cplusplus | 155 #ifdef __cplusplus |
158 const MojoHandleSignals MOJO_WAIT_FLAG_NONE = 0; | 156 const MojoHandleSignals MOJO_HANDLE_SIGNAL_NONE = 0; |
159 const MojoHandleSignals MOJO_WAIT_FLAG_READABLE = 1 << 0; | 157 const MojoHandleSignals MOJO_HANDLE_SIGNAL_READABLE = 1 << 0; |
160 const MojoHandleSignals MOJO_WAIT_FLAG_WRITABLE = 1 << 1; | 158 const MojoHandleSignals MOJO_HANDLE_SIGNAL_WRITABLE = 1 << 1; |
161 const MojoHandleSignals MOJO_WAIT_FLAG_EVERYTHING = ~0; | |
162 #else | 159 #else |
163 #define MOJO_WAIT_FLAG_NONE ((MojoHandleSignals) 0) | 160 #define MOJO_HANDLE_SIGNAL_NONE ((MojoHandleSignals) 0) |
164 #define MOJO_WAIT_FLAG_READABLE ((MojoHandleSignals) 1 << 0) | 161 #define MOJO_HANDLE_SIGNAL_READABLE ((MojoHandleSignals) 1 << 0) |
165 #define MOJO_WAIT_FLAG_WRITABLE ((MojoHandleSignals) 1 << 1) | 162 #define MOJO_HANDLE_SIGNAL_WRITABLE ((MojoHandleSignals) 1 << 1) |
166 #define MOJO_WAIT_FLAG_EVERYTHING (~((MojoHandleSignals) 0)) | |
167 #endif | 163 #endif |
168 | 164 |
169 // TODO(vtl): Add out parameters with this to MojoWait/MojoWaitMany. | 165 // TODO(vtl): Add out parameters with this to MojoWait/MojoWaitMany. |
170 // Note: This struct is not extensible (and only has 32-bit quantities), so it's | 166 // Note: This struct is not extensible (and only has 32-bit quantities), so it's |
171 // 32-bit-aligned. | 167 // 32-bit-aligned. |
172 // TODO(vtl): Rename this to MojoHandleSignalsState. | 168 // TODO(vtl): Rename this to MojoHandleSignalsState. |
173 MOJO_COMPILE_ASSERT(MOJO_ALIGNOF(int32_t) == 4, int32_t_has_weird_alignment); | 169 MOJO_COMPILE_ASSERT(MOJO_ALIGNOF(int32_t) == 4, int32_t_has_weird_alignment); |
174 struct MOJO_ALIGNAS(4) MojoWaitFlagsState { | 170 struct MOJO_ALIGNAS(4) MojoWaitFlagsState { |
175 MojoHandleSignals satisfied_signals; | 171 MojoHandleSignals satisfied_signals; |
176 MojoHandleSignals satisfiable_signals; | 172 MojoHandleSignals satisfiable_signals; |
177 }; | 173 }; |
178 MOJO_COMPILE_ASSERT(sizeof(MojoWaitFlagsState) == 8, | 174 MOJO_COMPILE_ASSERT(sizeof(MojoWaitFlagsState) == 8, |
179 MojoWaitFlagsState_has_wrong_size); | 175 MojoWaitFlagsState_has_wrong_size); |
180 | 176 |
181 #endif // MOJO_PUBLIC_C_SYSTEM_TYPES_H_ | 177 #endif // MOJO_PUBLIC_C_SYSTEM_TYPES_H_ |
OLD | NEW |