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